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
69 mailing_field = 'agree_mailing'
71 bio = forms.CharField(label=mark_safe_lazy(
72 _('Short biographical note in Polish (max. 500 characters)')),
73 widget=forms.Textarea, max_length=500, required=True)
74 bio_en = forms.CharField(label=_('Short biographical note in English (max. 500 characters, not required)'), widget=forms.Textarea,
75 max_length=500, required=False)
76 photo = forms.FileField(label=_('Photo'), required=False)
77 phone = forms.CharField(label=_('Phone number'), max_length=64,
79 help_text=_('(used only for organizational purposes)'))
81 presentation_title = forms.CharField(
82 label=mark_safe_lazy(_('Presentation title in Polish')),
84 presentation_title_en = forms.CharField(
85 label=_('Presentation title in English (not required)'), max_length=256, required=False)
86 presentation_summary = forms.CharField(label=_('Presentation summary (max. 1800 characters)'),
87 widget=forms.Textarea, max_length=1800)
89 # presentation_post_conference_publication = forms.BooleanField(
90 # label=_('I am interested in including my paper in the post-conference publication'),
96 def __init__(self, *args, **kw):
97 super(RegisterSpeaker, self).__init__(*args, **kw)
98 self.started = getattr(settings, 'REGISTRATION_SPEAKER_STARTED', False)
99 self.closed = getattr(settings, 'REGISTRATION_SPEAKER_CLOSED', False)
100 self.fields.keyOrder = [
109 'presentation_title',
110 'presentation_title_en',
111 'presentation_summary',
118 class RemindForm(ContactForm):
119 form_tag = 'remind-me'
120 save_as_tag = 'remind-me-2019'
121 form_title = u'CopyCamp 2019'
122 notify_on_register = False
126 class NextForm(ContactForm):
128 form_title = _('Next CopyCamp')
130 name = forms.CharField(label=_('Name'), max_length=128)
131 contact = forms.EmailField(label=_('E-mail'), max_length=128)
132 organization = forms.CharField(label=_('Organization'),
133 max_length=256, required=False)
136 def workshop_field(label, help=None):
137 return forms.BooleanField(label=_(label), required=False, help_text=help)
140 class WorkshopForm(ContactForm):
141 form_tag = 'workshops'
142 save_as_tag = 'workshops-2018'
143 conference_name = u'CopyCamp 2018'
144 form_title = _('Workshop')
145 notify_on_register = False
146 mailing_field = 'agree_mailing'
148 first_name = forms.CharField(label=_('First name'), max_length=128)
149 last_name = forms.CharField(label=_('Last name'), max_length=128)
150 contact = forms.EmailField(label=_('E-mail'), max_length=128)
151 organization = forms.CharField(label=_('Organization'), max_length=256, required=False)
152 country = forms.ChoiceField(
153 label=_('Country of residence'), choices=[('', '--------')] + zip(COUNTRIES, COUNTRIES), required=False)
155 _header = HeaderField(
156 label=mark_safe_lazy(_("<h3>I'll take a part in workshops</h3>")),
157 help_text=_('Only workshops with any spots left are visible here.'))
159 _h1 = HeaderField(label=mark_safe_lazy(_("<strong>Friday, October 5th, 11 a.m.–1 p.m.</strong>")))
161 w_dobosz = workshop_field(
162 u'Elżbieta Dobosz, Urząd Patentowy RP: Ochrona wzornictwa, co można chronić, co warto chronić i w jaki sposób',
163 u'Uczestnicy mogą przedstawić na warsztatach swoje wzory – '
164 u'rozwiązania wizualne ze wszystkich kategorii produktów.')
165 w_kozak = workshop_field(
166 u'Łukasz Kozak i Krzysztof Siewicz: Projekt : Upiór – wprowadzenie i warsztaty dla twórców gier')
167 w_secker = workshop_field(
168 u'Jane Secker and Chris Morrison: Embedding Copyright literacy using games-based learning',
169 _(u'The workshop will be conducted in English.'))
171 _h2 = HeaderField(label=mark_safe_lazy(_("<strong>Saturday, October 6th, 11 a.m.–1 p.m.</strong>")))
173 w_kakareko = workshop_field(
174 u'Ksenia Kakareko: Regulacje prawne dotyczące wykorzystania materiałów zdigitalizowanych')
175 w_kakareko_question = forms.CharField(
176 label=u'Możesz opisać sprawy, z którymi najczęściej spotykasz się jako pracownik instytucji posiadającej '
177 u'zdigitalizowane zbiory lub jako użytkownik tych zbiorów '
179 max_length=800, widget=forms.Textarea, required=False)
180 w_sikorska = workshop_field(
181 u'Krzysztof Siewicz: Autor: projektant / prawo autorskie dla projektantów')
182 w_sikorska_question = forms.CharField(
183 label=u'Jeżeli chcesz, możesz przesłać prowadzącemu swoje pytanie dotyczące prawa autorskiego, '
184 u'co pomoże mu lepiej przygotować warsztaty '
186 max_length=800, widget=forms.Textarea, required=False)
187 w_sztoldman = workshop_field(
188 u'dr Agnieszka Sztoldman, Aleksandra Burda, SMM Legal: Spory o pieniądze w branżach IP-driven')
190 _header_1 = HeaderField(label='')
191 _header_2 = HeaderField(label='')
193 start_workshops = ('dobosz', 'kozak', 'secker', 'kakareko', 'sikorska', 'sztoldman')
196 ('_h1', 'dobosz', 'kozak', 'secker'),
197 ('_h2', 'kakareko', 'sikorska', 'sztoldman'),
209 agree_mailing = forms.BooleanField(
210 label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
212 agree_license = forms.BooleanField(
213 label=_('Permission for publication'),
214 help_text=mark_safe_lazy(_(
215 u'I agree to having materials, recorded during the conference, released under the terms of '
216 u'<a href="http://creativecommons.org/licenses/by-sa/3.0/deed">CC\u00a0BY-SA</a> '
217 u'license and to publishing my image.')),
220 def __init__(self, *args, **kwargs):
221 super(WorkshopForm, self).__init__(*args, **kwargs)
223 url = Entry.objects.get(slug_pl='regulamin').get_absolute_url()
224 self.fields['agree_toc'] = forms.BooleanField(
226 label=mark_safe(_('I accept <a href="%s">Terms and Conditions of CopyCamp</a>') % url)
228 except Entry.DoesNotExist:
230 counts = {k: 0 for k in self.start_workshops}
231 for contact in Contact.objects.filter(form_tag=self.save_as_tag):
232 for workshop in self.start_workshops:
233 if contact.body.get('w_%s' % workshop, False):
234 counts[workshop] += 1
235 # if workshop == 'youtube' and counts[workshop] == 30:
236 # send_mail(u'Warsztaty YouTube', u'Przekroczono limit 30 osób na warsztaty YouTube',
237 # 'no-reply@copycamp.pl',
238 # ['krzysztof.siewicz@nowoczesnapolska.org.pl'],
239 # fail_silently=True)
242 for k, v in counts.items():
243 if v >= self.limits[k]:
245 if 'w_%s' % k in self.fields:
246 del self.fields['w_%s' % k]
248 self.fields['_header'].help_text = None
251 for slot in self.slots:
252 if sum(1 for w in slot if self.cleaned_data.get('w_%s' % w)) > 1:
253 self._errors[slot[0]] = [_("You can't choose more than one workshop during the same period")]
254 if not any(self.cleaned_data.get('w_%s' % w) for w in self.start_workshops):
255 self._errors['_header'] = [_("Please choose at least one workshop.")]
256 return self.cleaned_data