From ac1d5a3ab03c5a8d0b4f029bf549c2b59340a449 Mon Sep 17 00:00:00 2001 From: Thomas Rusiecki Date: Fri, 6 Dec 2024 19:19:49 -0300 Subject: [PATCH] changed state visual and ordering --- device/templates/details.html | 66 ++++++++++++++++++++++++++++++----- device/views.py | 2 +- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/device/templates/details.html b/device/templates/details.html index 5409cbb..16f973c 100644 --- a/device/templates/details.html +++ b/device/templates/details.html @@ -37,6 +37,9 @@ + @@ -122,14 +125,30 @@
{% trans 'Current State' %}

-
-
{% trans 'State' %}
-
{{ device_states.0.state }}
-
-
-
{% trans 'Date' %}
-
{{ device_states.0.date|date:"SHORT_DATETIME_FORMAT" }}
-
+
+ + + + + + + + + + {% if device_states %} + + + + + + {% else %} + + + + {% endif %} + +
{% trans 'State' %}{% trans 'User' %}{% trans 'Date' %}
{{ device_states.0.state }}{{ device_states.0.user.responsable_person|default:device_states.0.user.username }}{{ device_states.0.date|date:"SHORT_DATETIME_FORMAT" }}
{% trans 'No state recorded.' %}
+
{% if last_note %} @@ -143,7 +162,36 @@
- + + +
+
{% trans 'History of States' %}
+
+ + + + + + + + + + {% for state_change in device_states %} + + + + + + + {% empty %} + + + + {% endfor %} + +
{% trans 'Date' %}{% trans 'User' %}{% trans 'State' %}
{{ state_change.state }}{{ state_change.user.responsable_person|default:state_change.user.username }}{{ state_change.date|date:"SHORT_DATETIME_FORMAT" }}
{% trans 'No state changes recorded.' %}
+
+
diff --git a/device/views.py b/device/views.py index 7f9c380..743c67e 100644 --- a/device/views.py +++ b/device/views.py @@ -116,7 +116,7 @@ class DetailsView(DashboardView, TemplateView): 'snapshot': last_evidence, 'lot_tags': lot_tags, "state_definitions": StateDefinition.objects.filter(institution=self.request.user.institution).order_by('order'), - "device_states": State.objects.filter(snapshot_uuid=uuid).order_by('date'), + "device_states": State.objects.filter(snapshot_uuid=uuid).order_by('-date'), }) return context