don't notify on participant registration
[prawokultury.git] / prawokultury / contact_forms.py
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 from django.conf import settings
5 from django import forms
6 from contact.forms import ContactForm
7 from contact.models import Contact
8 from contact.fields import HeaderField
9 from django.utils.functional import lazy
10 from django.utils.translation import ugettext_noop as _
11 from django.utils.safestring import mark_safe
12 from migdal.models import Entry
13
14 from prawokultury.countries import COUNTRIES
15
16 mark_safe_lazy = lazy(mark_safe, unicode)
17
18
19 class RegistrationForm(ContactForm):
20     form_tag = 'register'
21
22     save_as_tag = '2017'
23     conference_name = u'CopyCamp 2017'
24     notify_on_register = False
25     
26     form_title = _('Registration')
27     admin_list = ['first_name', 'last_name', 'organization']
28
29     first_name = forms.CharField(label=_('First name'), max_length=128)
30     last_name = forms.CharField(label=_('Last name'), max_length=128)
31     contact = forms.EmailField(label=_('E-mail'), max_length=128)
32     organization = forms.CharField(label=_('Organization'), 
33             max_length=256, required=False)
34     country = forms.ChoiceField(label=_('Country'), choices=zip(COUNTRIES, COUNTRIES))
35
36     days = forms.ChoiceField(
37        label=_("I'm planning to show up on"),
38        choices=[
39            ('both', _('Both days of the conference')),
40            ('only-28th', _('September 28th only')),
41            ('only-29th', _('September 29th only')),
42        ], widget=forms.RadioSelect())
43
44     # ankieta
45     times_attended = forms.ChoiceField(
46         required=False,
47         label=_("1. How many times have you attended CopyCamp?"),
48         choices=[
49             ('0', _('not yet')),
50             ('1', _('once')),
51             ('2', _('twice')),
52             ('3', _('three times')),
53             ('4', _('four times')),
54             ('5', _('five times')),
55         ], widget=forms.RadioSelect())
56     age = forms.ChoiceField(
57         required=False,
58         label=_("2. Please indicate your age bracket:"),
59         choices=[
60             ('0-19', _('19 or below')),
61             ('20-25', _('20-25')),
62             ('26-35', _('26-35')),
63             ('36-45', _('36-45')),
64             ('46-55', _('46-55')),
65             ('56-65', _('56-65')),
66             ('66+', _('66 or above')),
67         ], widget=forms.RadioSelect())
68     areas = forms.MultipleChoiceField(
69         required=False,
70         label=_("3. Please indicate up to 3 areas you feel most affiliated with"),
71         choices=[
72             ('sztuki plastyczne', _('visual art')),
73             ('literatura', _('literature')),
74             ('muzyka', _('music')),
75             ('teatr', _('theatre')),
76             ('film', _('film production')),
77             ('wydawanie', _('publishing')),
78             ('prawo', _('law')),
79             ('ekonomia', _('economy')),
80             ('socjologia', _('sociology')),
81             ('technika', _('technology')),
82             ('edukacja', _('education')),
83             ('studia', _('higher education')),
84             ('nauka', _('academic research')),
85             ('biblioteki', _('library science')),
86             ('administracja', _('public administration')),
87             ('ngo', _('nonprofit organisations')),
88             ('other', _('other (please specify below)')),
89         ], widget=forms.CheckboxSelectMultiple())
90     areas_other = forms.CharField(required=False, label=_('Fill if you selected “other” above'))
91     source = forms.ChoiceField(
92         required=False,
93         label=_("4. Please indicate how you received information about the conference:"),
94         choices=[
95             ('znajomi', _('through friends sharing on the web')),
96             ('znajomi2', _('through friends by other means')),
97             ('prasa', _('through press')),
98             ('fnp', _('directly through the Foundation\'s facebook or website')),
99             ('www', _('through other websites (please specify below)')),
100             ('other', _('other (please specify below)')),
101         ], widget=forms.RadioSelect())
102     source_other = forms.CharField(required=False, label=_('Fill if you selected “other” or “other website” above'))
103     motivation = forms.ChoiceField(
104         required=False,
105         label=_("6. Please indicate the most important factor for your willingness to participate:"),
106         choices=[
107             ('speaker', _('listening to particular speaker(s)')),
108             ('networking', _('good networking occasion')),
109             ('partnering', _('partnering with organisations present at the event')),
110             ('other', _('other (please specify below)')),
111         ], widget=forms.RadioSelect())
112     motivation_other = forms.CharField(required=False, label=_('Fill if you selected “other” above'))
113
114     agree_mailing = forms.BooleanField(
115         label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
116         required=False
117     )
118     agree_data = forms.BooleanField(
119         label=_('Permission for data processing'),
120         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.')
121     )
122     agree_license = forms.BooleanField(
123         label=_('Permission for publication'),
124         help_text=mark_safe_lazy(_(u'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\u00a0BY-SA</a> license and to publishing my image.')),
125         required=False
126     )
127
128     def __init__(self, *args, **kwargs):
129         super(RegistrationForm, self).__init__(*args, **kwargs)
130         self.started = getattr(settings, 'REGISTRATION_STARTED', False)
131         self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= settings.REGISTRATION_LIMIT
132         try:
133             url = Entry.objects.get(slug_pl='regulamin').get_absolute_url()
134             self.fields['agree_toc'] = forms.BooleanField(
135                 required=True,
136                 label=mark_safe(_('I accept <a href="%s">Terms and Conditions of CopyCamp</a>') % url)
137             )
138         except Entry.DoesNotExist:
139             pass
140
141     def clean_areas(self):
142         data = self.cleaned_data['areas']
143         if len(data) > 3:
144             raise forms.ValidationError(_('Select at most 3 areas'))
145         return data
146
147     def main_fields(self):
148         return [self[name] for name in ('first_name', 'last_name', 'contact', 'organization', 'country', 'days')]
149
150     def survey_fields(self):
151         return [self[name] for name in (
152             'times_attended', 'age',
153             'areas', 'areas_other', 'source', 'source_other', 'motivation', 'motivation_other')]
154
155     def agreement_fields(self):
156         return [self[name] for name in ('agree_mailing', 'agree_data', 'agree_license', 'agree_toc')]
157
158
159 tracks = (
160     (_('business models, heritage digitization, remix'),
161      _('What are the boundaries of appropriation in culture? '
162        'Who owns the past and whether these exclusive rights allow to '
163        'control present and future? How to make money from creativity without selling yourself?')),
164     (_('health, food, security, and exclusive rights'),
165      _('Who owns medicines and equipment necessary to provide health care? '
166        'Who owns grain and machines used to harvest it? '
167        'To what extent exclusive rights can affect what you eat, '
168        'how you exercise, whether you can apply a specific treatment?')),
169     (_('text and data mining, machine learning, online education'),
170      _('Do you think own the data you feed to algorithms? Or maybe you think you own these algorithms? '
171        'What if you can’t mine the data because you actually don’t own any of those rights? '
172        'What does it mean to own data about someone, or data necessary for that person’s education?')),
173     (_('IoT: autonomous cars, smart homes, wearables'),
174      _('What does it mean to own exclusive rights to software and data used to construct autonomous agents? '
175        'What will it mean in a near future?')),
176     (_('hacking government data, public procurement, public aid in culture'),
177      _('Who owns information created using public money? How can this information be appropriated? '
178        'What is the role of government in the development of information infrastructure?')),
179 )
180
181
182 class RegisterSpeaker(RegistrationForm):
183     form_tag = 'register-speaker'
184     save_as_tag = '2017-speaker'
185     form_title = _('Open call for presentations')
186     notify_on_register = False
187
188     # inherited fields included so they are not translated
189     first_name = forms.CharField(label=_('First name'), max_length=128)
190     last_name = forms.CharField(label=_('Last name'), max_length=128)
191     organization = forms.CharField(label=_('Organization'),
192             max_length=256, required=False)
193     agree_mailing = forms.BooleanField(
194         label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
195         required=False
196     )
197     agree_license = forms.BooleanField(
198         label=_('Permission for publication'),
199         help_text=mark_safe_lazy(_(u'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\u00a0BY-SA</a> license and to publishing my image.')),
200         required=False
201     )
202
203     presentation_thematic_track = forms.ChoiceField(
204         label=_('Please select one thematic track'),
205         choices=[(t, mark_safe('<strong>%s</strong><p style="margin-left: 20px;">%s</p>' % (t, desc))) for t, desc in tracks],
206         widget=forms.RadioSelect())
207
208     bio = forms.CharField(label=_('Short biographical note in English (max. 500 characters)'), widget=forms.Textarea,
209                           max_length=500, required=False)
210     photo = forms.FileField(label=_('Photo'), required=False)
211     phone = forms.CharField(label=_('Phone number'), max_length=64,
212                             required=False,
213                             help_text=_('Used only for organizational purposes.'))
214
215     presentation_title = forms.CharField(
216         label=mark_safe_lazy(_('Title of the presentation in English')),
217         max_length=256, required=False)
218     presentation_summary = forms.CharField(label=_('Summary of presentation (max. 1800 characters)'),
219                                            widget=forms.Textarea, max_length=1800)
220
221     # presentation_post_conference_publication = forms.BooleanField(
222     #     label=_('I am interested in including my paper in the post-conference publication'),
223     #     required=False
224     # )
225
226     agree_data = None
227
228     agree_terms = forms.BooleanField(
229         label=mark_safe_lazy(_(u'I accept <a href="/en/info/terms-and-conditions/">'
230                                u'CopyCamp Terms and Conditions</a>.'))
231     )
232
233     # workshop = forms.BooleanField(label=_('Workshop'), required=False)
234     # workshop_title = forms.CharField(label=_('Title of workshop'),
235     #        max_length=256, required=False)
236     # workshop_summary = forms.CharField(label=_('Summary of workshop (max. 1800 characters)'),
237     #        widget=forms.Textarea, max_length=1800, required=False)
238
239     def __init__(self, *args, **kw):
240         super(RegisterSpeaker, self).__init__(*args, **kw)
241         self.started = getattr(settings, 'REGISTRATION_SPEAKER_STARTED', False)
242         self.closed = getattr(settings, 'REGISTRATION_SPEAKER_CLOSED', False)
243         self.fields.keyOrder = [
244             'first_name',
245             'last_name',
246             'contact',
247             'phone',
248             'organization',
249             'bio',
250             'photo',
251             'presentation_title',
252             'presentation_summary',
253             'presentation_thematic_track',
254             # 'presentation_post_conference_publication',
255             # 'workshop',
256             # 'workshop_title',
257             # 'workshop_summary',
258
259             'agree_mailing',
260             # 'agree_data',
261             'agree_license',
262             'agree_terms',
263         ]
264
265
266 class RemindForm(ContactForm):
267     form_tag = 'remind-me'
268     save_as_tag = 'remind-me-2017'
269     form_title = u'CopyCamp 2017'
270     notify_on_register = False
271     notify_user = False
272
273
274 class NextForm(ContactForm):
275     form_tag = '/next'
276     form_title = _('Next CopyCamp')
277
278     name = forms.CharField(label=_('Name'), max_length=128)
279     contact = forms.EmailField(label=_('E-mail'), max_length=128)
280     organization = forms.CharField(label=_('Organization'),
281                                    max_length=256, required=False)
282
283
284 class WorkshopForm(ContactForm):
285     form_tag = 'workshops'
286     save_as_tag = 'workshops-2017'
287     conference_name = u'CopyCamp 2017'
288     form_title = _('Workshop')
289
290     name = forms.CharField(label=_('Name'), max_length=128)
291     contact = forms.EmailField(label=_('E-mail'), max_length=128)
292     organization = forms.CharField(label=_('Organization'),
293                                    max_length=256, required=False)
294     country = forms.CharField(label=_('Country'), max_length=128)
295
296     _header = HeaderField(
297         label=mark_safe_lazy(_("<h3>I'll take a part in workshops</h3>")),
298         help_text=_('Only workshops with any spots left are visible here.'))
299
300     _h1 = HeaderField(label=mark_safe_lazy(_("<strong>Thursday, October 27th, 10 a.m.–12 noon</strong>")))
301
302     w_dimitrov = forms.BooleanField(label=_(u'Dimitar Dimitrov: Hacking Brussels'), required=False)
303     w_vangompel = forms.BooleanField(label=_(
304         u'Stef van Gompel: Methods and constraints for including evidence in IP lawmaking'), required=False)
305
306     _h2 = HeaderField(label=mark_safe_lazy(_("<strong>Friday, October 28th, 10 a.m.–12 noon</strong>")))
307
308     w_siewicz = forms.BooleanField(label=_(
309         u'dr Krzysztof Siewicz, dr Marta Hoffman-Sommer: '
310         u'Legal aspects of using research data in the age of Open Data'), required=False)
311     w_siewicz_project = forms.CharField(
312         label=mark_safe(
313             u'<p style="margin-top: 0"><strong>Qualification for this workshop will be based on the answers '
314             u'for the following problem:</strong></p>'
315             u'Please choose a particular dataset from any research project you are involved in and provide '
316             u'a description (no more than 1800 characters). Selected datasets will be discussed during '
317             u'the workshop as case studies. In your description, please include the following information: '
318             u'What is the research goal of the project (in the context of the chosen dataset)? '
319             u'What data is being collected and how is it stored? What is the process of data collection '
320             u'or generation? Who is involved in collecting or producing the data and in what manner?'),
321         max_length=1800, widget=forms.Textarea, required=False)
322     w_google = forms.BooleanField(label=_(
323         u'Marcin Olender, Google: Prawo autorskie na YouTube (workshop in Polish)'), required=False)
324
325     _h3 = HeaderField(label=mark_safe_lazy(_("<strong>Friday, October 28th, 12 noon–2 p.m.</strong>")))
326
327     w_patronite = forms.BooleanField(label=_(
328         u'Mateusz Górski, Michał Leksiński, Patronite: Jak zarabiać i się nie sprzedać – warsztaty dla twórców '
329         u'(workshop in Polish)'),
330         required=False)
331
332     w_gurionova = forms.BooleanField(label=_(
333         u'Olga Goriunova: The Lurker and the politics of knowledge in data culture'), required=False)
334
335     _header_1 = HeaderField(label='')
336
337     start_workshops = ('dimitrov', 'vangompel', 'siewicz', 'google', 'patronite', 'gurionova')
338
339     slots = (('_h1', 'dimitrov', 'vangompel'), ('_h2', 'siewicz', 'google'), ('_h3', 'patronite', 'gurionova'))
340
341     agree_mailing = forms.BooleanField(
342         label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
343         required=False)
344     agree_data = forms.BooleanField(
345         label=_('Permission for data processing'),
346         help_text=_(
347             u'I hereby grant Modern Poland Foundation (Fundacja Nowoczesna Polska, ul. Marszałkowska 84/92, '
348             u'00-514 Warszawa) permission to process my personal data (name, e-mail address) for purposes of '
349             u'registration for CopyCamp conference.'))
350     agree_license = forms.BooleanField(
351         label=_('Permission for publication'),
352         help_text=mark_safe_lazy(_(
353             u'I agree to having materials, recorded during the conference, released under the terms of '
354             u'<a href="http://creativecommons.org/licenses/by-sa/3.0/deed">CC\u00a0BY-SA</a> '
355             u'license and to publishing my image.')),
356         required=False)
357
358     def __init__(self, *args, **kwargs):
359         super(WorkshopForm, self).__init__(*args, **kwargs)
360         # self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= 60
361         try:
362             url = Entry.objects.get(slug_pl='regulamin').get_absolute_url()
363             self.fields['agree_toc'] = forms.BooleanField(
364                 required=True,
365                 label=mark_safe(_('I accept <a href="%s">Terms and Conditions of CopyCamp</a>') % url)
366             )
367         except Entry.DoesNotExist:
368             pass
369         counts = {k: 0 for k in self.start_workshops}
370         for contact in Contact.objects.filter(form_tag=self.save_as_tag):
371             for workshop in self.start_workshops:
372                 if contact.body.get('w_%s' % workshop, False): counts[workshop] += 1
373         some_full = False
374         for k, v in counts.items():
375             if v >= 30:
376                 some_full = True
377                 if 'w_%s' % k in self.fields:
378                     del self.fields['w_%s' % k]
379                 # if k in self.workshops:
380                 #     self.workshops.remove(k)
381         if not some_full:
382             self.fields['_header'].help_text = None
383
384     def clean(self):
385         if self.cleaned_data.get('w_siewicz') and not self.cleaned_data.get('w_siewicz_project'):
386             self._errors['w_siewicz_project'] = [_("Please submit your answer to qualify for this workshop")]
387         for slot in self.slots:
388             if sum(1 for w in slot if self.cleaned_data.get('w_%s' % w)) > 1:
389                 self._errors[slot[0]] = [_("You can't choose more than one workshop during the same period")]
390         if not any(self.cleaned_data.get('w_%s' % w) for w in self.start_workshops):
391             self._errors['_header'] = [_("Please choose at least one workshop.")]
392         return self.cleaned_data