diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2017-10-18 22:24:12 -0400 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2017-10-18 22:24:12 -0400 |
| commit | b38e080824587d9f3ba5d2ac589dc7c82e322c3c (patch) | |
| tree | 0dc6b573c2b6abfdefaa302111abc4fed68d1d3b | |
| parent | ce72b1fd9ca4136c0894d826dd5b20153e57c537 (diff) | |
| download | dispatch-tracker-b38e080824587d9f3ba5d2ac589dc7c82e322c3c.tar.gz dispatch-tracker-b38e080824587d9f3ba5d2ac589dc7c82e322c3c.tar.xz | |
Add support for Recent changes being viewable on the load detail page
| -rw-r--r-- | app/dispatch/templates/dispatch/loads/detail.html | 35 | ||||
| -rw-r--r-- | app/dispatch/templatetags/dynamic_key.py | 4 |
2 files changed, 35 insertions, 4 deletions
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 %} <div class="row"> <div class="col s12 m6"> <h1>Details for {{object.load_number}}</h1> </div> -</div> +</div> <div class="row"> - <div class="col s12"> + <div class="col s12"> <div class="right-align"> <a class="btn blue" href="{%url 'load_edit' object.id %}">Edit</a> </div> @@ -82,11 +83,37 @@ {% endfor %} </tbody> </table> - </div> </div> + <div class="row"> + <div class="col s12"> + <h4>Recent Changes</h4> + {% 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}} ) + <table> + <thead> + <th>Field</th> + <th>From</th> + <th>To</th> + </thead> + <tbody> + {% for field, changes in h.changes_dict.items %} + <tr> + <th>{{field}}</th> + <td>{{changes|getindex:0}}</td> + <td>{{changes|getindex:1}}</td> + </tr> + {% endfor %} + </tbody> + </table> + {% endif %} + {% endfor %} + </div> + </div> + -</div> +</div> {% 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] |
