From 9e38ec0faa092af8e39e0606d494979200b9d44a Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Fri, 24 Apr 2020 13:56:02 +0000 Subject: [PATCH] Fix actions filtering --- logs/forms.py | 11 ++++++----- logs/models.py | 2 +- logs/templates/logs/search_stats_logs.html | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/logs/forms.py b/logs/forms.py index 1ebfdcd4..72212b0c 100644 --- a/logs/forms.py +++ b/logs/forms.py @@ -40,16 +40,18 @@ def get_classes(module): for name, obj in inspect.getmembers(module): if inspect.isclass(obj): - classes.append((obj, name)) + classes.append(name) return classes # Get the list of all imported classes modules = [machines.models, preferences.models, tickets.models, topologie.models, users.models] -classes = sum([get_classes(m) for m in modules]) +classes = sum([get_classes(m) for m in modules], []) -CHOICES_ACTION_TYPE = classes +CHOICES_ACTION_TYPE = [ + (str(i), classes[i]) for i in range(len(classes)) +] CHOICES_TYPE = ( ("ip", _("IPv4")), @@ -63,7 +65,6 @@ class ActionsSearchForm(Form): label=_("Performed by"), max_length=100, required=False, - queryset=users.models.User.objects.all() ) t = forms.MultipleChoiceField( label=_("Action type"), @@ -76,7 +77,7 @@ class ActionsSearchForm(Form): e = forms.DateField(required=False, label=_("End date")) def __init__(self, *args, **kwargs): - super(MachineHistorySearchForm, self).__init__(*args, **kwargs) + super(ActionsSearchForm, self).__init__(*args, **kwargs) self.fields["s"].help_text = get_input_formats_help_text( self.fields["s"].input_formats ) diff --git a/logs/models.py b/logs/models.py index cc261411..1ce117ff 100644 --- a/logs/models.py +++ b/logs/models.py @@ -60,7 +60,7 @@ class ActionsSearch: query &= Q(date_created__leq=end) if actions_type: - query &= Q(version_set__object__in=actions_type) + query &= Q(version__content_type__in=actions_type) return ( Revision.objects.all() diff --git a/logs/templates/logs/search_stats_logs.html b/logs/templates/logs/search_stats_logs.html index d0b56ea6..5faa8066 100644 --- a/logs/templates/logs/search_stats_logs.html +++ b/logs/templates/logs/search_stats_logs.html @@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,

{% trans "Search events" %}

{% bootstrap_field actions_form.u %} - {% bootstrap_field actions_form.t %} + {% include 'buttons/multiple_checkbox_alt.html' with field=actions_form.t %} {% bootstrap_field actions_form.s %} {% bootstrap_field actions_form.e %} {% trans "Search" as tr_search %}