mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Make related history in detailed history view nicer
This commit is contained in:
parent
f3ac37d2e6
commit
caf09173f3
2 changed files with 8 additions and 10 deletions
|
@ -227,13 +227,12 @@ class RelatedHistory:
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return (
|
return (
|
||||||
self.name == other.name
|
self.model_name == other.model_name
|
||||||
and self.model_name == other.model_name
|
|
||||||
and self.object_id == other.object_id
|
and self.object_id == other.object_id
|
||||||
)
|
)
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash((self.name, self.model_name, self.object_id))
|
return hash((self.model_name, self.object_id))
|
||||||
|
|
||||||
|
|
||||||
class HistoryEvent:
|
class HistoryEvent:
|
||||||
|
@ -466,7 +465,7 @@ class UserHistory(History):
|
||||||
# that were once owned by this user
|
# that were once owned by this user
|
||||||
self.related = filter(
|
self.related = filter(
|
||||||
lambda x: x.field_dict["user_id"] == user.id,
|
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(
|
self.related = [RelatedHistory(
|
||||||
m.field_dict["name"] or _("None"),
|
m.field_dict["name"] or _("None"),
|
||||||
|
@ -553,7 +552,7 @@ class MachineHistory(History):
|
||||||
# that were once assigned to this machine
|
# that were once assigned to this machine
|
||||||
self.related = list(filter(
|
self.related = list(filter(
|
||||||
lambda x: x.field_dict["machine_id"] == machine.id,
|
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
|
# Create RelatedHistory objects and remove duplicates
|
||||||
|
|
|
@ -75,18 +75,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<h3>{% trans "No event" %}</h3>
|
<h3>{% trans "No event" %}</h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h2>{% trans "Related history" %}</h2>
|
|
||||||
|
|
||||||
{% if related_history %}
|
{% if related_history %}
|
||||||
|
|
||||||
|
<h2>{% blocktrans %}Related elements{% endblocktrans %}</h2>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for related in related_history %}
|
{% for related in related_history %}
|
||||||
<li>
|
<li>
|
||||||
<a title="{% trans "History" %}" href="{% url 'logs:detailed-history' related.model_name related.object_id %}">{{ related.name }}</a>
|
<a title="{% trans "History" %}" href="{% url 'logs:detailed-history' related.model_name related.object_id %}">{{ related.model_name }} - {{ related.name }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
|
||||||
<h3>{% trans "No related history" %}</h3>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
Loading…
Reference in a new issue