From 4c93a27109820e6d75310de384c7214b885d38a4 Mon Sep 17 00:00:00 2001 From: Thomas Rusiecki Date: Mon, 30 Dec 2024 15:42:29 -0300 Subject: [PATCH] added a sidebar notes display --- device/templates/details.html | 37 +++++++++++++++++++++++++++++++++++ device/views.py | 3 ++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/device/templates/details.html b/device/templates/details.html index d41a30c..a53e41c 100644 --- a/device/templates/details.html +++ b/device/templates/details.html @@ -3,6 +3,43 @@ {% block content %} +
+ +
+ + + +
+
+
{% trans "Latest Notes" %}
+ +
+
+ {% for note in device_notes|slice:":5" %} +
+
+
+ + {{ note.user.get_full_name|default:note.user.username }} + + + {{ note.date|timesince }} {% trans "ago" %} + +
+

{{ note.description }}

+
+
+ {% empty %} +

{% trans "No notes available." %}

+ {% endfor %} +
+
+

{{ object.shortid }}

diff --git a/device/views.py b/device/views.py index 7b6535d..fc520a6 100644 --- a/device/views.py +++ b/device/views.py @@ -13,7 +13,7 @@ from django.views.generic.edit import ( DeleteView, ) from django.views.generic.base import TemplateView -from action.models import StateDefinition, State, DeviceLog +from action.models import StateDefinition, State, DeviceLog, Note from dashboard.mixins import DashboardView, Http403 from evidence.models import UserProperty, SystemProperty from lot.models import LotTag @@ -125,6 +125,7 @@ class DetailsView(DashboardView, TemplateView): "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_logs": DeviceLog.objects.filter(snapshot_uuid=uuid).order_by('-date'), + "device_notes": Note.objects.filter(snapshot_uuid=uuid).order_by('-date'), }) return context