1 # -*- coding: utf-8 -*-
 
   2 from __future__ import unicode_literals
 
   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_lazy as _
 
  11 from django.utils.safestring import mark_safe
 
  12 from migdal.models import Entry
 
  14 mark_safe_lazy = lazy(mark_safe, unicode)
 
  17 class RegistrationForm(ContactForm):
 
  21     conference_name = u'CopyCamp 2016'
 
  23     form_title = _('Registration')
 
  24     admin_list = ['first_name', 'last_name', 'organization']
 
  26     first_name = forms.CharField(label=_('First name'), max_length=128)
 
  27     last_name = forms.CharField(label=_('Last name'), max_length=128)
 
  28     contact = forms.EmailField(label=_('E-mail'), max_length=128)
 
  29     organization = forms.CharField(label=_('Organization'), 
 
  30             max_length=256, required=False)
 
  31     country = forms.CharField(label=_('Country'), max_length=128)
 
  33     # days = forms.ChoiceField(
 
  34     #    label = _("I'm planning to show up on"),
 
  36     #        ('both', _('Both days of the conference')),
 
  37     #        ('only-6th', _('November 6th only')),
 
  38     #        ('only-7th', _('November 7th only')),
 
  39     #    ], widget=forms.RadioSelect())
 
  42     times_attended = forms.ChoiceField(
 
  44         label=_("1. How many times have you attended CopyCamp?"),
 
  49             ('3', _('three times')),
 
  50             ('4', _('four times')),
 
  51         ], widget=forms.RadioSelect())
 
  52     age = forms.ChoiceField(
 
  54         label=_("2. Please indicate your age bracket:"),
 
  56            ('0-19', _('19 or below')),
 
  57            ('20-25', _('20-25')),
 
  58            ('26-35', _('26-35')),
 
  59            ('36-45', _('36-45')),
 
  60            ('46-55', _('46-55')),
 
  61            ('56-65', _('56-65')),
 
  62            ('66+', _('66 or above')),
 
  63         ], widget=forms.RadioSelect())
 
  64     distance = forms.ChoiceField(
 
  66         label=_("3. How far will you travel to attend CopyCamp?"),
 
  68            ('0-50', _('0-50 km')),
 
  69            ('51-100', _('51-100 km')),
 
  70            ('101-200', _('101-200 km')),
 
  71            ('200+', _('200 km or more')),
 
  72         ], widget=forms.RadioSelect())
 
  73     areas = forms.MultipleChoiceField(
 
  75         label=_("4. Please indicate up to 3 areas you feel most affiliated with"),
 
  77             ('sztuki plastyczne', _('visual art')),
 
  78             ('literatura', _('literature')),
 
  79             ('muzyka', _('music')),
 
  80             ('teatr', _('theatre')),
 
  81             ('film', _('film production')),
 
  82             ('wydawanie', _('publishing')),
 
  84             ('ekonomia', _('economy')),
 
  85             ('socjologia', _('sociology')),
 
  86             ('technika', _('technology')),
 
  87             ('edukacja', _('education')),
 
  88             ('studia', _('higher education')),
 
  89             ('nauka', _('academic research')),
 
  90             ('biblioteki', _('library science')),
 
  91             ('administracja', _('public administration')),
 
  92             ('ngo', _('nonprofit organisations')),
 
  93             ('other', _('other (please specify below)')),
 
  94         ], widget=forms.CheckboxSelectMultiple())
 
  95     areas_other = forms.CharField(required=False, label=_('Fill if you selected “other” above'))
 
  96     source = forms.ChoiceField(
 
  98         label=_("5. Please indicate how you received information about the conference:"),
 
 100            ('znajomi', _('through friends sharing on the web')),
 
 101            ('fnp', _('directly through the Foundation\'s facebook or website')),
 
 102            ('www', _('through other websites (please specify below)')),
 
 103            ('other', _('other (please specify below)')),
 
 104         ], widget=forms.RadioSelect())
 
 105     source_other = forms.CharField(required=False, label=_('Fill if you selected “other” or “other website” above'))
 
 106     motivation = forms.ChoiceField(
 
 108         label=_("6. Please indicate the most important factor for your willingness to participate:"),
 
 110            ('idea', _('the main idea of the conference')),
 
 111            ('speaker', _('particular speaker(s)')),
 
 112            ('networking', _('good networking occasion')),
 
 113            ('other', _('other (please specify below)')),
 
 114         ], widget=forms.RadioSelect())
 
 115     motivation_other = forms.CharField(required=False, label=_('Fill if you selected “other” above'))
 
 117     agree_mailing = forms.BooleanField(
 
 118         label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
 
 121     agree_data = forms.BooleanField(
 
 122         label=_('Permission for data processing'),
 
 123         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.')
 
 125     agree_license = forms.BooleanField(
 
 126         label=_('Permission for publication'),
 
 127         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.')),
 
 131     def __init__(self, *args, **kwargs):
 
 132         super(RegistrationForm, self).__init__(*args, **kwargs)
 
 133         self.started = getattr(settings, 'REGISTRATION_STARTED', False)
 
 134         self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= settings.REGISTRATION_LIMIT
 
 136             url = Entry.objects.get(slug_pl='regulamin').get_absolute_url()
 
 137             self.fields['agree_toc'] = forms.BooleanField(
 
 139                 label=mark_safe(_('I accept <a href="%s">Terms and Conditions of CopyCamp</a>') % url)
 
 141         except Entry.DoesNotExist:
 
 144     def clean_areas(self):
 
 145         data = self.cleaned_data['areas']
 
 147             raise forms.ValidationError(_('Select at most 3 areas'))
 
 150     def main_fields(self):
 
 151         return [self[name] for name in ('first_name', 'last_name', 'contact', 'organization', 'country')]
 
 153     def survey_fields(self):
 
 154         return [self[name] for name in (
 
 155             'times_attended', 'age', 'distance',
 
 156             'areas', 'areas_other', 'source', 'source_other', 'motivation', 'motivation_other')]
 
 158     def agreement_fields(self):
 
 159         return [self[name] for name in ('agree_mailing', 'agree_data', 'agree_license', 'agree_toc')]
 
 163     _('Copyright and Art'),
 
 164     _('Remuneration Models'),
 
 165     _('Copyright, Education and Science'),
 
 166     _('Technology, Innovation and Copyright'),
 
 167     _('Copyright and Human Rights'),
 
 168     _('Copyright Enforcement'),
 
 169     _('Copyright Debate'),
 
 170     _('Copyright Lawmaking'),
 
 174 class RegisterSpeaker(RegistrationForm):
 
 175     form_tag = 'register-speaker'
 
 176     save_as_tag = '2016-speaker'
 
 177     form_title = _('Open call for presentations')
 
 179     presentation_thematic_track = forms.ChoiceField(
 
 180         label=_('Please select one thematic track'),
 
 181         choices=[(t, t) for t in tracks], widget=forms.RadioSelect())
 
 183     bio = forms.CharField(label=mark_safe_lazy(
 
 184         _('Short biographical note in Polish (max. 500 characters, fill <strong>at least</strong> one bio)')),
 
 185                           widget=forms.Textarea, max_length=500, required=False)
 
 186     bio_en = forms.CharField(label=_('Short biographical note in English (max. 500 characters)'), widget=forms.Textarea,
 
 187                              max_length=500, required=False)
 
 188     photo = forms.FileField(label=_('Photo'), required=False)
 
 189     phone = forms.CharField(label=_('Phone number'), max_length=64,
 
 191                             help_text=_('Used only for organizational purposes.'))
 
 193     # presentation = forms.BooleanField(label=_('Presentation'), required=False)
 
 194     presentation_title = forms.CharField(
 
 195         label=mark_safe_lazy(_('Title of the presentation in Polish (fill <strong>at least</strong> one title)')),
 
 196         max_length=256, required=False)
 
 197     presentation_title_en = forms.CharField(label=_('Title of the presentation in English'),
 
 198                                             max_length=256, required=False)
 
 199     # presentation = forms.FileField(label=_('Presentation'), required=False)
 
 200     presentation_summary = forms.CharField(label=_('Summary of presentation (max. 1800 characters)'),
 
 201                                            widget=forms.Textarea, max_length=1800)
 
 203     presentation_post_conference_publication = forms.BooleanField(
 
 204         label=_('I am interested in including my paper in the post-conference publication'),
 
 210     agree_terms = forms.BooleanField(
 
 211         label=mark_safe_lazy(_(u'I accept <a href="/en/info/terms-and-conditions/">'
 
 212                                    u'CopyCamp Terms and Conditions</a>.'))
 
 215     # workshop = forms.BooleanField(label=_('Workshop'), required=False)
 
 216     # workshop_title = forms.CharField(label=_('Title of workshop'),
 
 217     #        max_length=256, required=False)
 
 218     # workshop_summary = forms.CharField(label=_('Summary of workshop (max. 1800 characters)'),
 
 219     #        widget=forms.Textarea, max_length=1800, required=False)
 
 221     def __init__(self, *args, **kw):
 
 222         super(RegisterSpeaker, self).__init__(*args, **kw)
 
 223         self.started = getattr(settings, 'REGISTRATION_SPEAKER_STARTED', False)
 
 224         self.closed = getattr(settings, 'REGISTRATION_SPEAKER_CLOSED', False)
 
 225         self.fields.keyOrder = [
 
 235             'presentation_title',
 
 236             'presentation_title_en',
 
 237             'presentation_summary',
 
 238             'presentation_thematic_track',
 
 239             'presentation_post_conference_publication',
 
 242             # 'workshop_summary',
 
 251         cleaned_data = super(RegisterSpeaker, self).clean()
 
 253         if not cleaned_data.get('bio') and not cleaned_data.get('bio_en'):
 
 254             errors.append(forms.ValidationError(_('Fill at least one bio!')))
 
 255         if not cleaned_data.get('presentation_title') and not cleaned_data.get('presentation_title_en'):
 
 256             errors.append(forms.ValidationError(_('Fill at least one title!')))
 
 258             raise forms.ValidationError(errors)
 
 262 class NextForm(ContactForm):
 
 264     form_title = _('Next CopyCamp')
 
 266     name = forms.CharField(label=_('Name'), max_length=128)
 
 267     contact = forms.EmailField(label=_('E-mail'), max_length=128)
 
 268     organization = forms.CharField(label=_('Organization'),
 
 269                                    max_length=256, required=False)
 
 272 class WorkshopForm(ContactForm):
 
 273     form_tag = 'workshop'
 
 274     save_as_tag = 'workshop-2016'
 
 275     conference_name = u'CopyCamp 2016'
 
 276     form_title = _('Workshop')
 
 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)
 
 283     _#header = HeaderField(label=mark_safe_lazy(_("<h3>I'll take a part in workshops</h3>")), help_text=_('Only workshops with any spots left are visible here.'))
 
 285     #_h1 = HeaderField(label=mark_safe_lazy(_("<strong>Thursday, November 6th, 10 a.m.–12 noon</strong>")))
 
 287     #w_rysiek = forms.BooleanField(label=_(u'Michał „rysiek” Woźniak, Koalicja Otwartej Edukacji KOED: Wprowadzenie do prawa autorskiego i wolnych licencji'), required=False)
 
 288     #w_bartsch = forms.BooleanField(label=_(u'Natalia Bartsch: Wykorzystywanie istniejących utworów w tworzeniu przedstawienia teatralnego'), required=False)
 
 289     #w_samsung = forms.BooleanField(label=_(u'Rafał Sikorski: Prywatny użytek w prawie autorskim w XXI wieku. Jak powinien wyglądać w\u00a0Unii Europejskiej?'), required=False)
 
 291     #_h2 = HeaderField(label=mark_safe_lazy(_("<strong>Friday, November 7th, 10 a.m.–12 noon</strong>")))
 
 293     #w_mezei = forms.BooleanField(label=_(u'Péter Mezei: European copyright alternatives – 2014 (Workshop will be held in English)'), required=False)
 
 294     #w_sliwowski = forms.BooleanField(label=_(u'Kamil Śliwowski, Koalicja Otwartej Edukacji KOED: Prawo autorskie w Sieci - ćwiczenia praktyczne'), required=False)
 
 296     #_h3 = HeaderField(label=mark_safe_lazy(_("<strong>Friday, November 7th, 12 noon–2 p.m.</strong>")))
 
 298     #w_zaiks = forms.BooleanField(label=_(u'Łukasz Łyczkowski, Adam Pacuski, Stowarzyszenie Autorów ZAiKS: Praktyczne aspekty dozwolonego użytku'), required=False)
 
 299     #w_creativepoland = forms.BooleanField(label=_(u'Paweł Kaźmierczyk i Dagmara Białek, Creative Poland: Sektor kreatywny – pomysły są w cenie'), required=False)
 
 301     #_header_1 = HeaderField(label='')
 
 303     # agree_mailing = forms.BooleanField(
 
 304     #    label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
 
 307     agree_data = forms.BooleanField(
 
 308         label=_('Permission for data processing'),
 
 309         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.')
 
 311     agree_license = forms.BooleanField(
 
 312         label=_('Permission for publication'),
 
 313         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.')),
 
 317     def __init__(self, *args, **kwargs):
 
 318         super(WorkshopForm, self).__init__(*args, **kwargs)
 
 319         self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= 60
 
 321         # counts = {k: 0 for k in self.start_workshops}
 
 322         # for contact in Contact.objects.filter(form_tag=self.save_as_tag):
 
 323         #     for workshop in self.start_workshops:
 
 324     #            if contact.body.get('w_%s' % workshop, False): counts[workshop] += 1
 
 326         # for k, v in counts.items():
 
 329         #         if 'w_%s' % k in self.fields:
 
 330         #             del self.fields['w_%s' % k]
 
 331         #         if k in self.workshops:
 
 332         #             self.workshops.remove(k)
 
 334         #     self.fields['_header'].help_text = None
 
 337     #     any_workshop = False
 
 338     #     for w in self.start_workshops:
 
 339     #         if self.cleaned_data.get('w_%s' % w):
 
 340     #             any_workshop = True
 
 341     #     if not any_workshop:
 
 342     #         self._errors['_header'] = [_("Please choose at least one workshop.")]
 
 343     #     return self.cleaned_data