From f69e270e4d3bddd0e488886a05d9360316275853 Mon Sep 17 00:00:00 2001 From: Martin Gross Date: Mon, 13 Dec 2021 12:47:43 +0100 Subject: [PATCH] Add filter for revoked devices (#2372) Co-authored-by: Raphael Michel --- src/pretix/control/forms/filter.py | 14 ++++++++++++++ .../pretixcontrol/organizers/devices.html | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pretix/control/forms/filter.py b/src/pretix/control/forms/filter.py index 485753123b..1ccd554ed4 100644 --- a/src/pretix/control/forms/filter.py +++ b/src/pretix/control/forms/filter.py @@ -2018,6 +2018,15 @@ class DeviceFilterForm(FilterForm): ], required=False, ) + state = forms.ChoiceField( + label=_('Device status'), + choices=[ + ('', _('All devices')), + ('active', _('Active devices')), + ('revoked', _('Revoked devices')) + ], + required=False + ) def __init__(self, *args, **kwargs): request = kwargs.pop('request') @@ -2047,6 +2056,11 @@ class DeviceFilterForm(FilterForm): if fdata.get('gate'): qs = qs.filter(gate=fdata['gate']) + if fdata.get('state') == 'active': + qs = qs.filter(revoked=False) + elif fdata.get('state') == 'revoked': + qs = qs.filter(revoked=True) + if fdata.get('ordering'): qs = qs.order_by(self.get_order_by()) else: diff --git a/src/pretix/control/templates/pretixcontrol/organizers/devices.html b/src/pretix/control/templates/pretixcontrol/organizers/devices.html index bf94a73985..9e488f9fa2 100644 --- a/src/pretix/control/templates/pretixcontrol/organizers/devices.html +++ b/src/pretix/control/templates/pretixcontrol/organizers/devices.html @@ -30,7 +30,7 @@
-
+
{% bootstrap_field filter_form.query %}
@@ -39,6 +39,9 @@
{% bootstrap_field filter_form.software_brand %}
+
+ {% bootstrap_field filter_form.state %} +