From b38e080824587d9f3ba5d2ac589dc7c82e322c3c Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Wed, 18 Oct 2017 22:24:12 -0400 Subject: Add support for Recent changes being viewable on the load detail page --- app/dispatch/templates/dispatch/loads/detail.html | 35 ++++++++++++++++++++--- app/dispatch/templatetags/dynamic_key.py | 4 +++ 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/dispatch/templates/dispatch/loads/detail.html b/app/dispatch/templates/dispatch/loads/detail.html index bf6d809..44997ee 100644 --- a/app/dispatch/templates/dispatch/loads/detail.html +++ b/app/dispatch/templates/dispatch/loads/detail.html @@ -3,14 +3,15 @@ {% block title %}Details - {{ object.load_number }}{% endblock %} {% block content %} +{% load dynamic_key %}

Details for {{object.load_number}}

-
+
-
+
@@ -82,11 +83,37 @@ {% endfor %} -
+
+
+

Recent Changes

+ {% for h in object.history.get_queryset %} + {% if h.actor is not None %} + Change By: {{h.actor.first_name}} {{h.actor.last_name}} ( {{h.actor.email}} ) + + + + + + + + {% for field, changes in h.changes_dict.items %} + + + + + + {% endfor %} + +
FieldFromTo
{{field}}{{changes|getindex:0}}{{changes|getindex:1}}
+ {% endif %} + {% endfor %} +
+
+ -
+ {% endblock %} diff --git a/app/dispatch/templatetags/dynamic_key.py b/app/dispatch/templatetags/dynamic_key.py index fdd7f10..47a7ef8 100644 --- a/app/dispatch/templatetags/dynamic_key.py +++ b/app/dispatch/templatetags/dynamic_key.py @@ -5,3 +5,7 @@ register = template.Library() @register.filter def keyvalue(dictionary, key): return dictionary.get(key) + +@register.filter +def getindex(my_list, index): + return my_list[index] -- cgit v1.2.3