From c95064ddec03488885c2f1b62682dd1df4b82e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Fri, 2 Jan 2026 23:19:18 +0100 Subject: [PATCH] More templates modularization --- .../{includes => _includes}/documents.html | 0 .../{includes => _includes}/footer.html | 0 .../{includes => _includes}/header.html | 0 .../{includes => _includes}/login.html | 0 .../{includes => _includes}/search.html | 0 .../{includes => _includes}/symbols.html | 0 ram/portal/templates/_modules/documents.html | 26 +++++++ ram/portal/templates/_modules/properties.html | 18 +++++ .../templates/_modules/purchase_data.html | 29 ++++++++ ram/portal/templates/base.html | 8 +-- ram/portal/templates/bookshelf/book.html | 47 +------------ ram/portal/templates/rollingstock.html | 67 ++----------------- 12 files changed, 85 insertions(+), 110 deletions(-) rename ram/portal/templates/{includes => _includes}/documents.html (100%) rename ram/portal/templates/{includes => _includes}/footer.html (100%) rename ram/portal/templates/{includes => _includes}/header.html (100%) rename ram/portal/templates/{includes => _includes}/login.html (100%) rename ram/portal/templates/{includes => _includes}/search.html (100%) rename ram/portal/templates/{includes => _includes}/symbols.html (100%) create mode 100644 ram/portal/templates/_modules/documents.html create mode 100644 ram/portal/templates/_modules/properties.html create mode 100644 ram/portal/templates/_modules/purchase_data.html diff --git a/ram/portal/templates/includes/documents.html b/ram/portal/templates/_includes/documents.html similarity index 100% rename from ram/portal/templates/includes/documents.html rename to ram/portal/templates/_includes/documents.html diff --git a/ram/portal/templates/includes/footer.html b/ram/portal/templates/_includes/footer.html similarity index 100% rename from ram/portal/templates/includes/footer.html rename to ram/portal/templates/_includes/footer.html diff --git a/ram/portal/templates/includes/header.html b/ram/portal/templates/_includes/header.html similarity index 100% rename from ram/portal/templates/includes/header.html rename to ram/portal/templates/_includes/header.html diff --git a/ram/portal/templates/includes/login.html b/ram/portal/templates/_includes/login.html similarity index 100% rename from ram/portal/templates/includes/login.html rename to ram/portal/templates/_includes/login.html diff --git a/ram/portal/templates/includes/search.html b/ram/portal/templates/_includes/search.html similarity index 100% rename from ram/portal/templates/includes/search.html rename to ram/portal/templates/_includes/search.html diff --git a/ram/portal/templates/includes/symbols.html b/ram/portal/templates/_includes/symbols.html similarity index 100% rename from ram/portal/templates/includes/symbols.html rename to ram/portal/templates/_includes/symbols.html diff --git a/ram/portal/templates/_modules/documents.html b/ram/portal/templates/_modules/documents.html new file mode 100644 index 0000000..4331c67 --- /dev/null +++ b/ram/portal/templates/_modules/documents.html @@ -0,0 +1,26 @@ + {% if documents %} + + + + + + + + {% for d in documents.all %} + + + + + + {% endfor %} + +
{{ header|default:"Documents" }}
{{ d.description }} + {% if d.private %} + + {% else %} + + {% endif %} + {{ d.filename }} + {{ d.file.size | filesizeformat }}
+ {% endif %} + diff --git a/ram/portal/templates/_modules/properties.html b/ram/portal/templates/_modules/properties.html new file mode 100644 index 0000000..b60863f --- /dev/null +++ b/ram/portal/templates/_modules/properties.html @@ -0,0 +1,18 @@ + {% if properties %} + + + + + + + + {% for p in properties %} + + + + + {% endfor %} + +
Properties
{{ p.property }}{{ p.value }}
+ {% endif %} + diff --git a/ram/portal/templates/_modules/purchase_data.html b/ram/portal/templates/_modules/purchase_data.html new file mode 100644 index 0000000..f667afd --- /dev/null +++ b/ram/portal/templates/_modules/purchase_data.html @@ -0,0 +1,29 @@ + {% if request.user.is_staff %} + {% if data.shop or data.purchase_date or data.price %} + + + + + + + + + + + + + + + + + + + + +
Purchase
Shop + {{ data.shop|default:"-" }} + {% if data.shop.website %} {% endif %} +
Purchase date{{ data.purchase_date|default:"-" }}
Price ({{ site_conf.currency }}){{ data.price|default:"-" }}
+ {% endif %} + {% endif %} + diff --git a/ram/portal/templates/base.html b/ram/portal/templates/base.html index 2ef2e1f..44d6d1a 100644 --- a/ram/portal/templates/base.html +++ b/ram/portal/templates/base.html @@ -148,7 +148,7 @@ {{ site_conf.site_name }} - {% include 'includes/login.html' %} + {% include '_includes/login.html' %} @@ -186,7 +186,7 @@ {% show_bookshelf_menu %} {% show_flatpages_menu user %} - {% include 'includes/search.html' %} + {% include '_includes/search.html' %} @@ -211,9 +211,9 @@
{% block pagination %}{% endblock %}
{% block extra_content %}{% endblock %} - {% include 'includes/symbols.html' %} + {% include '_includes/symbols.html' %} - {% include 'includes/footer.html' %} + {% include '_includes/footer.html' %} {% if site_conf.use_cdn %} {% else %} diff --git a/ram/portal/templates/bookshelf/book.html b/ram/portal/templates/bookshelf/book.html index 4e14488..d6532a8 100644 --- a/ram/portal/templates/bookshelf/book.html +++ b/ram/portal/templates/bookshelf/book.html @@ -147,49 +147,8 @@ {% endif %} - {% if request.user.is_staff %} - - - - - - - - - - - - - - - - - - - - -
Purchase
Shop - {{ data.shop|default:"-" }} - {% if data.shop.website %} {% endif %} -
Purchase date{{ data.purchase_date|default:"-" }}
Price ({{ site_conf.currency }}){{ data.price|default:"-" }}
- {% endif %} - {% if properties %} - - - - - - - - {% for p in properties %} - - - - - {% endfor %} - -
Properties
{{ p.property }}{{ p.value }}
- {% endif %} + {% include "_modules/purchase_data.html" %} + {% include "_modules/properties.html" %}
diff --git a/ram/portal/templates/rollingstock.html b/ram/portal/templates/rollingstock.html index 3cdee98..4f71c97 100644 --- a/ram/portal/templates/rollingstock.html +++ b/ram/portal/templates/rollingstock.html @@ -217,49 +217,8 @@ {% endif %} - {% if request.user.is_staff %} - - - - - - - - - - - - - - - - - - - - -
Purchase
Shop - {{ rolling_stock.shop | default:"-" }} - {% if rolling_stock.shop.website %} {% endif %} -
Purchase date{{ rolling_stock.purchase_date | default:"-" }}
Price ({{ site_conf.currency }}){{ rolling_stock.price | default:"-" }}
- {% endif %} - {% if properties %} - - - - - - - - {% for p in properties %} - - - - - {% endfor %} - -
Properties
{{ p.property }}{{ p.value }}
- {% endif %} + {% include "_modules/purchase_data.html" with data=rolling_stock %} + {% include "_modules/properties.html" %}