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