8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 07:23:46 +00:00

Improve display of deleted objects in history

This commit is contained in:
Jean-Romain Garnier 2020-04-25 11:09:22 +00:00 committed by Supelec Rezo Rennes
parent 13cb3f7990
commit de23ed7e03
2 changed files with 5 additions and 14 deletions

View file

@ -299,7 +299,7 @@ class RelatedHistory:
self.app_name = version.content_type.app_label self.app_name = version.content_type.app_label
self.model_name = version.content_type.model self.model_name = version.content_type.model
self.object_id = version.object_id self.object_id = version.object_id
self.name = version._object_cache or version.object_repr self.name = version.object_repr
def __eq__(self, other): def __eq__(self, other):
return ( return (
@ -390,6 +390,7 @@ class History:
if self._last_version is None: if self._last_version is None:
return None return None
self.name = self._last_version.object_repr
return self.events[::-1] return self.events[::-1]
def _compute_diff(self, v1, v2, ignoring=[]): 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 = [RelatedHistory(v) for v in self.related]
self.related = list(dict.fromkeys(self.related)) self.related = list(dict.fromkeys(self.related))
events = super(MachineHistory, self).get(machine_id, Machine) return super(MachineHistory, self).get(machine_id, Machine)
# Update name
self.name = self._last_version.field_dict["name"]
return events
class InterfaceHistoryEvent(HistoryEvent): class InterfaceHistoryEvent(HistoryEvent):
@ -794,12 +790,7 @@ class InterfaceHistory(History):
self.event_type = InterfaceHistoryEvent self.event_type = InterfaceHistoryEvent
def get(self, interface_id, model): def get(self, interface_id, model):
events = super(InterfaceHistory, self).get(interface_id, Interface) return super(InterfaceHistory, self).get(interface_id, Interface)
# Update name
self.name = self._last_version.field_dict["mac_address"]
return events
############################ ############################

View file

@ -79,7 +79,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% for related in related_history %} {% for related in related_history %}
<li> <li>
{% if related.object_id %} {% if related.object_id %}
<a href="{% url 'logs:history' related.application related.model_name related.object_id %}" title="{% trans "History" %}"> <a href="{% url 'logs:history' related.app_name related.model_name related.object_id %}" title="{% trans "History" %}">
{{ related.name }} {{ related.name }}
</a> </a>
{% else %} {% else %}