From ba7e0080aaec8cfbe97da6fea05c93c608548eaf Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Fri, 24 Apr 2020 14:34:36 +0000 Subject: [PATCH] Fix filtering action logs by type --- logs/forms.py | 2 +- logs/models.py | 8 ++++---- logs/templates/logs/aff_stats_logs.html | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/logs/forms.py b/logs/forms.py index ffae8e52..ae281e98 100644 --- a/logs/forms.py +++ b/logs/forms.py @@ -85,7 +85,7 @@ def classes_for_action_type(action_type): if action_type == "whitelists": return [users.models.Whitelist.__name__] - if action_type == "ban": + if action_type == "bans": return [users.models.Ban.__name__] if action_type == "topology": diff --git a/logs/models.py b/logs/models.py index 6528ea23..ce2b3602 100644 --- a/logs/models.py +++ b/logs/models.py @@ -60,9 +60,9 @@ class ActionsSearch: if end: query &= Q(date_created__leq=end) - action_classes = self.classes_for_action_types(action_types) - if action_classes: - query &= Q(object__classname=action_classes) + action_models = self.models_for_action_types(action_types) + if action_models: + query &= Q(version__content_type__model__in=action_models) return ( Revision.objects.all() @@ -71,7 +71,7 @@ class ActionsSearch: .prefetch_related("version_set__object") ) - def classes_for_action_types(self, action_types): + def models_for_action_types(self, action_types): if action_types is None: return None diff --git a/logs/templates/logs/aff_stats_logs.html b/logs/templates/logs/aff_stats_logs.html index adccc95f..ab12a02f 100644 --- a/logs/templates/logs/aff_stats_logs.html +++ b/logs/templates/logs/aff_stats_logs.html @@ -47,7 +47,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% for reversion in revision.version_set.all %} {{ reversion.object|truncatechars:20 }} - {{ reversion.object|classname }} + {{ reversion.content_type.model|truncatechars:20 }} {{ revision.user }} {{ revision.date_created }} {{ revision.comment }}