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 %}