From be8a95685e965c5861535d005441f671253a41d4 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Tue, 24 Oct 2017 20:59:58 +0200 Subject: [PATCH] Add changes listing on item page --- storage/templates/item.html | 14 ++++++++++++++ storage/views.py | 2 ++ 2 files changed, 16 insertions(+) diff --git a/storage/templates/item.html b/storage/templates/item.html index f105b6a..e8fa57d 100644 --- a/storage/templates/item.html +++ b/storage/templates/item.html @@ -89,6 +89,20 @@ {% endfor %} {% endif %} + + {% if history %} +

Changes

+ + {% for entry in history %} + + + + {% endfor %} +
+ {{ entry.user }} + @ {{ entry.action_time }}
+ {{ entry.get_change_message }}
+ {% endif %}
diff --git a/storage/views.py b/storage/views.py index c66ed13..95a1b2b 100644 --- a/storage/views.py +++ b/storage/views.py @@ -3,6 +3,7 @@ from storage.models import Item, Label from django.contrib.postgres.search import SearchVector from django_select2.views import AutoResponseView from django.http import Http404, JsonResponse +from django.contrib.admin.models import LogEntry import shlex def apply_smart_search(query, objects): @@ -65,6 +66,7 @@ def item_display(request, pk): 'categories': item.categories.all(), 'images': item.images.all(), 'labels': item.labels.all(), + 'history': LogEntry.objects.filter(object_id=item.pk), 'ancestors': item.get_ancestors(), 'children': item.get_children().prefetch_related('categories'), })