8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 19:33:11 +00:00

Fix actions filtering

This commit is contained in:
Jean-Romain Garnier 2020-04-24 13:56:02 +00:00 committed by Gabriel Detraz
parent fc21a1da3e
commit f196bc8046
3 changed files with 8 additions and 7 deletions

View file

@ -40,16 +40,18 @@ def get_classes(module):
for name, obj in inspect.getmembers(module): for name, obj in inspect.getmembers(module):
if inspect.isclass(obj): if inspect.isclass(obj):
classes.append((obj, name)) classes.append(name)
return classes return classes
# Get the list of all imported classes # Get the list of all imported classes
modules = [machines.models, preferences.models, tickets.models, topologie.models, users.models] 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 = ( CHOICES_TYPE = (
("ip", _("IPv4")), ("ip", _("IPv4")),
@ -63,7 +65,6 @@ class ActionsSearchForm(Form):
label=_("Performed by"), label=_("Performed by"),
max_length=100, max_length=100,
required=False, required=False,
queryset=users.models.User.objects.all()
) )
t = forms.MultipleChoiceField( t = forms.MultipleChoiceField(
label=_("Action type"), label=_("Action type"),
@ -76,7 +77,7 @@ class ActionsSearchForm(Form):
e = forms.DateField(required=False, label=_("End date")) e = forms.DateField(required=False, label=_("End date"))
def __init__(self, *args, **kwargs): 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"].help_text = get_input_formats_help_text(
self.fields["s"].input_formats self.fields["s"].input_formats
) )

View file

@ -60,7 +60,7 @@ class ActionsSearch:
query &= Q(date_created__leq=end) query &= Q(date_created__leq=end)
if actions_type: if actions_type:
query &= Q(version_set__object__in=actions_type) query &= Q(version__content_type__in=actions_type)
return ( return (
Revision.objects.all() Revision.objects.all()

View file

@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<h3>{% trans "Search events" %}</h3> <h3>{% trans "Search events" %}</h3>
{% bootstrap_field actions_form.u %} {% 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.s %}
{% bootstrap_field actions_form.e %} {% bootstrap_field actions_form.e %}
{% trans "Search" as tr_search %} {% trans "Search" as tr_search %}