From 676418cb671a4b3aa323ee9379484d51a0da470a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Wed, 24 Dec 2025 15:38:07 +0100 Subject: [PATCH] Code refactoring to simplify template data contexts (#55) * Fix a search filter when no catalogs are returned * Code refactoring to simplify templates * Remove duplicated code * Remove dead code * More improvements, clean up and add featured items in homepage * Fix a type and better page navigation --- ram/bookshelf/admin.py | 29 +-- ram/bookshelf/models.py | 4 + ram/consist/admin.py | 15 +- ram/metadata/admin.py | 16 +- ram/metadata/models.py | 17 +- ram/portal/templates/bookshelf/book.html | 68 +++--- ram/portal/templates/cards.html | 16 +- ram/portal/templates/cards/book.html | 38 ++-- ram/portal/templates/cards/company.html | 20 +- ram/portal/templates/cards/consist.html | 36 ++-- ram/portal/templates/cards/magazine.html | 64 +++--- ram/portal/templates/cards/manufacturer.html | 16 +- .../templates/cards/rolling_stock_type.html | 12 +- ram/portal/templates/cards/roster.html | 42 ++-- ram/portal/templates/cards/scale.html | 16 +- ram/portal/templates/consist.html | 6 +- ram/portal/templates/filter.html | 6 +- ram/portal/templates/home.html | 15 ++ ram/portal/templates/manufacturer.html | 6 +- ram/portal/templates/pagination.html | 6 +- .../templates/pagination_manufacturers.html | 8 +- ram/portal/templates/search.html | 6 +- ram/portal/templatetags/dynamic_url.py | 7 - ram/portal/templatetags/shuffle.py | 11 + ram/portal/urls.py | 102 +++------ ram/portal/views.py | 197 +++++++----------- ram/ram/__init__.py | 2 +- ram/ram/models.py | 21 ++ ram/ram/settings.py | 2 + ram/roster/admin.py | 50 ++++- .../migrations/0039_rollingstock_featured.py | 21 ++ ram/roster/models.py | 24 ++- 32 files changed, 466 insertions(+), 433 deletions(-) create mode 100644 ram/portal/templatetags/shuffle.py create mode 100644 ram/roster/migrations/0039_rollingstock_featured.py diff --git a/ram/bookshelf/admin.py b/ram/bookshelf/admin.py index 1c18986..2cb980d 100644 --- a/ram/bookshelf/admin.py +++ b/ram/bookshelf/admin.py @@ -11,7 +11,7 @@ from portal.utils import get_site_conf from repository.models import ( BookDocument, CatalogDocument, - MagazineIssueDocument + MagazineIssueDocument, ) from bookshelf.models import ( BaseBookProperty, @@ -66,12 +66,12 @@ class BookAdmin(SortableAdminBase, admin.ModelAdmin): BookDocInline, ) list_display = ( + "published", "title", "get_authors", "get_publisher", "publication_year", "number_of_pages", - "published", ) autocomplete_fields = ("authors", "publisher", "shop") readonly_fields = ("invoices", "creation_time", "updated_time") @@ -135,8 +135,8 @@ class BookAdmin(SortableAdminBase, admin.ModelAdmin): if obj.invoice.exists(): html = format_html_join( "
", - "{}", - ((i.file.url, i) for i in obj.invoice.all()) + '{}', + ((i.file.url, i) for i in obj.invoice.all()), ) else: html = "-" @@ -212,11 +212,11 @@ class AuthorAdmin(admin.ModelAdmin): @admin.register(Publisher) class PublisherAdmin(admin.ModelAdmin): - list_display = ("name", "country_flag") + list_display = ("name", "country_flag_name") search_fields = ("name",) @admin.display(description="Country") - def country_flag(self, obj): + def country_flag_name(self, obj): return format_html( ' {}', obj.country.flag, obj.country.name ) @@ -240,10 +240,10 @@ class CatalogAdmin(SortableAdminBase, admin.ModelAdmin): readonly_fields = ("invoices", "creation_time", "updated_time") search_fields = ("manufacturer__name", "years", "scales__scale") list_filter = ( + "published", "manufacturer__name", "publication_year", "scales__scale", - "published", ) fieldsets = ( @@ -303,8 +303,8 @@ class CatalogAdmin(SortableAdminBase, admin.ModelAdmin): if obj.invoice.exists(): html = format_html_join( "
", - "{}", - ((i.file.url, i) for i in obj.invoice.all()) + '{}', + ((i.file.url, i) for i in obj.invoice.all()), ) else: html = "-" @@ -449,14 +449,12 @@ class MagazineIssueInline(admin.TabularInline): readonly_fields = ("preview",) class Media: - js = ('admin/js/magazine_issue_defaults.js',) + js = ("admin/js/magazine_issue_defaults.js",) @admin.register(Magazine) class MagazineAdmin(SortableAdminBase, admin.ModelAdmin): - inlines = ( - MagazineIssueInline, - ) + inlines = (MagazineIssueInline,) list_display = ( "__str__", @@ -466,7 +464,10 @@ class MagazineAdmin(SortableAdminBase, admin.ModelAdmin): autocomplete_fields = ("publisher",) readonly_fields = ("creation_time", "updated_time") search_fields = ("name", "publisher__name") - list_filter = ("publisher__name", "published") + list_filter = ( + "published", + "publisher__name", + ) fieldsets = ( ( diff --git a/ram/bookshelf/models.py b/ram/bookshelf/models.py index 0fb498f..46062c7 100644 --- a/ram/bookshelf/models.py +++ b/ram/bookshelf/models.py @@ -224,6 +224,10 @@ class MagazineIssue(BaseBook): "published." ) + @property + def obj_label(self): + return "Magazine Issue" + def preview(self): return self.image.first().image_thumbnail(100) diff --git a/ram/consist/admin.py b/ram/consist/admin.py index 135760a..1344952 100644 --- a/ram/consist/admin.py +++ b/ram/consist/admin.py @@ -2,6 +2,7 @@ import html from django.conf import settings from django.contrib import admin + # from django.forms import BaseInlineFormSet # for future reference from django.utils.html import format_html, strip_tags from adminsortable2.admin import ( @@ -46,15 +47,22 @@ class ConsistAdmin(SortableAdminBase, admin.ModelAdmin): "creation_time", "updated_time", ) - list_filter = ("company__name", "era", "scale", "published") - list_display = ("__str__",) + list_filter + ("country_flag",) + list_filter = ("published", "company__name", "era", "scale") + list_display = ( + "__str__", + "company__name", + "era", + "scale", + "country_flag", + "published", + ) search_fields = ("identifier",) + list_filter save_as = True @admin.display(description="Country") def country_flag(self, obj): return format_html( - ' {}', obj.country.flag, obj.country + '', obj.country.flag, obj.country.name ) fieldsets = ( @@ -138,6 +146,7 @@ class ConsistAdmin(SortableAdminBase, admin.ModelAdmin): ) return generate_csv(header, data, "consists.csv") + download_csv.short_description = "Download selected items as CSV" actions = [publish, unpublish, download_csv] diff --git a/ram/metadata/admin.py b/ram/metadata/admin.py index d3f30b5..ec91a0a 100644 --- a/ram/metadata/admin.py +++ b/ram/metadata/admin.py @@ -47,12 +47,12 @@ class ScaleAdmin(admin.ModelAdmin): @admin.register(Company) class CompanyAdmin(admin.ModelAdmin): readonly_fields = ("logo_thumbnail",) - list_display = ("name", "country_flag") + list_display = ("name", "country_flag_name") list_filter = ("name", "country") search_fields = ("name",) @admin.display(description="Country") - def country_flag(self, obj): + def country_flag_name(self, obj): return format_html( ' {}', obj.country.flag, obj.country.name ) @@ -61,12 +61,12 @@ class CompanyAdmin(admin.ModelAdmin): @admin.register(Manufacturer) class ManufacturerAdmin(admin.ModelAdmin): readonly_fields = ("logo_thumbnail",) - list_display = ("name", "category", "country_flag") + list_display = ("name", "category", "country_flag_name") list_filter = ("category",) search_fields = ("name",) @admin.display(description="Country") - def country_flag(self, obj): + def country_flag_name(self, obj): return format_html( ' {}', obj.country.flag, obj.country.name ) @@ -88,6 +88,12 @@ class RollingStockTypeAdmin(SortableAdminMixin, admin.ModelAdmin): @admin.register(Shop) class ShopAdmin(admin.ModelAdmin): - list_display = ("name", "on_line", "active") + list_display = ("name", "on_line", "active", "country_flag_name") list_filter = ("on_line", "active") search_fields = ("name",) + + @admin.display(description="Country") + def country_flag_name(self, obj): + return format_html( + ' {}', obj.country.flag, obj.country.name + ) diff --git a/ram/metadata/models.py b/ram/metadata/models.py index a956738..4ef63b5 100644 --- a/ram/metadata/models.py +++ b/ram/metadata/models.py @@ -7,11 +7,12 @@ from django.dispatch.dispatcher import receiver from django.core.exceptions import ValidationError from django_countries.fields import CountryField +from ram.models import SimpleBaseModel from ram.utils import DeduplicatedStorage, get_image_preview, slugify from ram.managers import PublicManager -class Property(models.Model): +class Property(SimpleBaseModel): name = models.CharField(max_length=128, unique=True) private = models.BooleanField( default=False, @@ -28,7 +29,7 @@ class Property(models.Model): objects = PublicManager() -class Manufacturer(models.Model): +class Manufacturer(SimpleBaseModel): name = models.CharField(max_length=128, unique=True) slug = models.CharField(max_length=128, unique=True, editable=False) category = models.CharField( @@ -68,7 +69,7 @@ class Manufacturer(models.Model): logo_thumbnail.short_description = "Preview" -class Company(models.Model): +class Company(SimpleBaseModel): name = models.CharField(max_length=64, unique=True) slug = models.CharField(max_length=64, unique=True, editable=False) extended_name = models.CharField(max_length=128, blank=True) @@ -106,7 +107,7 @@ class Company(models.Model): logo_thumbnail.short_description = "Preview" -class Decoder(models.Model): +class Decoder(SimpleBaseModel): name = models.CharField(max_length=128, unique=True) manufacturer = models.ForeignKey( Manufacturer, @@ -142,7 +143,7 @@ def calculate_ratio(ratio): raise ValidationError("Invalid ratio format") -class Scale(models.Model): +class Scale(SimpleBaseModel): scale = models.CharField(max_length=32, unique=True) slug = models.CharField(max_length=32, unique=True, editable=False) ratio = models.CharField(max_length=16, validators=[calculate_ratio]) @@ -177,7 +178,7 @@ def scale_save(sender, instance, **kwargs): instance.ratio_int = calculate_ratio(instance.ratio) -class RollingStockType(models.Model): +class RollingStockType(SimpleBaseModel): type = models.CharField(max_length=64) order = models.PositiveSmallIntegerField() category = models.CharField( @@ -207,7 +208,7 @@ class RollingStockType(models.Model): return "{0} {1}".format(self.type, self.category) -class Tag(models.Model): +class Tag(SimpleBaseModel): name = models.CharField(max_length=128, unique=True) slug = models.CharField(max_length=128, unique=True) @@ -227,7 +228,7 @@ class Tag(models.Model): ) -class Shop(models.Model): +class Shop(SimpleBaseModel): name = models.CharField(max_length=128, unique=True) country = CountryField(blank=True) website = models.URLField(blank=True) diff --git a/ram/portal/templates/bookshelf/book.html b/ram/portal/templates/bookshelf/book.html index 2a3159d..ea1eb3a 100644 --- a/ram/portal/templates/bookshelf/book.html +++ b/ram/portal/templates/bookshelf/book.html @@ -2,23 +2,23 @@ {% load dynamic_url %} {% block header %} - {% if book.tags.all %} + {% if data.tags.all %}

Tags: - {% for t in book.tags.all %} + {% for t in data.tags.all %} {{ t.name }}{# new line is required #} {% endfor %}

{% endif %} - {% if not book.published %} + {% if not data.published %} Unpublished | {% endif %} - Updated {{ book.updated_time | date:"M d, Y H:i" }} + Updated {{ data.updated_time | date:"M d, Y H:i" }} {% endblock %} {% block carousel %}
- {% if request.user.is_staff %}Edit{% endif %} + {% if request.user.is_staff %}Edit{% endif %}
diff --git a/ram/portal/templates/cards.html b/ram/portal/templates/cards.html index fc64027..c634884 100644 --- a/ram/portal/templates/cards.html +++ b/ram/portal/templates/cards.html @@ -6,21 +6,21 @@
{% block cards %} {% for d in data %} - {% if d.type == "roster" %} + {% if d.obj_type == "rollingstock" %} {% include "cards/roster.html" %} - {% elif d.type == "company" %} + {% elif d.obj_type == "company" %} {% include "cards/company.html" %} - {% elif d.type == "rolling_stock_type" %} + {% elif d.obj_type == "rollingstocktype" %} {% include "cards/rolling_stock_type.html" %} - {% elif d.type == "scale" %} + {% elif d.obj_type == "scale" %} {% include "cards/scale.html" %} - {% elif d.type == "consist" %} + {% elif d.obj_type == "consist" %} {% include "cards/consist.html" %} - {% elif d.type == "manufacturer" %} + {% elif d.obj_type == "manufacturer" %} {% include "cards/manufacturer.html" %} - {% elif d.type == "magazine" or d.type == "magazineissue" %} + {% elif d.obj_type == "magazine" or d.obj_type == "magazineissue" %} {% include "cards/magazine.html" %} - {% elif d.type == "book" or d.type == "catalog" %} + {% elif d.obj_type == "book" or d.obj_type == "catalog" %} {% include "cards/book.html" %} {% endif %} {% endfor %} diff --git a/ram/portal/templates/cards/book.html b/ram/portal/templates/cards/book.html index 1421c61..035bc0f 100644 --- a/ram/portal/templates/cards/book.html +++ b/ram/portal/templates/cards/book.html @@ -2,19 +2,19 @@ {% load dynamic_url %}
- {% if d.item.image.exists %} - {{ d.item }} + {% if d.image.exists %} + {{ d }} {% else %} - {{ d.item }} + {{ d }} {% endif %}

- {{ d.item }} - + {{ d }} +

Tags: - {% for t in d.item.tags.all %} + {% for t in d.tags.all %} {{ t.name }}{# new line is required #} {% empty %} @@ -24,9 +24,9 @@ - {{ d.label|capfirst }} + {{ d.obj_label|capfirst }}

- {% if not d.item.published %} + {% if not d.published %} Unpublished {% endif %}
@@ -34,46 +34,46 @@ - {% if d.type == "catalog" %} + {% if d.obj_type == "catalog" %} Manufacturer - {{ d.item.manufacturer }}{% if d.item.manufacturer.website %} {% endif %} + {{ d.manufacturer }}{% if d.manufacturer.website %} {% endif %} Scales - {{ d.item.get_scales }} + {{ d.get_scales }} - {% elif d.type == "book" %} + {% elif d.obj_type == "book" %} Authors -
    {% for a in d.item.authors.all %}
  • {{ a }}
  • {% endfor %}
+
    {% for a in d.authors.all %}
  • {{ a }}
  • {% endfor %}
Publisher - {{ d.item.publisher.country }} {{ d.item.publisher }} + {{ d.publisher.country }} {{ d.publisher }} {% endif %} Language - {{ d.item.get_language_display }} + {{ d.get_language_display }} Pages - {{ d.item.number_of_pages|default:"-" }} + {{ d.number_of_pages|default:"-" }} Year - {{ d.item.publication_year|default:"-" }} + {{ d.publication_year|default:"-" }}
- Show all data - {% if request.user.is_staff %}Edit{% endif %} + Show all data + {% if request.user.is_staff %}Edit{% endif %}
diff --git a/ram/portal/templates/cards/company.html b/ram/portal/templates/cards/company.html index fc0b5af..46f73ea 100644 --- a/ram/portal/templates/cards/company.html +++ b/ram/portal/templates/cards/company.html @@ -2,7 +2,7 @@

- {{ d.item.name }} + {{ d.name }}

@@ -10,7 +10,7 @@ - {% if d.item.logo %} + {% if d.logo %} - + {% endif %} - + - + - +
Company
- {% if d.item.freelance %} + {% if d.freelance %} Freelance {% endif %}
@@ -18,30 +18,30 @@
Logo
Name{{ d.item.extended_name }}{{ d.extended_name }}
Abbreviation{{ d.item.name }}{{ d.name }}
Country{{ d.item.country }} {{ d.item.country.name }}{{ d.country }} {{ d.country.name }}
- {% with items=d.item.num_items %} - Show {{ items }} item{{ items | pluralize}} - {% if request.user.is_staff %}Edit{% endif %} + {% with items=d.num_items %} + Show {{ items }} item{{ items | pluralize}} + {% if request.user.is_staff %}Edit{% endif %} {% endwith %}
diff --git a/ram/portal/templates/cards/consist.html b/ram/portal/templates/cards/consist.html index 1fc8ce6..4c5b46e 100644 --- a/ram/portal/templates/cards/consist.html +++ b/ram/portal/templates/cards/consist.html @@ -1,21 +1,21 @@
- - {% if d.item.image %} - {{ d.item }} + + {% if d.image %} + {{ d }} {% else %} - {% with d.item.consist_item.first.rolling_stock as r %} - {{ d.item }} + {% with d.consist_item.first.rolling_stock as r %} + {{ d }} {% endwith %} {% endif %}

- {{ d.item }} - + {{ d }} +

Tags: - {% for t in d.item.tags.all %} + {% for t in d.tags.all %} {{ t.name }}{# new line is required #} {% empty %} @@ -27,10 +27,10 @@ Consist

- {% if not d.item.published %} + {% if not d.published %} Unpublished {% endif %} - {% if d.item.company.freelance %} + {% if d.company.freelance %} Freelance {% endif %}
@@ -38,32 +38,32 @@ - {% if d.item.address %} + {% if d.address %} Address - {{ d.item.address }} + {{ d.address }} {% endif %} Company - {{ d.item.company.country }} - {{ d.item.company }} + {{ d.company.country }} + {{ d.company }} Era - {{ d.item.era }} + {{ d.era }} Length - {{ d.item.length }} + {{ d.length }}
- Show all data - {% if request.user.is_staff %}Edit{% endif %} + Show all data + {% if request.user.is_staff %}Edit{% endif %}
diff --git a/ram/portal/templates/cards/magazine.html b/ram/portal/templates/cards/magazine.html index 25832b5..3b508b3 100644 --- a/ram/portal/templates/cards/magazine.html +++ b/ram/portal/templates/cards/magazine.html @@ -2,37 +2,37 @@ {% load dynamic_url %}
- {% if d.type == "magazine" %} - - {% if d.item.image and d.type == "magazine" %} - {{ d.item }} - {% elif d.item.issue.first.image.exists %} - {% with d.item.issue.first as i %} - {{ d.item }} + {% if d.obj_type == "magazine" %} + + {% if d.image and d.obj_type == "magazine" %} + {{ d }} + {% elif d.issue.first.image.exists %} + {% with d.issue.first as i %} + {{ d }} {% endwith %} {% else %} - {{ d.item }} + {{ d }} {% endif %} - {% elif d.type == "magazineissue" %} - - {% if d.item.image.exists %} - {{ d.item }} + {% elif d.obj_type == "magazineissue" %} + + {% if d.image.exists %} + {{ d }} {% else %} - {{ d.item }} + {{ d }} {% endif %} {% endif %}

- {{ d.item }} - + {{ d }} +

Tags: - {% for t in d.item.tags.all %} + {% for t in d.tags.all %} {{ t.name }}{# new line is required #} {% empty %} @@ -42,10 +42,10 @@ - {{ d.label|capfirst }} + {{ d.obj_label|capfirst }}

- {% if not d.item.published %} + {% if not d.published %} Unpublished {% endif %}
@@ -53,51 +53,51 @@ - {% if d.type == "magazineissue" %} + {% if d.obj_type == "magazineissue" %} Magazine - {{ d.item.magazine }} + {{ d.magazine }} {% else %} Website - {% if d.item.website %}{{ d.item.website_short }}{% else %}-{% endif %} + {% if d.website %}{{ d.website_short }}{% else %}-{% endif %} {% endif %} Publisher - {{ d.item.publisher.country }} {{ d.item.publisher }} - {% if d.item.publisher.website %} {% endif %} + {{ d.publisher.country }} {{ d.publisher }} + {% if d.publisher.website %} {% endif %} - {% if d.type == "magazineissue" %} + {% if d.obj_type == "magazineissue" %} Issue - {{ d.item.issue_number }} + {{ d.issue_number }} Date - {{ d.item.publication_year|default:"-" }} / {{ d.item.get_publication_month_display|default:"-" }} + {{ d.publication_year|default:"-" }} / {{ d.get_publication_month_display|default:"-" }} Pages - {{ d.item.number_of_pages|default:"-" }} + {{ d.number_of_pages|default:"-" }} {% endif %} Language - {{ d.item.get_language_display }} + {{ d.get_language_display }}
- {% if d.type == "magazine" %} - Show {{ d.item.issues }} issue{{ d.item.issues|pluralize }} + {% if d.obj_type == "magazine" %} + Show {{ d.issues }} issue{{ d.issues|pluralize }} {% else %} - Show all data + Show all data {% endif %} - {% if request.user.is_staff %}Edit{% endif %} + {% if request.user.is_staff %}Edit{% endif %}
diff --git a/ram/portal/templates/cards/manufacturer.html b/ram/portal/templates/cards/manufacturer.html index 8c84397..576294f 100644 --- a/ram/portal/templates/cards/manufacturer.html +++ b/ram/portal/templates/cards/manufacturer.html @@ -2,7 +2,7 @@

- {{ d.item.name }} + {{ d.name }}

@@ -11,26 +11,26 @@ - {% if d.item.logo %} + {% if d.logo %} - + {% endif %} - {% else %}-{% endif %} + {% else %}-{% endif %} - +
Logo
Website{% if d.item.website %}{{ d.item.website_short }}{% if d.website %}{{ d.website_short }}
Category{{ d.item.category | title }}{{ d.category | title }}
- {% with items=d.item.num_items %} - Show {{ items }} item{{ items|pluralize }} - {% if request.user.is_staff %}Edit{% endif %} + {% with items=d.num_items %} + Show {{ items }} item{{ items|pluralize }} + {% if request.user.is_staff %}Edit{% endif %} {% endwith %}
diff --git a/ram/portal/templates/cards/rolling_stock_type.html b/ram/portal/templates/cards/rolling_stock_type.html index 30665c9..abb88c8 100644 --- a/ram/portal/templates/cards/rolling_stock_type.html +++ b/ram/portal/templates/cards/rolling_stock_type.html @@ -1,7 +1,7 @@
-

{{ d.item }}

+

{{ d }}

@@ -11,18 +11,18 @@ - + - +
Type{{ d.item.type }}{{ d.type }}
Category{{ d.item.category | title}}{{ d.category | title}}
- {% with items=d.item.num_items %} - Show {{ items }} item{{ items | pluralize}} - {% if request.user.is_staff %}Edit{% endif %} + {% with items=d.num_items %} + Show {{ items }} item{{ items | pluralize}} + {% if request.user.is_staff %}Edit{% endif %} {% endwith %}
diff --git a/ram/portal/templates/cards/roster.html b/ram/portal/templates/cards/roster.html index 0d79921..0f805b8 100644 --- a/ram/portal/templates/cards/roster.html +++ b/ram/portal/templates/cards/roster.html @@ -3,19 +3,19 @@
- {% if d.item.image.exists %} - {{ d.item }} + {% if d.image.exists %} + {{ d }} {% else %} - {{ d.item }} + {{ d }} {% endif %}

- {{ d.item }} - + {{ d }} +

Tags: - {% for t in d.item.tags.all %} + {% for t in d.tags.all %} {{ t.name }}{# new line is required #} {% empty %} @@ -27,10 +27,10 @@ Rolling stock

- {% if not d.item.published %} + {% if not d.published %} Unpublished {% endif %} - {% if d.item.company.freelance %} + {% if d.company.freelance %} Freelance {% endif %}
@@ -40,50 +40,50 @@ Type - {{ d.item.rolling_class.type }} + {{ d.rolling_class.type }} Company - {{ d.item.company.country }} - {{ d.item.company }} + {{ d.company.country }} + {{ d.company }} Class - {{ d.item.rolling_class.identifier }} + {{ d.rolling_class.identifier }} Road number - {{ d.item.road_number }} + {{ d.road_number }} Era - {{ d.item.era }} + {{ d.era }} Manufacturer - {%if d.item.manufacturer %} - {{ d.item.manufacturer }}{% if d.item.manufacturer.website %} {% endif %} + {%if d.manufacturer %} + {{ d.manufacturer }}{% if d.manufacturer.website %} {% endif %} {% endif %} Scale - {{ d.item.scale }} + {{ d.scale }} Item number - {{ d.item.item_number }}{%if d.item.set %} | SET{% endif %} + {{ d.item_number }}{%if d.set %} | SET{% endif %} DCC - {% dcc d.item %} + {% dcc d %}
- Show all data - {% if request.user.is_staff %}Edit{% endif %} + Show all data + {% if request.user.is_staff %}Edit{% endif %}
diff --git a/ram/portal/templates/cards/scale.html b/ram/portal/templates/cards/scale.html index 4c1118a..1b4d6e3 100644 --- a/ram/portal/templates/cards/scale.html +++ b/ram/portal/templates/cards/scale.html @@ -1,7 +1,7 @@
-

{{ d.item }}

+

{{ d }}

@@ -11,26 +11,26 @@ - + - + - + - +
Name{{ d.item.scale }}{{ d.scale }}
Ratio{{ d.item.ratio }}{{ d.ratio }}
Tracks{{ d.item.tracks }} mm{{ d.tracks }} mm
Gauge{{ d.item.gauge }}{{ d.gauge }}
- {% with items=d.item.num_items %} - Show {{ items }} item{{ items | pluralize}} - {% if request.user.is_staff %}Edit{% endif %} + {% with items=d.num_items %} + Show {{ items }} item{{ items | pluralize}} + {% if request.user.is_staff %}Edit{% endif %} {% endwith %}
diff --git a/ram/portal/templates/consist.html b/ram/portal/templates/consist.html index 587a5ba..53041c2 100644 --- a/ram/portal/templates/consist.html +++ b/ram/portal/templates/consist.html @@ -32,7 +32,7 @@
    {% if data.has_previous %}
  • - +
  • {% else %}
  • @@ -48,13 +48,13 @@ {% if i == data.paginator.ELLIPSIS %}
  • {{ i }}
  • {% else %} -
  • {{ i }}
  • +
  • {{ i }}
  • {% endif %} {% endif %} {% endfor %} {% if data.has_next %}
  • - +
  • {% else %}
  • diff --git a/ram/portal/templates/filter.html b/ram/portal/templates/filter.html index 36cda7d..85b976c 100644 --- a/ram/portal/templates/filter.html +++ b/ram/portal/templates/filter.html @@ -5,7 +5,7 @@
      {% if data.has_previous %}
    • - +
    • {% else %}
    • @@ -21,13 +21,13 @@ {% if i == data.paginator.ELLIPSIS %}
    • {{ i }}
    • {% else %} -
    • {{ i }}
    • +
    • {{ i }}
    • {% endif %} {% endif %} {% endfor %} {% if data.has_next %}
    • - +
    • {% else %}
    • diff --git a/ram/portal/templates/home.html b/ram/portal/templates/home.html index cba2ba2..83d013c 100644 --- a/ram/portal/templates/home.html +++ b/ram/portal/templates/home.html @@ -3,3 +3,18 @@ {% block header %}
      {{ site_conf.about | safe }}
      {% endblock %} + {% block cards %} + {% for d in data %} + {% include "cards/roster.html" %} + {% endfor %} + {% endblock %} + + {% block pagination %} + + {% endblock %} diff --git a/ram/portal/templates/manufacturer.html b/ram/portal/templates/manufacturer.html index 0aaa2f6..33dd5af 100644 --- a/ram/portal/templates/manufacturer.html +++ b/ram/portal/templates/manufacturer.html @@ -5,7 +5,7 @@
        {% if data.has_previous %}
      • - +
      • {% else %}
      • @@ -21,13 +21,13 @@ {% if i == data.paginator.ELLIPSIS %}
      • {{ i }}
      • {% else %} -
      • {{ i }}
      • +
      • {{ i }}
      • {% endif %} {% endif %} {% endfor %} {% if data.has_next %}
      • - +
      • {% else %}
      • diff --git a/ram/portal/templates/pagination.html b/ram/portal/templates/pagination.html index a690a77..b198243 100644 --- a/ram/portal/templates/pagination.html +++ b/ram/portal/templates/pagination.html @@ -7,7 +7,7 @@
          {% if data.has_previous %}
        • - +
        • {% else %}
        • @@ -23,13 +23,13 @@ {% if i == data.paginator.ELLIPSIS %}
        • {{ i }}
        • {% else %} -
        • {{ i }}
        • +
        • {{ i }}
        • {% endif %} {% endif %} {% endfor %} {% if data.has_next %}
        • - +
        • {% else %}
        • diff --git a/ram/portal/templates/pagination_manufacturers.html b/ram/portal/templates/pagination_manufacturers.html index 1b3cea2..6829ba8 100644 --- a/ram/portal/templates/pagination_manufacturers.html +++ b/ram/portal/templates/pagination_manufacturers.html @@ -1,12 +1,12 @@ {% extends "cards.html" %} {% block pagination %} {% if data.has_other_pages %} - {% with data.0.item.category as c %} + {% with data.0.category as c %}