From 60a8fd0ed5b49bb111084bc404a6ffc0909dd0ee Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Sat, 25 Apr 2020 11:09:22 +0000 Subject: [PATCH] Improve display of deleted objects in history --- logs/models.py | 17 ++++------------- re2o/templates/re2o/aff_history.html | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/logs/models.py b/logs/models.py index e7d56afa..365424d9 100644 --- a/logs/models.py +++ b/logs/models.py @@ -299,7 +299,7 @@ class RelatedHistory: self.app_name = version.content_type.app_label self.model_name = version.content_type.model self.object_id = version.object_id - self.name = version._object_cache or version.object_repr + self.name = version.object_repr def __eq__(self, other): return ( @@ -390,6 +390,7 @@ class History: if self._last_version is None: return None + self.name = self._last_version.object_repr return self.events[::-1] def _compute_diff(self, v1, v2, ignoring=[]): @@ -743,12 +744,7 @@ class MachineHistory(History): self.related = [RelatedHistory(v) for v in self.related] self.related = list(dict.fromkeys(self.related)) - events = super(MachineHistory, self).get(machine_id, Machine) - - # Update name - self.name = self._last_version.field_dict["name"] - - return events + return super(MachineHistory, self).get(machine_id, Machine) class InterfaceHistoryEvent(HistoryEvent): @@ -794,12 +790,7 @@ class InterfaceHistory(History): self.event_type = InterfaceHistoryEvent def get(self, interface_id, model): - events = super(InterfaceHistory, self).get(interface_id, Interface) - - # Update name - self.name = self._last_version.field_dict["mac_address"] - - return events + return super(InterfaceHistory, self).get(interface_id, Interface) ############################ diff --git a/re2o/templates/re2o/aff_history.html b/re2o/templates/re2o/aff_history.html index 46eb82bc..a52ecc38 100644 --- a/re2o/templates/re2o/aff_history.html +++ b/re2o/templates/re2o/aff_history.html @@ -79,7 +79,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% for related in related_history %}
  • {% if related.object_id %} - + {{ related.name }} {% else %}