8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 11:23:10 +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 :param value: the value of the field
:return: object :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 # value is a list of ints
groups = [] groups = []
for gid in value: for gid in value:
# Try to get the group name, if it's not deleted # Try to get the group name, if it's not deleted
try: try:
groups.append(Group.objects.get(id=gid)) groups.append(Group.objects.get(id=gid).name)
except Group.DoesNotExist: except Group.DoesNotExist:
# TODO: Find the group name in the versions? # TODO: Find the group name in the versions?
groups.append(_("Deleted")) groups.append(_("Deleted"))
return ", ".join(groups)
elif name == "state": elif name == "state":
if value is not None: if value is not None:
return User.STATES[value] return User.STATES[value][1]
else: else:
return _("Unknown") return _("Unknown")
elif name == "email_state": elif name == "email_state":
if value is not None: if value is not None:
return User.EMAIL_STATES[value] return User.EMAIL_STATES[value][1]
else: else:
return _("Unknown") return _("Unknown")

View file

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