Changing registration form.
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Wed, 2 Apr 2014 14:39:51 +0000 (16:39 +0200)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Wed, 2 Apr 2014 14:39:51 +0000 (16:39 +0200)
contact/forms.py
prawokultury/contact_forms.py
prawokultury/locale/pl/LC_MESSAGES/django.mo
prawokultury/locale/pl/LC_MESSAGES/django.po
prawokultury/templates/contact/register/form.html
prawokultury/templates/contact/register/mail_body.txt

index 142d209..4199dd7 100644 (file)
@@ -27,7 +27,9 @@ class ContactForm(forms.Form):
     """Subclass and define some fields."""
     __metaclass__ = ContactFormMeta
 
     """Subclass and define some fields."""
     __metaclass__ = ContactFormMeta
 
+    started = False
     form_tag = None
     form_tag = None
+    save_as_tag = None
     form_title = _('Contact form')
     submit_label = _('Submit')
     admin_list = None
     form_title = _('Contact form')
     submit_label = _('Submit')
     admin_list = None
@@ -40,10 +42,11 @@ class ContactForm(forms.Form):
         for name, value in self.cleaned_data.items():
             if not isinstance(value, UploadedFile) and name != 'contact':
                     body[name] = value
         for name, value in self.cleaned_data.items():
             if not isinstance(value, UploadedFile) and name != 'contact':
                     body[name] = value
+        save_as_tag = self.save_as_tag or self.form_tag
         contact = Contact.objects.create(body=body,
                     ip=request.META['REMOTE_ADDR'],
                     contact=self.cleaned_data['contact'],
         contact = Contact.objects.create(body=body,
                     ip=request.META['REMOTE_ADDR'],
                     contact=self.cleaned_data['contact'],
-                    form_tag=self.form_tag)
+                    form_tag=self.save_as_tag)
         for name, value in self.cleaned_data.items():
             if isinstance(value, UploadedFile):
                 attachment = Attachment(contact=contact, tag=name)
         for name, value in self.cleaned_data.items():
             if isinstance(value, UploadedFile):
                 attachment = Attachment(contact=contact, tag=name)
@@ -56,6 +59,7 @@ class ContactForm(forms.Form):
             'site_name': site.name,
             'site_domain': site.domain,
             'contact': contact,
             'site_name': site.name,
             'site_domain': site.domain,
             'contact': contact,
+            'form': self,
         }
         context = RequestContext(request)
         mail_managers_subject = render_to_string([
         }
         context = RequestContext(request)
         mail_managers_subject = render_to_string([
index bb6a54c..a50840e 100644 (file)
@@ -8,6 +8,10 @@ from django.utils.translation import ugettext_lazy as _
 
 class RegistrationForm(ContactForm):
     form_tag = 'register'
 
 class RegistrationForm(ContactForm):
     form_tag = 'register'
+
+    save_as_tag = '2014'
+    conference_name = u'CopyCamp 2014' 
+    
     form_title = _('Take part!')
     admin_list = ['name', 'organization', 'title']
 
     form_title = _('Take part!')
     admin_list = ['name', 'organization', 'title']
 
@@ -16,11 +20,11 @@ class RegistrationForm(ContactForm):
     organization = forms.CharField(label=_('Organization'), 
             max_length=256, required=False)
     title = forms.CharField(label=_('Title of presentation'), 
     organization = forms.CharField(label=_('Organization'), 
             max_length=256, required=False)
     title = forms.CharField(label=_('Title of presentation'), 
-            max_length=256, required=False, widget = forms.HiddenInput)
+            max_length=256, required=False)
     presentation = forms.FileField(label=_('Presentation'),
     presentation = forms.FileField(label=_('Presentation'),
-            required=False, widget = forms.HiddenInput)
+            required=False)
     summary = forms.CharField(label=_('Summary of presentation (max. 1800 characters)'),
     summary = forms.CharField(label=_('Summary of presentation (max. 1800 characters)'),
-            widget=forms.HiddenInput, max_length=1800, required=False)
+            max_length=1800, required=False)
     agree_data = forms.BooleanField(
         label=_('Permission for data processing'),
         help_text=_(u'I hereby grant Modern Poland Foundation (Fundacja Nowoczesna Polska, ul. Marszałkowska 84/92, 00-514 Warszawa) permission to process my personal data (name, e-mail address) for purposes of registration for CopyCamp conference.')
     agree_data = forms.BooleanField(
         label=_('Permission for data processing'),
         help_text=_(u'I hereby grant Modern Poland Foundation (Fundacja Nowoczesna Polska, ul. Marszałkowska 84/92, 00-514 Warszawa) permission to process my personal data (name, e-mail address) for purposes of registration for CopyCamp conference.')
@@ -32,10 +36,17 @@ class RegistrationForm(ContactForm):
 
     def __init__(self, *args, **kwargs):
         super(RegistrationForm, self).__init__(*args, **kwargs)
 
     def __init__(self, *args, **kwargs):
         super(RegistrationForm, self).__init__(*args, **kwargs)
-        self.limit_reached = Contact.objects.filter(form_tag=self.form_tag).count() >= settings.REGISTRATION_LIMIT
+
+        self.started = getattr(settings, 'REGISTRATION_STARTED', False)
+        self.open_call = getattr(settings, 'REGISTRATION_OPEN_CALL', False)
+        self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= settings.REGISTRATION_LIMIT
         if self.limit_reached:
             for field in ('title', 'summary'):
                 self.fields[field].required = True
         if self.limit_reached:
             for field in ('title', 'summary'):
                 self.fields[field].required = True
+        if not self.open_call:
+            for field in ('title', 'summary', 'presentation'):
+                del self.fields[field]
+            
 
 class NextForm(ContactForm):
     form_tag = 'next'
 
 class NextForm(ContactForm):
     form_tag = 'next'
index 9d25776..f5344dc 100644 (file)
Binary files a/prawokultury/locale/pl/LC_MESSAGES/django.mo and b/prawokultury/locale/pl/LC_MESSAGES/django.mo differ
index dbeb717..2f92a5b 100644 (file)
@@ -7,50 +7,50 @@ msgid ""
 msgstr ""
 "Project-Id-Version: prawokultury\n"
 "Report-Msgid-Bugs-To: \n"
 msgstr ""
 "Project-Id-Version: prawokultury\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-09-12 12:00+0200\n"
-"PO-Revision-Date: 2012-11-08 11:22+0100\n"
+"POT-Creation-Date: 2014-04-02 16:10+0200\n"
+"PO-Revision-Date: 2014-04-02 16:11+0100\n"
 "Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
 "Language-Team: FNP <fundacja@nowoczesnapolska.org.pl>\n"
 "Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
 "Language-Team: FNP <fundacja@nowoczesnapolska.org.pl>\n"
-"Language: \n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
-"|| n%100>=20) ? 1 : 2)\n"
+"|| n%100>=20) ? 1 : 2);\n"
+"X-Generator: Poedit 1.5.4\n"
 
 
-#: contact_forms.py:11 menu_items.py:22
+#: contact_forms.py:16 menu_items.py:22
 msgid "Take part!"
 msgstr "Weź udział!"
 
 msgid "Take part!"
 msgstr "Weź udział!"
 
-#: contact_forms.py:14
+#: contact_forms.py:19 contact_forms.py:49
 msgid "Name"
 msgstr "Imię i nazwisko"
 
 msgid "Name"
 msgstr "Imię i nazwisko"
 
-#: contact_forms.py:15
+#: contact_forms.py:20 contact_forms.py:50
 msgid "E-mail"
 msgstr "E-mail"
 
 msgid "E-mail"
 msgstr "E-mail"
 
-#: contact_forms.py:16
+#: contact_forms.py:21 contact_forms.py:51
 msgid "Organization"
 msgstr "Organizacja"
 
 msgid "Organization"
 msgstr "Organizacja"
 
-#: contact_forms.py:18
+#: contact_forms.py:23
 msgid "Title of presentation"
 msgstr "Tytuł prezentacji"
 
 msgid "Title of presentation"
 msgstr "Tytuł prezentacji"
 
-#: contact_forms.py:20
+#: contact_forms.py:25
 msgid "Presentation"
 msgstr "Prezentacja"
 
 msgid "Presentation"
 msgstr "Prezentacja"
 
-#: contact_forms.py:22
+#: contact_forms.py:27
 msgid "Summary of presentation (max. 1800 characters)"
 msgstr "Krótki opis prezentacji (maks. 1800 znaków)"
 
 msgid "Summary of presentation (max. 1800 characters)"
 msgstr "Krótki opis prezentacji (maks. 1800 znaków)"
 
-#: contact_forms.py:25
+#: contact_forms.py:30
 msgid "Permission for data processing"
 msgstr "Zgoda na przetwarzanie danych"
 
 msgid "Permission for data processing"
 msgstr "Zgoda na przetwarzanie danych"
 
-#: contact_forms.py:26
+#: contact_forms.py:31
 msgid ""
 "I hereby grant Modern Poland Foundation (Fundacja Nowoczesna Polska, ul. "
 "Marszałkowska 84/92, 00-514 Warszawa) permission to process my personal data "
 msgid ""
 "I hereby grant Modern Poland Foundation (Fundacja Nowoczesna Polska, ul. "
 "Marszałkowska 84/92, 00-514 Warszawa) permission to process my personal data "
@@ -60,11 +60,11 @@ msgstr ""
 "poczty elektronicznej) przez Fundację Nowoczesna Polska (ul. Marszałkowska "
 "84/92, 00-514 Warszawa) w związku z rejestracją na konferencję CopyCamp."
 
 "poczty elektronicznej) przez Fundację Nowoczesna Polska (ul. Marszałkowska "
 "84/92, 00-514 Warszawa) w związku z rejestracją na konferencję CopyCamp."
 
-#: contact_forms.py:29
+#: contact_forms.py:34
 msgid "Permission for publication"
 msgstr "Zgoda na publikację"
 
 msgid "Permission for publication"
 msgstr "Zgoda na publikację"
 
-#: contact_forms.py:30
+#: contact_forms.py:35
 msgid ""
 "I agree to having materials recorded during the conference released under "
 "the terms of <a href=\"http://creativecommons.org/licenses/by-sa/3.0/deed"
 msgid ""
 "I agree to having materials recorded during the conference released under "
 "the terms of <a href=\"http://creativecommons.org/licenses/by-sa/3.0/deed"
@@ -74,9 +74,13 @@ msgstr ""
 "licencji <a href=\"http://creativecommons.org/licenses/by-sa/3.0/deed.pl"
 "\">CC BY-SA</a>."
 
 "licencji <a href=\"http://creativecommons.org/licenses/by-sa/3.0/deed.pl"
 "\">CC BY-SA</a>."
 
+#: contact_forms.py:47
+msgid "Next CopyCamp"
+msgstr "Kolejny CopyCamp"
+
 #: settings.d/60-custom.py:5
 msgid "info"
 #: settings.d/60-custom.py:5
 msgid "info"
-msgstr ""
+msgstr "info"
 
 #: templates/404.html:5 templates/404.html.py:10
 msgid "Page not found"
 
 #: templates/404.html:5 templates/404.html.py:10
 msgid "Page not found"
@@ -112,26 +116,27 @@ msgstr ""
 "href='http://creativecommons.org/licenses/by-sa/3.0/deed.pl'>Creative "
 "Commons Uznanie autorstwa – Na tych samych warunkach</a>."
 
 "href='http://creativecommons.org/licenses/by-sa/3.0/deed.pl'>Creative "
 "Commons Uznanie autorstwa – Na tych samych warunkach</a>."
 
-#: templates/contact/register/mail_body.txt:2
-#: templates/contact/register/mail_subject.txt:1
+#: templates/contact/register/mail_body.txt:4
 #, python-format
 #, python-format
-msgid "Thank you for submitting the registration form at %(site_name)s."
-msgstr ""
-"Dziękujemy za wypełnienie formularza rejestracyjnego na stronie "
-"%(site_name)s."
-
-#: templates/contact/register/mail_body.txt:3
 msgid ""
 msgid ""
-"Thank you for registering to the CopyCamp 2013 conference.\n"
+"Thank you for registering to the %(conf)s conference.\n"
 "Please arrive early to obtain your name badge and conference materials."
 msgstr ""
 "Please arrive early to obtain your name badge and conference materials."
 msgstr ""
-"Dziękujemy za rejestrację na konferencję CopyCamp 2013."
-"Prosimy o wcześniejsze przybycie w celu otrzymania identyfikatora i materiałów konferencyjnych."
+"Dziękujemy za rejestrację na konferencję %(conf)s.\n"
+"Prosimy o wcześniejsze przybycie w celu otrzymania identyfikatora i "
+"materiałów konferencyjnych."
 
 
-#: templates/contact/register/mail_body.txt:7
+#: templates/contact/register/mail_body.txt:8
 msgid "Message sent automatically. Please do not reply to it."
 msgstr "Wiadomość wysłana automatycznie, prosimy nie odpowiadać."
 
 msgid "Message sent automatically. Please do not reply to it."
 msgstr "Wiadomość wysłana automatycznie, prosimy nie odpowiadać."
 
+#: templates/contact/register/mail_subject.txt:1
+#, python-format
+msgid "Thank you for submitting the registration form at %(site_name)s."
+msgstr ""
+"Dziękujemy za wypełnienie formularza rejestracyjnego na stronie "
+"%(site_name)s."
+
 #: templates/contact/register/thanks.html:5
 msgid "Thank you for submitting the registration form."
 msgstr "Dziękujemy za wypełnienie formularza rejestracyjnego."
 #: templates/contact/register/thanks.html:5
 msgid "Thank you for submitting the registration form."
 msgstr "Dziękujemy za wypełnienie formularza rejestracyjnego."
index 2c19f4d..516fcfe 100644 (file)
     {% endblock %}
     </div>
 
     {% endblock %}
     </div>
 
-  {% if form.limit_reached %}
+{% if not form.started %}
+  {# Not yet started. #}
+  <div class="warning">
+    {% chunk "contact_form__"|add:form.form_tag|add:"__not_started" %}
+  </div>
+{% else %}
+  {# Already started. #}
+  {% if form.limit_reached and not form.open_call %}
+    {# Already closed. #}
     <div class="warning">
     <div class="warning">
-        {% chunk "contact_form__"|add:form.form_tag|add:"__full" %}
+      {% chunk "contact_form__"|add:form.form_tag|add:"__closed" %}
     </div>
   {% else %}
     </div>
   {% else %}
+    {# Still running. #}
+    {% if form.limit_reached %}
+      {# Only taking presentation submissions. #}
+      <div class="warning">
+        {% chunk "contact_form__"|add:form.form_tag|add:"__presentations_only" %}
+      </div>
+    {% else %}
+      {% if not form.open_call %}
+      {# Not taking presentations any more. #}
+      <div class="warning">
+        {% chunk "contact_form__"|add:form.form_tag|add:"__no_presentations" %}
+      </div>
+      {% else %}
+        <div class="warning">
+          {% chunk "contact_form__"|add:form.form_tag|add:"__running" %}
+        </div>
+      {% endif %}
+    {% endif %}
+
     <form method="POST" action="." enctype="multipart/form-data" class="submit-form">
     <form method="POST" action="." enctype="multipart/form-data" class="submit-form">
-    {% csrf_token %}
-    <table>
+      {% csrf_token %}
+      <table>
         {{ form.as_table }}
         <tr><td></td><td><button>{% block contact_form_submit %}{{ form.submit_label }}{% endblock %}</button></td></tr>
         {{ form.as_table }}
         <tr><td></td><td><button>{% block contact_form_submit %}{{ form.submit_label }}{% endblock %}</button></td></tr>
-    </table>
+      </table>
     </form>
   {% endif %}
     </form>
   {% endif %}
-   <script type="text/javascript" src="/static/js/prefill.js"></script>
+{% endif %}
+
+<script type="text/javascript" src="/static/js/prefill.js"></script>
 
 {% endblock %}
 
 {% endblock %}
index 2c256cc..3d5cbed 100755 (executable)
@@ -1,6 +1,6 @@
 {% load i18n %}
 {% comment %}{% blocktrans %}Thank you for submitting the registration form at {{ site_name }}.{% endblocktrans %}{% endcomment %}
 {% load i18n %}
 {% comment %}{% blocktrans %}Thank you for submitting the registration form at {{ site_name }}.{% endblocktrans %}{% endcomment %}
-{% blocktrans %}Thank you for registering to the CopyCamp 2013 conference.
+{% blocktrans with conf=form.conference_name %}Thank you for registering to the {{conf}} conference.
 Please arrive early to obtain your name badge and conference materials.{% endblocktrans %}
 
 -- 
 Please arrive early to obtain your name badge and conference materials.{% endblocktrans %}
 
 --