1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
4 from django.conf import settings
5 from django import forms
6 from django.core.mail import send_mail
8 from contact.forms import ContactForm
9 from contact.models import Contact
10 from contact.fields import HeaderField
11 from django.utils.functional import lazy
12 from django.utils.translation import ugettext_lazy as _
13 from django.utils.safestring import mark_safe
14 from migdal.models import Entry
16 from prawokultury.countries import COUNTRIES, TRAVEL_GRANT_COUNTRIES
18 mark_safe_lazy = lazy(mark_safe, unicode)
21 class RegistrationForm(ContactForm):
25 conference_name = u'CopyCamp 2019'
26 notify_on_register = False
28 form_title = _('Registration')
29 admin_list = ['first_name', 'last_name', 'organization']
31 first_name = forms.CharField(label=_('First name'), max_length=128)
32 last_name = forms.CharField(label=_('Last name'), max_length=128)
33 contact = forms.EmailField(label=_('E-mail'), max_length=128)
34 organization = forms.CharField(label=_('Organization'), max_length=256, required=False)
35 agree_license = forms.BooleanField(
36 label=_('Permission for publication'),
37 help_text=mark_safe_lazy(_(
38 u'I agree to having materials, recorded during the conference, released under the terms of '
39 u'<a href="http://creativecommons.org/licenses/by-sa/3.0/deed">CC\u00a0BY-SA</a> license and '
40 u'to publishing my image.')),
43 agree_terms = forms.BooleanField(
45 _(u'I accept <a href="/en/info/terms-and-conditions/">CopyCamp Terms and Conditions</a>.'))
48 def __init__(self, *args, **kwargs):
49 super(RegistrationForm, self).__init__(*args, **kwargs)
50 self.started = getattr(settings, 'REGISTRATION_STARTED', False)
51 self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= settings.REGISTRATION_LIMIT
53 def main_fields(self):
54 return [self[name] for name in (
55 'first_name', 'last_name', 'contact', 'organization')]
57 def survey_fields(self):
60 def agreement_fields(self):
61 return [self[name] for name in ('agree_license', 'agree_toc')]
64 class RegisterSpeaker(RegistrationForm):
65 form_tag = 'register-speaker'
66 save_as_tag = '2019-speaker'
67 form_title = _('Open call for presentations')
68 notify_on_register = False
70 bio = forms.CharField(label=mark_safe_lazy(
71 _('Short biographical note in Polish (max. 500 characters)')),
72 widget=forms.Textarea, max_length=500, required=True)
73 bio_en = forms.CharField(label=_('Short biographical note in English (max. 500 characters, not required)'), widget=forms.Textarea,
74 max_length=500, required=False)
75 photo = forms.FileField(label=_('Photo'), required=False)
76 phone = forms.CharField(label=_('Phone number'), max_length=64,
78 help_text=_('(used only for organizational purposes)'))
80 presentation_title = forms.CharField(
81 label=mark_safe_lazy(_('Presentation title in Polish')),
83 presentation_title_en = forms.CharField(
84 label=_('Presentation title in English (not required)'), max_length=256, required=False)
85 presentation_summary = forms.CharField(label=_('Presentation summary (max. 1800 characters)'),
86 widget=forms.Textarea, max_length=1800)
88 # presentation_post_conference_publication = forms.BooleanField(
89 # label=_('I am interested in including my paper in the post-conference publication'),
95 def __init__(self, *args, **kw):
96 super(RegisterSpeaker, self).__init__(*args, **kw)
97 self.started = getattr(settings, 'REGISTRATION_SPEAKER_STARTED', False)
98 self.closed = getattr(settings, 'REGISTRATION_SPEAKER_CLOSED', False)
99 self.fields.keyOrder = [
108 'presentation_title',
109 'presentation_title_en',
110 'presentation_summary',
117 class RemindForm(ContactForm):
118 form_tag = 'remind-me'
119 save_as_tag = 'remind-me-2019'
120 form_title = u'CopyCamp 2019'
121 notify_on_register = False
125 class NextForm(ContactForm):
127 form_title = _('Next CopyCamp')
129 name = forms.CharField(label=_('Name'), max_length=128)
130 contact = forms.EmailField(label=_('E-mail'), max_length=128)
131 organization = forms.CharField(label=_('Organization'),
132 max_length=256, required=False)
135 def workshop_field(label, help=None):
136 return forms.BooleanField(label=_(label), required=False, help_text=help)
139 class WorkshopForm(ContactForm):
140 form_tag = 'workshops'
141 save_as_tag = 'workshops-2018'
142 conference_name = u'CopyCamp 2018'
143 form_title = _('Workshop')
144 notify_on_register = False
145 mailing_field = 'agree_mailing'
147 first_name = forms.CharField(label=_('First name'), max_length=128)
148 last_name = forms.CharField(label=_('Last name'), max_length=128)
149 contact = forms.EmailField(label=_('E-mail'), max_length=128)
150 organization = forms.CharField(label=_('Organization'), max_length=256, required=False)
151 country = forms.ChoiceField(
152 label=_('Country of residence'), choices=[('', '--------')] + zip(COUNTRIES, COUNTRIES), required=False)
154 _header = HeaderField(
155 label=mark_safe_lazy(_("<h3>I'll take a part in workshops</h3>")),
156 help_text=_('Only workshops with any spots left are visible here.'))
158 _h1 = HeaderField(label=mark_safe_lazy(_("<strong>Friday, October 5th, 11 a.m.–1 p.m.</strong>")))
160 w_dobosz = workshop_field(
161 u'Elżbieta Dobosz, Urząd Patentowy RP: Ochrona wzornictwa, co można chronić, co warto chronić i w jaki sposób',
162 u'Uczestnicy mogą przedstawić na warsztatach swoje wzory – '
163 u'rozwiązania wizualne ze wszystkich kategorii produktów.')
164 w_kozak = workshop_field(
165 u'Łukasz Kozak i Krzysztof Siewicz: Projekt : Upiór – wprowadzenie i warsztaty dla twórców gier')
166 w_secker = workshop_field(
167 u'Jane Secker and Chris Morrison: Embedding Copyright literacy using games-based learning',
168 _(u'The workshop will be conducted in English.'))
170 _h2 = HeaderField(label=mark_safe_lazy(_("<strong>Saturday, October 6th, 11 a.m.–1 p.m.</strong>")))
172 w_kakareko = workshop_field(
173 u'Ksenia Kakareko: Regulacje prawne dotyczące wykorzystania materiałów zdigitalizowanych')
174 w_kakareko_question = forms.CharField(
175 label=u'Możesz opisać sprawy, z którymi najczęściej spotykasz się jako pracownik instytucji posiadającej '
176 u'zdigitalizowane zbiory lub jako użytkownik tych zbiorów '
178 max_length=800, widget=forms.Textarea, required=False)
179 w_sikorska = workshop_field(
180 u'Krzysztof Siewicz: Autor: projektant / prawo autorskie dla projektantów')
181 w_sikorska_question = forms.CharField(
182 label=u'Jeżeli chcesz, możesz przesłać prowadzącemu swoje pytanie dotyczące prawa autorskiego, '
183 u'co pomoże mu lepiej przygotować warsztaty '
185 max_length=800, widget=forms.Textarea, required=False)
186 w_sztoldman = workshop_field(
187 u'dr Agnieszka Sztoldman, Aleksandra Burda, SMM Legal: Spory o pieniądze w branżach IP-driven')
189 _header_1 = HeaderField(label='')
190 _header_2 = HeaderField(label='')
192 start_workshops = ('dobosz', 'kozak', 'secker', 'kakareko', 'sikorska', 'sztoldman')
195 ('_h1', 'dobosz', 'kozak', 'secker'),
196 ('_h2', 'kakareko', 'sikorska', 'sztoldman'),
208 agree_mailing = forms.BooleanField(
209 label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
211 agree_license = forms.BooleanField(
212 label=_('Permission for publication'),
213 help_text=mark_safe_lazy(_(
214 u'I agree to having materials, recorded during the conference, released under the terms of '
215 u'<a href="http://creativecommons.org/licenses/by-sa/3.0/deed">CC\u00a0BY-SA</a> '
216 u'license and to publishing my image.')),
219 def __init__(self, *args, **kwargs):
220 super(WorkshopForm, self).__init__(*args, **kwargs)
222 url = Entry.objects.get(slug_pl='regulamin').get_absolute_url()
223 self.fields['agree_toc'] = forms.BooleanField(
225 label=mark_safe(_('I accept <a href="%s">Terms and Conditions of CopyCamp</a>') % url)
227 except Entry.DoesNotExist:
229 counts = {k: 0 for k in self.start_workshops}
230 for contact in Contact.objects.filter(form_tag=self.save_as_tag):
231 for workshop in self.start_workshops:
232 if contact.body.get('w_%s' % workshop, False):
233 counts[workshop] += 1
234 # if workshop == 'youtube' and counts[workshop] == 30:
235 # send_mail(u'Warsztaty YouTube', u'Przekroczono limit 30 osób na warsztaty YouTube',
236 # 'no-reply@copycamp.pl',
237 # ['krzysztof.siewicz@nowoczesnapolska.org.pl'],
238 # fail_silently=True)
241 for k, v in counts.items():
242 if v >= self.limits[k]:
244 if 'w_%s' % k in self.fields:
245 del self.fields['w_%s' % k]
247 self.fields['_header'].help_text = None
250 for slot in self.slots:
251 if sum(1 for w in slot if self.cleaned_data.get('w_%s' % w)) > 1:
252 self._errors[slot[0]] = [_("You can't choose more than one workshop during the same period")]
253 if not any(self.cleaned_data.get('w_%s' % w) for w in self.start_workshops):
254 self._errors['_header'] = [_("Please choose at least one workshop.")]
255 return self.cleaned_data