mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 05:07:50 +02:00
More code refactoring, reduce template duplications
This commit is contained in:
@@ -180,7 +180,7 @@
|
|||||||
<li><a class="dropdown-item" href="{% url 'manufacturers' category='model' %}">Manufacturer</a></li>
|
<li><a class="dropdown-item" href="{% url 'manufacturers' category='model' %}">Manufacturer</a></li>
|
||||||
<li><hr class="dropdown-divider"></li>
|
<li><hr class="dropdown-divider"></li>
|
||||||
<li class="ps-2 text-secondary">Prototype</li>
|
<li class="ps-2 text-secondary">Prototype</li>
|
||||||
<li><a class="dropdown-item" href="{% url 'types' %}">Type</a></li>
|
<li><a class="dropdown-item" href="{% url 'rolling_stock_types' %}">Type</a></li>
|
||||||
<li><a class="dropdown-item" href="{% url 'companies' %}">Company</a></li>
|
<li><a class="dropdown-item" href="{% url 'companies' %}">Company</a></li>
|
||||||
<li><a class="dropdown-item" href="{% url 'manufacturers' category='real' %}">Manufacturer</a></li>
|
<li><a class="dropdown-item" href="{% url 'manufacturers' category='real' %}">Manufacturer</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -136,7 +136,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||||
FIXME: {{ type }}
|
|
||||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% dynamic_admin_url 'bookshelf' type book.pk %}">Edit</a>{% endif %}
|
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% dynamic_admin_url 'bookshelf' type book.pk %}">Edit</a>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-3">
|
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-3">
|
||||||
{% block cards %}
|
{% block cards %}
|
||||||
{% for d in data %}
|
{% for d in data %}
|
||||||
{% if d.type == "rolling_stock" %}
|
{% if d.type == "roster" %}
|
||||||
{% include "cards/roster.html" %}
|
{% include "cards/roster.html" %}
|
||||||
{% elif d.type == "company" %}
|
{% elif d.type == "company" %}
|
||||||
{% include "cards/company.html" %}
|
{% include "cards/company.html" %}
|
||||||
|
@@ -1,40 +0,0 @@
|
|||||||
{% extends "cards.html" %}
|
|
||||||
{% block pagination %}
|
|
||||||
{% if data.has_other_pages %}
|
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="pagination flex-wrap justify-content-center mt-4 mb-0">
|
|
||||||
{% if data.has_previous %}
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="{% url 'companies_pagination' page=data.previous_page_number %}#main-content" tabindex="-1"><i class="bi bi-chevron-left"></i></a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link"><i class="bi bi-chevron-left"></i></span>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% for i in page_range %}
|
|
||||||
{% if data.number == i %}
|
|
||||||
<li class="page-item active">
|
|
||||||
<span class="page-link">{{ i }}</span>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
{% if i == data.paginator.ELLIPSIS %}
|
|
||||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item"><a class="page-link" href="{% url 'companies_pagination' page=i %}#main-content">{{ i }}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% if data.has_next %}
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="{% url 'companies_pagination' page=data.next_page_number %}#main-content" tabindex="-1"><i class="bi bi-chevron-right"></i></a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link"><i class="bi bi-chevron-right"></i></span>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
@@ -1,40 +0,0 @@
|
|||||||
{% extends "cards.html" %}
|
|
||||||
{% block pagination %}
|
|
||||||
{% if data.has_other_pages %}
|
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="pagination flex-wrap justify-content-center mt-4 mb-0">
|
|
||||||
{% if data.has_previous %}
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="{% url 'consists_pagination' page=data.previous_page_number %}#main-content" tabindex="-1"><i class="bi bi-chevron-left"></i></a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link"><i class="bi bi-chevron-left"></i></span>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% for i in page_range %}
|
|
||||||
{% if data.number == i %}
|
|
||||||
<li class="page-item active">
|
|
||||||
<span class="page-link">{{ i }}</span>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
{% if i == data.paginator.ELLIPSIS %}
|
|
||||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item"><a class="page-link" href="{% url 'consists_pagination' page=i %}#main-content">{{ i }}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% if data.has_next %}
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="{% url 'consists_pagination' page=data.next_page_number %}#main-content" tabindex="-1"><i class="bi bi-chevron-right"></i></a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link"><i class="bi bi-chevron-right"></i></span>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
@@ -1,4 +1,4 @@
|
|||||||
{% extends "roster.html" %}
|
{% extends "pagination.html" %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
<div class="text-muted">{{ site_conf.about | safe }}</div>
|
<div class="text-muted">{{ site_conf.about | safe }}</div>
|
||||||
|
@@ -1,41 +0,0 @@
|
|||||||
{% extends "cards.html" %}
|
|
||||||
|
|
||||||
{% block pagination %}
|
|
||||||
{% if data.has_other_pages %}
|
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="pagination flex-wrap justify-content-center mt-4 mb-0">
|
|
||||||
{% if data.has_previous %}
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="{% url 'roster_pagination' page=data.previous_page_number %}#main-content" tabindex="-1"><i class="bi bi-chevron-left"></i></a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link"><i class="bi bi-chevron-left"></i></span>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% for i in page_range %}
|
|
||||||
{% if data.number == i %}
|
|
||||||
<li class="page-item active">
|
|
||||||
<span class="page-link">{{ i }}</span>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
{% if i == data.paginator.ELLIPSIS %}
|
|
||||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item"><a class="page-link" href="{% url 'roster_pagination' page=i %}#main-content">{{ i }}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% if data.has_next %}
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="{% url 'roster_pagination' page=data.next_page_number %}#main-content" tabindex="-1"><i class="bi bi-chevron-right"></i></a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link"><i class="bi bi-chevron-right"></i></span>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
@@ -1,40 +0,0 @@
|
|||||||
{% extends "cards.html" %}
|
|
||||||
{% block pagination %}
|
|
||||||
{% if data.has_other_pages %}
|
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="pagination flex-wrap justify-content-center mt-4 mb-0">
|
|
||||||
{% if data.has_previous %}
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="{% url 'scales_pagination' page=data.previous_page_number %}#main-content" tabindex="-1"><i class="bi bi-chevron-left"></i></a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link"><i class="bi bi-chevron-left"></i></span>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% for i in page_range %}
|
|
||||||
{% if data.number == i %}
|
|
||||||
<li class="page-item active">
|
|
||||||
<span class="page-link">{{ i }}</span>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
{% if i == data.paginator.ELLIPSIS %}
|
|
||||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item"><a class="page-link" href="{% url 'scales_pagination' page=i %}#main-content">{{ i }}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% if data.has_next %}
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="{% url 'scales_pagination' page=data.next_page_number %}#main-content" tabindex="-1"><i class="bi bi-chevron-right"></i></a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link"><i class="bi bi-chevron-right"></i></span>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
@@ -1,40 +0,0 @@
|
|||||||
{% extends "cards.html" %}
|
|
||||||
{% block pagination %}
|
|
||||||
{% if data.has_other_pages %}
|
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="pagination flex-wrap justify-content-center mt-4 mb-0">
|
|
||||||
{% if data.has_previous %}
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="{% url 'types_pagination' page=data.previous_page_number %}#main-content" tabindex="-1"><i class="bi bi-chevron-left"></i></a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link"><i class="bi bi-chevron-left"></i></span>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% for i in page_range %}
|
|
||||||
{% if data.number == i %}
|
|
||||||
<li class="page-item active">
|
|
||||||
<span class="page-link">{{ i }}</span>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
{% if i == data.paginator.ELLIPSIS %}
|
|
||||||
<li class="page-item"><span class="page-link">{{ i }}</span></li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item"><a class="page-link" href="{% url 'types_pagination' page=i %}#main-content">{{ i }}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% if data.has_next %}
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="{% url 'types_pagination' page=data.next_page_number %}#main-content" tabindex="-1"><i class="bi bi-chevron-right"></i></a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link"><i class="bi bi-chevron-right"></i></span>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
@@ -15,5 +15,7 @@ def dynamic_admin_url(app_name, model_name, object_id=None):
|
|||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def dynamic_pagination(model_name, page):
|
def dynamic_pagination(reverse_name, page):
|
||||||
return reverse(f'{model_name}s_pagination', args=[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])
|
||||||
|
@@ -25,7 +25,7 @@ urlpatterns = [
|
|||||||
path(
|
path(
|
||||||
"roster/page/<int:page>",
|
"roster/page/<int:page>",
|
||||||
GetRoster.as_view(),
|
GetRoster.as_view(),
|
||||||
name="roster_pagination"
|
name="rosters_pagination"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"page/<str:flatpage>",
|
"page/<str:flatpage>",
|
||||||
@@ -34,12 +34,12 @@ urlpatterns = [
|
|||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"consists",
|
"consists",
|
||||||
Consists.as_view(template="consists.html"),
|
Consists.as_view(),
|
||||||
name="consists"
|
name="consists"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"consists/page/<int:page>",
|
"consists/page/<int:page>",
|
||||||
Consists.as_view(template="consists.html"),
|
Consists.as_view(),
|
||||||
name="consists_pagination"
|
name="consists_pagination"
|
||||||
),
|
),
|
||||||
path("consist/<uuid:uuid>", GetConsist.as_view(), name="consist"),
|
path("consist/<uuid:uuid>", GetConsist.as_view(), name="consist"),
|
||||||
@@ -50,52 +50,52 @@ urlpatterns = [
|
|||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"companies",
|
"companies",
|
||||||
Companies.as_view(template="companies.html"),
|
Companies.as_view(),
|
||||||
name="companies"
|
name="companies"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"companies/page/<int:page>",
|
"companies/page/<int:page>",
|
||||||
Companies.as_view(template="companies.html"),
|
Companies.as_view(),
|
||||||
name="companies_pagination",
|
name="companies_pagination",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"manufacturers/<str:category>",
|
"manufacturers/<str:category>",
|
||||||
Manufacturers.as_view(template="manufacturers.html"),
|
Manufacturers.as_view(template="pagination_manufacturers.html"),
|
||||||
name="manufacturers"
|
name="manufacturers"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"manufacturers/<str:category>/page/<int:page>",
|
"manufacturers/<str:category>/page/<int:page>",
|
||||||
Manufacturers.as_view(template="manufacturers.html"),
|
Manufacturers.as_view(template="pagination_manufacturers.html"),
|
||||||
name="manufacturers_pagination",
|
name="manufacturers_pagination",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"scales",
|
"scales",
|
||||||
Scales.as_view(template="scales.html"),
|
Scales.as_view(),
|
||||||
name="scales"
|
name="scales"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"scales/page/<int:page>",
|
"scales/page/<int:page>",
|
||||||
Scales.as_view(template="scales.html"),
|
Scales.as_view(),
|
||||||
name="scales_pagination"
|
name="scales_pagination"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"types",
|
"types",
|
||||||
Types.as_view(template="types.html"),
|
Types.as_view(),
|
||||||
name="types"
|
name="rolling_stock_types"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"types/page/<int:page>",
|
"types/page/<int:page>",
|
||||||
Types.as_view(template="types.html"),
|
Types.as_view(),
|
||||||
name="types_pagination"
|
name="rolling_stock_types_pagination"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"bookshelf/books",
|
"bookshelf/books",
|
||||||
Books.as_view(template="bookshelf/books.html"),
|
Books.as_view(),
|
||||||
name="books"
|
name="books"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"bookshelf/books/page/<int:page>",
|
"bookshelf/books/page/<int:page>",
|
||||||
Books.as_view(template="bookshelf/books.html"),
|
Books.as_view(),
|
||||||
name="books_pagination"
|
name="books_pagination"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
@@ -105,12 +105,12 @@ urlpatterns = [
|
|||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"bookshelf/catalogs",
|
"bookshelf/catalogs",
|
||||||
Catalogs.as_view(template="bookshelf/books.html"),
|
Catalogs.as_view(),
|
||||||
name="catalogs"
|
name="catalogs"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"bookshelf/catalogs/page/<int:page>",
|
"bookshelf/catalogs/page/<int:page>",
|
||||||
Catalogs.as_view(template="bookshelf/books.html"),
|
Catalogs.as_view(),
|
||||||
name="catalogs_pagination"
|
name="catalogs_pagination"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
|
@@ -62,8 +62,8 @@ class Render404(View):
|
|||||||
|
|
||||||
class GetData(View):
|
class GetData(View):
|
||||||
title = "Home"
|
title = "Home"
|
||||||
template = "roster.html"
|
template = "pagination.html"
|
||||||
item_type = "rolling_stock"
|
item_type = "roster"
|
||||||
filter = Q() # empty filter by default
|
filter = Q() # empty filter by default
|
||||||
|
|
||||||
def get_data(self, request):
|
def get_data(self, request):
|
||||||
@@ -78,8 +78,7 @@ class GetData(View):
|
|||||||
for item in self.get_data(request):
|
for item in self.get_data(request):
|
||||||
data.append({"type": self.item_type, "item": item})
|
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)
|
data = paginator.get_page(page)
|
||||||
page_range = paginator.get_elided_page_range(
|
page_range = paginator.get_elided_page_range(
|
||||||
data.number, on_each_side=1, on_ends=1
|
data.number, on_each_side=1, on_ends=1
|
||||||
@@ -99,8 +98,8 @@ class GetData(View):
|
|||||||
|
|
||||||
|
|
||||||
class GetRoster(GetData):
|
class GetRoster(GetData):
|
||||||
title = "Roster"
|
title = "The Roster"
|
||||||
item_type = "rolling_stock"
|
item_type = "roster"
|
||||||
|
|
||||||
def get_data(self, request):
|
def get_data(self, request):
|
||||||
return RollingStock.objects.get_published(request.user).order_by(
|
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
|
# FIXME see if it makes sense to filter calatogs and books by scale
|
||||||
# and manufacturer as well
|
# and manufacturer as well
|
||||||
data = []
|
data = []
|
||||||
rolling_stock = (
|
roster = (
|
||||||
RollingStock.objects.get_published(request.user)
|
RollingStock.objects.get_published(request.user)
|
||||||
.filter(query)
|
.filter(query)
|
||||||
.distinct()
|
.distinct()
|
||||||
.order_by(*get_order_by_field())
|
.order_by(*get_order_by_field())
|
||||||
)
|
)
|
||||||
for item in rolling_stock:
|
for item in roster:
|
||||||
data.append({"type": "rolling_stock", "item": item})
|
data.append({"type": "roster", "item": item})
|
||||||
|
|
||||||
if _filter is None:
|
if _filter is None:
|
||||||
consists = (
|
consists = (
|
||||||
@@ -247,7 +246,7 @@ class GetManufacturerItem(View):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if search != "all":
|
if search != "all":
|
||||||
rolling_stock = get_list_or_404(
|
roster = get_list_or_404(
|
||||||
RollingStock.objects.get_published(request.user).order_by(
|
RollingStock.objects.get_published(request.user).order_by(
|
||||||
*get_order_by_field()
|
*get_order_by_field()
|
||||||
),
|
),
|
||||||
@@ -260,10 +259,10 @@ class GetManufacturerItem(View):
|
|||||||
manufacturer,
|
manufacturer,
|
||||||
# all returned records must have the same `item_number``;
|
# all returned records must have the same `item_number``;
|
||||||
# just pick it up the first result, otherwise `search`
|
# 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:
|
else:
|
||||||
rolling_stock = (
|
roster = (
|
||||||
RollingStock.objects.get_published(request.user)
|
RollingStock.objects.get_published(request.user)
|
||||||
.order_by(*get_order_by_field())
|
.order_by(*get_order_by_field())
|
||||||
.filter(
|
.filter(
|
||||||
@@ -274,8 +273,8 @@ class GetManufacturerItem(View):
|
|||||||
title = "Manufacturer: {0}".format(manufacturer)
|
title = "Manufacturer: {0}".format(manufacturer)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
for item in rolling_stock:
|
for item in roster:
|
||||||
data.append({"type": "rolling_stock", "item": item})
|
data.append({"type": "roster", "item": item})
|
||||||
|
|
||||||
paginator = Paginator(data, get_items_per_page())
|
paginator = Paginator(data, get_items_per_page())
|
||||||
data = paginator.get_page(page)
|
data = paginator.get_page(page)
|
||||||
@@ -318,7 +317,7 @@ class GetObjectsFiltered(View):
|
|||||||
else:
|
else:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
rolling_stock = (
|
roster = (
|
||||||
RollingStock.objects.get_published(request.user)
|
RollingStock.objects.get_published(request.user)
|
||||||
.filter(query)
|
.filter(query)
|
||||||
.distinct()
|
.distinct()
|
||||||
@@ -326,8 +325,8 @@ class GetObjectsFiltered(View):
|
|||||||
)
|
)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
for item in rolling_stock:
|
for item in roster:
|
||||||
data.append({"type": "rolling_stock", "item": item})
|
data.append({"type": "roster", "item": item})
|
||||||
|
|
||||||
try: # Execute only if query_2nd is defined
|
try: # Execute only if query_2nd is defined
|
||||||
consists = (
|
consists = (
|
||||||
@@ -452,7 +451,7 @@ class GetConsist(View):
|
|||||||
raise Http404
|
raise Http404
|
||||||
data = [
|
data = [
|
||||||
{
|
{
|
||||||
"type": "rolling_stock",
|
"type": "roster",
|
||||||
"item": RollingStock.objects.get_published(request.user).get(
|
"item": RollingStock.objects.get_published(request.user).get(
|
||||||
uuid=r.rolling_stock_id
|
uuid=r.rolling_stock_id
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user