From 4989bac4a5fe2650846ca4c166836e6c0e6a3926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Tue, 19 Apr 2022 19:18:31 +0200 Subject: [PATCH 1/5] Add support for consist and minor improvements --- ram/consist/models.py | 4 + ram/portal/templates/base.html | 73 ++++++----- ram/portal/templates/consist.html | 147 ++++++++++++++++++++++ ram/portal/templates/consists.html | 93 ++++++++++++++ ram/portal/templates/includes/login.html | 2 +- ram/portal/templates/includes/search.html | 4 +- ram/portal/templates/page.html | 8 +- ram/portal/urls.py | 33 ++++- ram/portal/views.py | 95 ++++++++++---- 9 files changed, 391 insertions(+), 68 deletions(-) create mode 100644 ram/portal/templates/consist.html create mode 100644 ram/portal/templates/consists.html diff --git a/ram/consist/models.py b/ram/consist/models.py index bb9b7ab..cdd1085 100644 --- a/ram/consist/models.py +++ b/ram/consist/models.py @@ -1,5 +1,6 @@ from uuid import uuid4 from django.db import models +from django.urls import reverse from metadata.models import Company, Tag from roster.models import RollingStock @@ -23,6 +24,9 @@ class Consist(models.Model): def __str__(self): return "{0}".format(self.identifier) + def get_absolute_url(self): + return reverse("consist", kwargs={"uuid": self.uuid}) + class ConsistItem(models.Model): consist = models.ForeignKey( diff --git a/ram/portal/templates/base.html b/ram/portal/templates/base.html index 8b62c38..35df3cd 100644 --- a/ram/portal/templates/base.html +++ b/ram/portal/templates/base.html @@ -32,11 +32,11 @@
-
-
+
@@ -64,7 +73,7 @@
-
+
{% block cards %} {% for r in rolling_stock %}
@@ -74,6 +83,13 @@ {% endfor %}

{{ r }}

+ {% if r.tags.all %} +

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

+ {% endif %} @@ -113,38 +129,31 @@ - -
SKU {{ r.sku }}
+ + {% if r.decoder %} - - - - - - - - - - - - - - - - -
DCC data
Decoder{{ r.decoder }}
Address{{ r.address }}
+ + + + + + + + + + + + + + + + +
DCC data
Decoder{{ r.decoder }}
Address{{ r.address }}
{% endif %}
Show all data {% if request.user.is_staff %}Edit{% endif %}
- {% if r.tags.all %} -

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

- {% endif %}
Updated {{ r.updated_time | date:"M d, Y H:m" }}
diff --git a/ram/portal/templates/consist.html b/ram/portal/templates/consist.html new file mode 100644 index 0000000..711ff7b --- /dev/null +++ b/ram/portal/templates/consist.html @@ -0,0 +1,147 @@ +{% extends "base.html" %} +{% load markdown %} + + {% block header %} +

{{ consist }}

+ {% if consist.tags.all %} +

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

+ {% endif %} + {% endblock %} + {% block cards %} + {% for r in rolling_stock %} +
+
+ {% for i in r.rolling_stock.image.all %} + {% if i.is_thumbnail %}Card image cap{% endif %} + {% endfor %} +
+

{{ r }}

+ {% if r.rolling_stock.tags.all %} +

Tags: + {% for t in r.rolling_stock.tags.all %} + {{ t.name }}{# new line is required #} + {% endfor %} +

+ {% endif %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Data
Type{{ r.rolling_stock.rolling_class.type }}
Company{{ r.rolling_stock.rolling_class.company }}
Class{{ r.rolling_stock.rolling_class.identifier }}
Road number{{ r.rolling_stock.road_number }}
Era{{ r.rolling_stock.era }}
Manufacturer{% if r.rolling_stock.manufacturer.website %}{% endif %}{{ r.rolling_stock.manufacturer }}{% if r.rolling_stock.manufacturer.website %}{% endif %} +
Scale{{ r.rolling_stock.scale }}
SKU{{ r.rolling_stock.sku }}
+ {% if r.rolling_stock.decoder %} + + + + + + + + + + + + + + + + +
DCC data
Decoder{{ r.rolling_stock.decoder }}
Address{{ r.rolling_stock.address }}
+ {% endif %} +
+ Show all data + {% if request.user.is_staff %}Edit{% endif %} +
+
+ Updated {{ r.rolling_stock.updated_time | date:"M d, Y H:m" }} +
+
+
+
+ {% endfor %} + {% endblock %} + {% block pagination %} + {% if rolling_stock.has_other_pages %} + + {% endif %} + {% endblock %} + {% block extra_content %} +
+
+
+
+ {% if request.user.is_staff %}Edit{% endif %} +
+
+
+
+ {% endblock %} diff --git a/ram/portal/templates/consists.html b/ram/portal/templates/consists.html new file mode 100644 index 0000000..b62e53b --- /dev/null +++ b/ram/portal/templates/consists.html @@ -0,0 +1,93 @@ +{% extends "base.html" %} +{% load markdown %} + + {% block header %} +

Consists

+ {% endblock %} + {% block cards %} + {% for c in consist %} +
+
+
+

{{ c.identifier }}

+ {% if c.tags.all %} +

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

+ {% endif %} + + + + + + + + {% if c.address %} + + + + + {% endif %} + + + + + + + + + + + + + +
Consist data
Address{{ c.address }}
Company{{ c.company }}
Era{{ c.era }}
Length{{ c.consist_item.all | length }}
+
+ Show all data + {% if request.user.is_staff %}Edit{% endif %} +
+
+ Updated {{ c.updated_time | date:"M d, Y H:m" }} +
+
+
+
+ {% endfor %} + {% endblock %} + {% block pagination %} + {% if rolling_stock.has_other_pages %} + + {% endif %} + {% endblock %} diff --git a/ram/portal/templates/includes/login.html b/ram/portal/templates/includes/login.html index 6ecd6f4..b67f2ee 100644 --- a/ram/portal/templates/includes/login.html +++ b/ram/portal/templates/includes/login.html @@ -1,6 +1,6 @@ {% if request.user.is_staff %}
-
+