From a3d31f5c4b64b1f56f98455882db1b6c6e0d2e84 Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Thu, 23 Apr 2020 18:09:39 +0000 Subject: [PATCH] Make related history in detailed history view nicer --- logs/models.py | 9 ++++----- logs/templates/logs/detailed_history.html | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/logs/models.py b/logs/models.py index 3b088b87..e3f0cba8 100644 --- a/logs/models.py +++ b/logs/models.py @@ -227,13 +227,12 @@ class RelatedHistory: def __eq__(self, other): return ( - self.name == other.name - and self.model_name == other.model_name + self.model_name == other.model_name and self.object_id == other.object_id ) def __hash__(self): - return hash((self.name, self.model_name, self.object_id)) + return hash((self.model_name, self.object_id)) class HistoryEvent: @@ -466,7 +465,7 @@ class UserHistory(History): # that were once owned by this user self.related = filter( lambda x: x.field_dict["user_id"] == user.id, - Version.objects.get_for_model(Machine).order_by("revision__date_created") + Version.objects.get_for_model(Machine).order_by("-revision__date_created") ) self.related = [RelatedHistory( m.field_dict["name"] or _("None"), @@ -553,7 +552,7 @@ class MachineHistory(History): # that were once assigned to this machine self.related = list(filter( lambda x: x.field_dict["machine_id"] == machine.id, - Version.objects.get_for_model(Interface).order_by("revision__date_created") + Version.objects.get_for_model(Interface).order_by("-revision__date_created") )) # Create RelatedHistory objects and remove duplicates diff --git a/logs/templates/logs/detailed_history.html b/logs/templates/logs/detailed_history.html index b862448d..26bae90c 100644 --- a/logs/templates/logs/detailed_history.html +++ b/logs/templates/logs/detailed_history.html @@ -75,18 +75,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,

{% trans "No event" %}

{% endif %} -

{% trans "Related history" %}

- {% if related_history %} + +

{% blocktrans %}Related elements{% endblocktrans %}

+ -{% else %} -

{% trans "No related history" %}

{% endif %}