Browse Source

Fix filtering action logs by type

release-2.9
Jean-Romain Garnier 6 years ago
committed by Gabriel Detraz
parent
commit
43bfed664d
  1. 2
      logs/forms.py
  2. 8
      logs/models.py
  3. 2
      logs/templates/logs/aff_stats_logs.html

2
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":

8
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

2
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 %}
<tr>
<td>{{ reversion.object|truncatechars:20 }}</td>
<td>{{ reversion.object|classname }}</td>
<td>{{ reversion.content_type.model|truncatechars:20 }}</td>
<td>{{ revision.user }}</td>
<td>{{ revision.date_created }}</td>
<td>{{ revision.comment }}</td>

Loading…
Cancel
Save