Skip to content
Snippets Groups Projects
Commit a48e4118 authored by Felix Schäfer's avatar Felix Schäfer :construction_worker:
Browse files

Favor quick returns over long if-else

parent 94affd1e
Branches
No related tags found
No related merge requests found
...@@ -22,39 +22,36 @@ settings_hierarkey.add_default('public_registrations_show_item_name', False, boo ...@@ -22,39 +22,36 @@ settings_hierarkey.add_default('public_registrations_show_item_name', False, boo
@receiver(html_head, dispatch_uid="public_registrations_html_head") @receiver(html_head, dispatch_uid="public_registrations_html_head")
def add_public_registrations_html_head(sender, request=None, **kwargs): def add_public_registrations_html_head(sender, request=None, **kwargs):
url = resolve(request.path_info) url = resolve(request.path_info)
if "event.index" in url.url_name: if "event.index" not in url.url_name: return ""
cached = sender.cache.get('public_registrations_html_head') cached = sender.cache.get('public_registrations_html_head')
if cached is None: if cached is None:
cached = get_template("pretix_public_registrations/head.html").render() cached = get_template("pretix_public_registrations/head.html").render()
sender.cache.set('public_registrations_html_head', cached) sender.cache.set('public_registrations_html_head', cached)
return cached return cached
else:
return ""
@receiver(question_form_fields, dispatch_uid="public_registration_question") @receiver(question_form_fields, dispatch_uid="public_registration_question")
def add_public_registration_question(sender, position, **kwargs): def add_public_registration_question(sender, position, **kwargs):
if str(position.item.pk) in sender.settings.get('public_registrations_items'): if str(position.item.pk) not in sender.settings.get('public_registrations_items'):
public_questions = sender.questions.filter(
pk__in=sender.settings.get('public_registrations_questions')
)
headers = (
[_("Product")] if sender.settings.get('public_registrations_show_item_name') else []
) + (
[_("Name")] if sender.settings.get('public_registrations_show_attendee_name') else []
) + [
q.question for q in public_questions
]
return {'public_registrations_public_registration': forms.BooleanField(
label=_('Public registration'),
required=False,
help_text=_(
'A gravatar image based on a hash of your e-mail address as well as the answers to '
'the following questions will be publicly shown: %(qlist)s'
) % {'qlist': ", ".join(str(h) for h in headers)},
)}
else:
return {} return {}
public_questions = sender.questions.filter(
pk__in=sender.settings.get('public_registrations_questions')
)
headers = (
[_("Product")] if sender.settings.get('public_registrations_show_item_name') else []
) + (
[_("Name")] if sender.settings.get('public_registrations_show_attendee_name') else []
) + [
q.question for q in public_questions
]
return {'public_registrations_public_registration': forms.BooleanField(
label=_('Public registration'),
required=False,
help_text=_(
'A gravatar image based on a hash of your e-mail address as well as the answers to '
'the following questions will be publicly shown: %(qlist)s'
) % {'qlist': ", ".join(str(h) for h in headers)},
)}
@receiver(signal=front_page_bottom, dispatch_uid="public_registrations_table") @receiver(signal=front_page_bottom, dispatch_uid="public_registrations_table")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment