From 979ff24d5dcb7d85d1f38ed980a268f67c12b9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= <felix@thegcat.net> Date: Mon, 9 Sep 2019 21:30:31 +0200 Subject: [PATCH] Only show public registration question for selected items --- pretix_public_registrations/signals.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pretix_public_registrations/signals.py b/pretix_public_registrations/signals.py index 940ae47..f9ee172 100644 --- a/pretix_public_registrations/signals.py +++ b/pretix_public_registrations/signals.py @@ -30,13 +30,17 @@ def add_public_registrations_html_head(sender, request=None, **kwargs): @receiver(question_form_fields, dispatch_uid="public_registration_question") -def add_public_registration_question(sender, **kwargs): - return {'public_registration': forms.CharField( - label=_('Public registration'), - required=False, - help_text=sender.settings.get('public_registration_field_help_text', as_type=LazyI18nString), - widget=forms.CheckboxInput(), - )} +def add_public_registration_question(sender, position, **kwargs): + # TODO: This should also filter by items with an attendee + if str(position.item.pk) in sender.settings.get('public_registrations_items'): + return {'public_registration': forms.CharField( + label=_('Public registration'), + required=False, + help_text=sender.settings.get('public_registrations_field_help_text', as_type=LazyI18nString), + widget=forms.CheckboxInput(), + )} + else: + return {} @receiver(signal=front_page_bottom, dispatch_uid="public_registrations_table") -- GitLab