registration link for speakers only when active
authorJan Szejko <janek37@gmail.com>
Mon, 19 Sep 2016 13:17:52 +0000 (15:17 +0200)
committerJan Szejko <janek37@gmail.com>
Mon, 19 Sep 2016 13:17:52 +0000 (15:17 +0200)
prawokultury/contact_forms.py
prawokultury/context_processors.py [new file with mode: 0644]
prawokultury/settings.d/40-context.py
prawokultury/templates/base.html

index 60ef542..009bd45 100644 (file)
@@ -220,6 +220,7 @@ class RegisterSpeaker(RegistrationForm):
 
     def __init__(self, *args, **kw):
         super(RegisterSpeaker, self).__init__(*args, **kw)
 
     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',
         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 (file)
index 0000000..7e8713c
--- /dev/null
@@ -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}
index fe0dd19..90231de 100644 (file)
@@ -7,4 +7,5 @@ TEMPLATE_CONTEXT_PROCESSORS = (
     "django.core.context_processors.tz",
     "django.contrib.messages.context_processors.messages",
     'django.core.context_processors.request',
     "django.core.context_processors.tz",
     "django.contrib.messages.context_processors.messages",
     'django.core.context_processors.request',
+    'prawokultury.context_processors.registration_url',
 )
 )
index fbb3d76..8c80fc9 100755 (executable)
@@ -56,7 +56,7 @@
             {% endblock %}
             <li id="item-lang">{% lang_switcher %}</li>
         </ul>
             {% endblock %}
             <li id="item-lang">{% lang_switcher %}</li>
         </ul>
-        <a href="{% url "contact_form" "register-speaker" %}" style="float: right; margin: 0 10px; width: 220px; text-align:center; background: #ED7F00; color: white; font-size: 24px; text-transform: uppercase;">{% trans "Registration" %}</a>
+        <a href="{{ REGISTRATION_URL }}" style="float: right; margin: 0 10px; width: 220px; text-align:center; background: #ED7F00; color: white; font-size: 24px; text-transform: uppercase;">{% trans "Registration" %}</a>
         <div style="clear: both;"></div>
         </div>
 
         <div style="clear: both;"></div>
         </div>