From 94affd1ea0561aeb343a0c1af899ebc9d4a1cd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= <felix@thegcat.net> Date: Sat, 25 Apr 2020 23:21:54 +0200 Subject: [PATCH] Fix caching of html_head Previously the result of the first run was cached, subsequent calls would receive the same result as the first call independently of the conditional --- pretix_public_registrations/signals.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pretix_public_registrations/signals.py b/pretix_public_registrations/signals.py index dadb362..d3c3501 100644 --- a/pretix_public_registrations/signals.py +++ b/pretix_public_registrations/signals.py @@ -21,16 +21,15 @@ settings_hierarkey.add_default('public_registrations_show_item_name', False, boo @receiver(html_head, dispatch_uid="public_registrations_html_head") def add_public_registrations_html_head(sender, request=None, **kwargs): - cached = sender.cache.get('public_registrations_html_head') - if cached is None: - url = resolve(request.path_info) - if "event.index" in url.url_name: - template = get_template("pretix_public_registrations/head.html") - cached = template.render() - else: - cached = "" + url = resolve(request.path_info) + if "event.index" in url.url_name: + cached = sender.cache.get('public_registrations_html_head') + if cached is None: + cached = get_template("pretix_public_registrations/head.html").render() sender.cache.set('public_registrations_html_head', cached) - return cached + return cached + else: + return "" @receiver(question_form_fields, dispatch_uid="public_registration_question") -- GitLab