diff --git a/logs/models.py b/logs/models.py
index 50471375..17146389 100644
--- a/logs/models.py
+++ b/logs/models.py
@@ -25,6 +25,7 @@ from reversion.models import Version, Revision
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import Group
from django.db.models import Q
+from django.apps import apps
from machines.models import IpList
from machines.models import Interface
@@ -39,6 +40,34 @@ from topologie.models import Port
from .forms import classes_for_action_type
+class VersionAction:
+ def __init__(self, version):
+ self.version = version
+
+ def name(self):
+ return self.version.object_repr
+
+ def application(self):
+ return self.version.content_type.app_label
+
+ def model_name(self):
+ return self.version.content_type.model
+
+ def object_id(self):
+ return self.version.object_id
+
+ def object_type(self):
+ return apps.get_model(self.application(), self.model_name())
+
+
+class RevisionAction:
+ """A Revision may group multiple Version objects together"""
+ def __init__(self, revision):
+ self.performed_by = revision.user
+ self.revision = revision
+ self.versions = [VersionAction(v) for v in revision.version_set.all()]
+
+
class ActionsSearch:
def get(self, params):
"""
@@ -65,7 +94,8 @@ class ActionsSearch:
if action_models:
query &= Q(version__content_type__model__in=action_models)
- return (
+ return map(
+ RevisionAction,
Revision.objects.all()
.filter(query)
.select_related("user")
diff --git a/logs/templates/logs/aff_stats_logs.html b/logs/templates/logs/aff_stats_logs.html
index ab12a02f..c161cdbd 100644
--- a/logs/templates/logs/aff_stats_logs.html
+++ b/logs/templates/logs/aff_stats_logs.html
@@ -34,7 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% for revision in revisions_list %}
- {% for reversion in revision.version_set.all %}
+ {% for version in revision.versions %}
{% trans "Edited object" %}
- {% trans "Object type" %}
{% trans "Edited by" as tr_edited_by %}
{% include 'buttons/sort.html' with prefix='logs' col='author' text=tr_edited_by %}
{% trans "Date of editing" as tr_date_of_editing %}
@@ -44,11 +43,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,