diff --git a/ram/portal/templates/base.html b/ram/portal/templates/base.html
index 9d64635..a860f83 100644
--- a/ram/portal/templates/base.html
+++ b/ram/portal/templates/base.html
@@ -180,7 +180,7 @@
- FIXME: {{ type }}
{% if request.user.is_staff %}
Edit{% endif %}
diff --git a/ram/portal/templates/cards.html b/ram/portal/templates/cards.html
index c1df627..b62276b 100644
--- a/ram/portal/templates/cards.html
+++ b/ram/portal/templates/cards.html
@@ -6,7 +6,7 @@
{% block cards %}
{% for d in data %}
- {% if d.type == "rolling_stock" %}
+ {% if d.type == "roster" %}
{% include "cards/roster.html" %}
{% elif d.type == "company" %}
{% include "cards/company.html" %}
diff --git a/ram/portal/templates/companies.html b/ram/portal/templates/companies.html
deleted file mode 100644
index 1c62ccc..0000000
--- a/ram/portal/templates/companies.html
+++ /dev/null
@@ -1,40 +0,0 @@
-{% extends "cards.html" %}
- {% block pagination %}
- {% if data.has_other_pages %}
-
- {% endif %}
- {% endblock %}
diff --git a/ram/portal/templates/consists.html b/ram/portal/templates/consists.html
deleted file mode 100644
index ca216a6..0000000
--- a/ram/portal/templates/consists.html
+++ /dev/null
@@ -1,40 +0,0 @@
-{% extends "cards.html" %}
- {% block pagination %}
- {% if data.has_other_pages %}
-
- {% endif %}
- {% endblock %}
diff --git a/ram/portal/templates/home.html b/ram/portal/templates/home.html
index 9876353..f7080bd 100644
--- a/ram/portal/templates/home.html
+++ b/ram/portal/templates/home.html
@@ -1,4 +1,4 @@
-{% extends "roster.html" %}
+{% extends "pagination.html" %}
{% block header %}
{{ site_conf.about | safe }}
diff --git a/ram/portal/templates/bookshelf/books.html b/ram/portal/templates/pagination.html
similarity index 100%
rename from ram/portal/templates/bookshelf/books.html
rename to ram/portal/templates/pagination.html
diff --git a/ram/portal/templates/manufacturers.html b/ram/portal/templates/pagination_manufacturers.html
similarity index 100%
rename from ram/portal/templates/manufacturers.html
rename to ram/portal/templates/pagination_manufacturers.html
diff --git a/ram/portal/templates/roster.html b/ram/portal/templates/roster.html
deleted file mode 100644
index ab46bc5..0000000
--- a/ram/portal/templates/roster.html
+++ /dev/null
@@ -1,41 +0,0 @@
-{% extends "cards.html" %}
-
- {% block pagination %}
- {% if data.has_other_pages %}
-
- {% endif %}
- {% endblock %}
diff --git a/ram/portal/templates/scales.html b/ram/portal/templates/scales.html
deleted file mode 100644
index 462fa05..0000000
--- a/ram/portal/templates/scales.html
+++ /dev/null
@@ -1,40 +0,0 @@
-{% extends "cards.html" %}
- {% block pagination %}
- {% if data.has_other_pages %}
-
- {% endif %}
- {% endblock %}
diff --git a/ram/portal/templates/types.html b/ram/portal/templates/types.html
deleted file mode 100644
index dd76a18..0000000
--- a/ram/portal/templates/types.html
+++ /dev/null
@@ -1,40 +0,0 @@
-{% extends "cards.html" %}
- {% block pagination %}
- {% if data.has_other_pages %}
-
- {% endif %}
- {% endblock %}
diff --git a/ram/portal/templatetags/dynamic_url.py b/ram/portal/templatetags/dynamic_url.py
index 9b23565..fdde704 100644
--- a/ram/portal/templatetags/dynamic_url.py
+++ b/ram/portal/templatetags/dynamic_url.py
@@ -15,5 +15,7 @@ def dynamic_admin_url(app_name, model_name, object_id=None):
@register.simple_tag
-def dynamic_pagination(model_name, page):
- return reverse(f'{model_name}s_pagination', args=[page])
+def dynamic_pagination(reverse_name, page):
+ if reverse_name.endswith('y'):
+ return reverse(f'{reverse_name[:-1]}ies_pagination', args=[page])
+ return reverse(f'{reverse_name}s_pagination', args=[page])
diff --git a/ram/portal/urls.py b/ram/portal/urls.py
index 30c326a..b12943e 100644
--- a/ram/portal/urls.py
+++ b/ram/portal/urls.py
@@ -25,7 +25,7 @@ urlpatterns = [
path(
"roster/page/
",
GetRoster.as_view(),
- name="roster_pagination"
+ name="rosters_pagination"
),
path(
"page/",
@@ -34,12 +34,12 @@ urlpatterns = [
),
path(
"consists",
- Consists.as_view(template="consists.html"),
+ Consists.as_view(),
name="consists"
),
path(
"consists/page/",
- Consists.as_view(template="consists.html"),
+ Consists.as_view(),
name="consists_pagination"
),
path("consist/", GetConsist.as_view(), name="consist"),
@@ -50,52 +50,52 @@ urlpatterns = [
),
path(
"companies",
- Companies.as_view(template="companies.html"),
+ Companies.as_view(),
name="companies"
),
path(
"companies/page/",
- Companies.as_view(template="companies.html"),
+ Companies.as_view(),
name="companies_pagination",
),
path(
"manufacturers/",
- Manufacturers.as_view(template="manufacturers.html"),
+ Manufacturers.as_view(template="pagination_manufacturers.html"),
name="manufacturers"
),
path(
"manufacturers//page/",
- Manufacturers.as_view(template="manufacturers.html"),
+ Manufacturers.as_view(template="pagination_manufacturers.html"),
name="manufacturers_pagination",
),
path(
"scales",
- Scales.as_view(template="scales.html"),
+ Scales.as_view(),
name="scales"
),
path(
"scales/page/",
- Scales.as_view(template="scales.html"),
+ Scales.as_view(),
name="scales_pagination"
),
path(
"types",
- Types.as_view(template="types.html"),
- name="types"
+ Types.as_view(),
+ name="rolling_stock_types"
),
path(
"types/page/",
- Types.as_view(template="types.html"),
- name="types_pagination"
+ Types.as_view(),
+ name="rolling_stock_types_pagination"
),
path(
"bookshelf/books",
- Books.as_view(template="bookshelf/books.html"),
+ Books.as_view(),
name="books"
),
path(
"bookshelf/books/page/",
- Books.as_view(template="bookshelf/books.html"),
+ Books.as_view(),
name="books_pagination"
),
path(
@@ -105,12 +105,12 @@ urlpatterns = [
),
path(
"bookshelf/catalogs",
- Catalogs.as_view(template="bookshelf/books.html"),
+ Catalogs.as_view(),
name="catalogs"
),
path(
"bookshelf/catalogs/page/",
- Catalogs.as_view(template="bookshelf/books.html"),
+ Catalogs.as_view(),
name="catalogs_pagination"
),
path(
diff --git a/ram/portal/views.py b/ram/portal/views.py
index f60c3ee..d678379 100644
--- a/ram/portal/views.py
+++ b/ram/portal/views.py
@@ -62,8 +62,8 @@ class Render404(View):
class GetData(View):
title = "Home"
- template = "roster.html"
- item_type = "rolling_stock"
+ template = "pagination.html"
+ item_type = "roster"
filter = Q() # empty filter by default
def get_data(self, request):
@@ -78,8 +78,7 @@ class GetData(View):
for item in self.get_data(request):
data.append({"type": self.item_type, "item": item})
- paginator = Paginator(data, 3)
- # paginator = Paginator(data, get_items_per_page())
+ paginator = Paginator(data, get_items_per_page())
data = paginator.get_page(page)
page_range = paginator.get_elided_page_range(
data.number, on_each_side=1, on_ends=1
@@ -99,8 +98,8 @@ class GetData(View):
class GetRoster(GetData):
- title = "Roster"
- item_type = "rolling_stock"
+ title = "The Roster"
+ item_type = "roster"
def get_data(self, request):
return RollingStock.objects.get_published(request.user).order_by(
@@ -153,14 +152,14 @@ class SearchObjects(View):
# FIXME see if it makes sense to filter calatogs and books by scale
# and manufacturer as well
data = []
- rolling_stock = (
+ roster = (
RollingStock.objects.get_published(request.user)
.filter(query)
.distinct()
.order_by(*get_order_by_field())
)
- for item in rolling_stock:
- data.append({"type": "rolling_stock", "item": item})
+ for item in roster:
+ data.append({"type": "roster", "item": item})
if _filter is None:
consists = (
@@ -247,7 +246,7 @@ class GetManufacturerItem(View):
)
if search != "all":
- rolling_stock = get_list_or_404(
+ roster = get_list_or_404(
RollingStock.objects.get_published(request.user).order_by(
*get_order_by_field()
),
@@ -260,10 +259,10 @@ class GetManufacturerItem(View):
manufacturer,
# all returned records must have the same `item_number``;
# just pick it up the first result, otherwise `search`
- rolling_stock[0].item_number if rolling_stock else search,
+ roster.first.item_number if roster else search,
)
else:
- rolling_stock = (
+ roster = (
RollingStock.objects.get_published(request.user)
.order_by(*get_order_by_field())
.filter(
@@ -274,8 +273,8 @@ class GetManufacturerItem(View):
title = "Manufacturer: {0}".format(manufacturer)
data = []
- for item in rolling_stock:
- data.append({"type": "rolling_stock", "item": item})
+ for item in roster:
+ data.append({"type": "roster", "item": item})
paginator = Paginator(data, get_items_per_page())
data = paginator.get_page(page)
@@ -318,7 +317,7 @@ class GetObjectsFiltered(View):
else:
raise Http404
- rolling_stock = (
+ roster = (
RollingStock.objects.get_published(request.user)
.filter(query)
.distinct()
@@ -326,8 +325,8 @@ class GetObjectsFiltered(View):
)
data = []
- for item in rolling_stock:
- data.append({"type": "rolling_stock", "item": item})
+ for item in roster:
+ data.append({"type": "roster", "item": item})
try: # Execute only if query_2nd is defined
consists = (
@@ -452,7 +451,7 @@ class GetConsist(View):
raise Http404
data = [
{
- "type": "rolling_stock",
+ "type": "roster",
"item": RollingStock.objects.get_published(request.user).get(
uuid=r.rolling_stock_id
),