diff --git a/logs/models.py b/logs/models.py index 01927de8..0e544215 100644 --- a/logs/models.py +++ b/logs/models.py @@ -256,28 +256,23 @@ class UserHistoryEvent: class UserHistory: def __init__(self): self.events = [] - self.user = None self.__last_version = None - def get(self, user_id): + def get(self, user): """ - :param user_id: id of the user to lookup + :param user: User, the user to lookup :return: list or None, a list of UserHistoryEvent, in reverse chronological order """ self.events = [] - try: - self.user = User.objects.get(id=user_id) - except User.DoesNotExist: - return None # Get all the versions for this user, with the oldest first user_versions = filter( - lambda x: x.field_dict["id"] == user_id, + lambda x: x.field_dict["id"] == user.id, Version.objects.get_for_model(User).order_by("revision__date_created") ) for version in user_versions: - self.__add_revision(self.user, version) + self.__add_revision(user, version) return self.events[::-1] diff --git a/logs/templates/logs/user_history.html b/logs/templates/logs/user_history.html index 6cf86625..b7714978 100644 --- a/logs/templates/logs/user_history.html +++ b/logs/templates/logs/user_history.html @@ -33,28 +33,32 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% trans "Performed by" %} | {% trans "Date" %} | -{% trans "Diff" %} | +{% trans "Performed by" %} | +{% trans "Edited" %} | {% trans "Comment" %} |
---|---|---|---|---|---|
- - {{ event.performed_by }} - - | {{ event.date }} | ++ {% if event.performed_by %} + + {{ event.performed_by }} + + {% else %} + {% trans "Unknown" %} + {% endif %} + |
{% for edit in event.edits %}
- {% if edit[1] and edit[2] %}
- {{ edit[0] }}: {{ edit[1] }} ➔ {{ edit[2] }} - {% elif edit[2] %} -{{ edit[0] }}: {{ edit[2] }} + {% if edit.1 and edit.2 %} + {{ edit.0 }}: {{ edit.1 }} ➔ {{ edit.2 }}+ {% elif edit.2 %} + {{ edit.0 }}: {{ edit.2 }} {% else %} - {{ edit[0] }} + {{ edit.0 }}{% endif %} {% endfor %} |
@@ -69,3 +73,5 @@ with this program; if not, write to the Free Software Foundation, Inc.,