8
0
Fork 0
mirror of https://gitlab.federez.net/re2o/re2o synced 2024-07-02 04:04:06 +00:00

Improve user history view event format

This commit is contained in:
Jean-Romain Garnier 2020-04-23 12:44:23 +00:00 committed by Hugo Levy-Falk
parent 42cc29e2f8
commit b1a170f3e4
2 changed files with 18 additions and 9 deletions

View file

@ -232,24 +232,30 @@ class UserHistoryEvent:
:param value: the value of the field
:return: object
"""
if name == "groups" and value is not None:
if name == "groups":
if len(value) == 0:
# Removed all the user's groups
return _("None")
# value is a list of ints
groups = []
for gid in value:
# Try to get the group name, if it's not deleted
try:
groups.append(Group.objects.get(id=gid))
groups.append(Group.objects.get(id=gid).name)
except Group.DoesNotExist:
# TODO: Find the group name in the versions?
groups.append(_("Deleted"))
return ", ".join(groups)
elif name == "state":
if value is not None:
return User.STATES[value]
return User.STATES[value][1]
else:
return _("Unknown")
elif name == "email_state":
if value is not None:
return User.EMAIL_STATES[value]
return User.EMAIL_STATES[value][1]
else:
return _("Unknown")

View file

@ -53,12 +53,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</td>
<td>
{% for edit in event.edits %}
{% if edit.1 and edit.2 %}
{{ edit.0 }}: {{ edit.1 }} ➔ {{ edit.2 }}<br/>
{% elif edit.2 %}
{{ edit.0 }}: {{ edit.2 }}<br/>
{% if edit.1 is None and edit.2 is None %}
<strong>{{ edit.0 }}</strong><br/>
{% elif edit.1 is None %}
<strong>{{ edit.0 }}:</strong>
<i class="text-success"> {{ edit.2 }}</i><br/>
{% else %}
{{ edit.0 }}<br/>
<strong>{{ edit.0 }}:</strong>
<i class="text-danger"> {{ edit.1 }} </i>
<i class="text-success">{{ edit.2 }}</i><br/>
{% endif %}
{% endfor %}
</td>