From 1af6ada49dc01932883c838a4f37244f5dc4a2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Tue, 23 Oct 2018 21:31:43 +0200 Subject: [PATCH] volunteers: filter activities per conference --- cfp/forms.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cfp/forms.py b/cfp/forms.py index baef338..91b0cb1 100644 --- a/cfp/forms.py +++ b/cfp/forms.py @@ -457,6 +457,11 @@ class VolunteerForm(forms.ModelForm): def __init__(self, *args, **kwargs): self.conference = kwargs.pop('conference') super().__init__(*args, **kwargs) + activities = Activity.objects.filter(site=self.conference.site) + if activities.exists(): + self.fields['activities'].queryset = activities + else: + del self.fields['activities'] # we should manually check (site, email) uniqueness as the site is not part of the form def clean_email(self):