From ebc2f30757c39ad8decccbe020f4a721130534df Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Mon, 19 Sep 2016 15:17:52 +0200 Subject: [PATCH] registration link for speakers only when active --- prawokultury/contact_forms.py | 1 + prawokultury/context_processors.py | 12 ++++++++++++ prawokultury/settings.d/40-context.py | 1 + prawokultury/templates/base.html | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 prawokultury/context_processors.py diff --git a/prawokultury/contact_forms.py b/prawokultury/contact_forms.py index 60ef542..009bd45 100644 --- a/prawokultury/contact_forms.py +++ b/prawokultury/contact_forms.py @@ -220,6 +220,7 @@ class RegisterSpeaker(RegistrationForm): def __init__(self, *args, **kw): super(RegisterSpeaker, self).__init__(*args, **kw) + self.started = getattr(settings, 'REGISTRATION_SPEAKER_STARTED', False) self.closed = getattr(settings, 'REGISTRATION_SPEAKER_CLOSED', False) self.fields.keyOrder = [ 'first_name', diff --git a/prawokultury/context_processors.py b/prawokultury/context_processors.py new file mode 100644 index 0000000..7e8713c --- /dev/null +++ b/prawokultury/context_processors.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +from django.core.urlresolvers import reverse +from .contact_forms import RegisterSpeaker + + +def registration_url(request): + speaker_form = RegisterSpeaker() + if speaker_form.started and not speaker_form.closed: + url = reverse("contact_form", args=["register-speaker"]) + else: + url = reverse("contact_form", args=["register"]) + return {'REGISTRATION_URL': url} diff --git a/prawokultury/settings.d/40-context.py b/prawokultury/settings.d/40-context.py index fe0dd19..90231de 100644 --- a/prawokultury/settings.d/40-context.py +++ b/prawokultury/settings.d/40-context.py @@ -7,4 +7,5 @@ TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.tz", "django.contrib.messages.context_processors.messages", 'django.core.context_processors.request', + 'prawokultury.context_processors.registration_url', ) diff --git a/prawokultury/templates/base.html b/prawokultury/templates/base.html index fbb3d76..8c80fc9 100755 --- a/prawokultury/templates/base.html +++ b/prawokultury/templates/base.html @@ -56,7 +56,7 @@ {% endblock %}
  • {% lang_switcher %}
  • - {% trans "Registration" %} + {% trans "Registration" %}
    -- 2.20.1