mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 09:26:27 +00:00
Make related history in detailed history view nicer
This commit is contained in:
parent
8469d758ce
commit
a3d31f5c4b
2 changed files with 8 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -75,18 +75,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<h3>{% trans "No event" %}</h3>
|
||||
{% endif %}
|
||||
|
||||
<h2>{% trans "Related history" %}</h2>
|
||||
|
||||
{% if related_history %}
|
||||
|
||||
<h2>{% blocktrans %}Related elements{% endblocktrans %}</h2>
|
||||
|
||||
<ul>
|
||||
{% for related in related_history %}
|
||||
<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>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<h3>{% trans "No related history" %}</h3>
|
||||
{% endif %}
|
||||
<br />
|
||||
<br />
|
||||
|
|
Loading…
Reference in a new issue