From 85edbe48376047142ceb7e85c4aba1fe70e1bab7 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 18 Jul 2019 17:26:34 +0200 Subject: [PATCH] Improved device validation --- src/pretix/control/forms/organizer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pretix/control/forms/organizer.py b/src/pretix/control/forms/organizer.py index 118af4eefb..a427c6f7de 100644 --- a/src/pretix/control/forms/organizer.py +++ b/src/pretix/control/forms/organizer.py @@ -173,6 +173,13 @@ class DeviceForm(forms.ModelForm): super().__init__(*args, **kwargs) self.fields['limit_events'].queryset = organizer.events.all() + def clean(self): + d = super().clean() + if not d['all_events'] and not d['limit_events']: + raise ValidationError(_('Your device will not have access to anything, please select some events.')) + + return d + class Meta: model = Device fields = ['name', 'all_events', 'limit_events']