registration limit
[prawokultury.git] / prawokultury / contact_forms.py
1 # -*- coding: utf-8 -*-
2 from django.conf import settings
3 from django import forms
4 from contact.forms import ContactForm
5 from contact.models import Contact
6 from django.utils.translation import ugettext_lazy as _
7
8
9 class RegistrationForm(ContactForm):
10     form_tag = 'register'
11     form_title = _('Take part!')
12
13     name = forms.CharField(label=_('Name'), max_length=128)
14     contact = forms.EmailField(label=_('E-mail'), max_length=128)
15     organization = forms.CharField(label=_('Organization'), 
16             max_length=256, required=False)
17     title = forms.CharField(label=_('Title of presentation'), 
18             max_length=256, required=False)
19     presentation = forms.FileField(label=_('Presentation'),
20             required=False)
21     summary = forms.CharField(label=_('Summary of presentation (max. 1800 characters)'),
22             widget=forms.Textarea, max_length=1800, required=False)
23     agree_data = forms.BooleanField(
24         label=_('Permission for data processing'),
25         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.')
26     )
27     agree_license = forms.BooleanField(
28         label=_('Permission for publication'),
29         help_text=_('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">CC BY-SA</a> license.')
30     )
31
32     def __init__(self, *args, **kwargs):
33         super(RegistrationForm, self).__init__(*args, **kwargs)
34         self.limit_reached = Contact.objects.all().count() >= settings.REGISTRATION_LIMIT
35         if self.limit_reached:
36             for field in ('title', 'summary'):
37                 self.fields[field].required = True