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_noop 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 2017'
 
  26     notify_on_register = False
 
  28     form_title = _('Registration')
 
  29     admin_list = ['first_name', 'last_name', 'organization']
 
  31     travel_grant_countries = TRAVEL_GRANT_COUNTRIES
 
  33     first_name = forms.CharField(label=_('First name'), max_length=128)
 
  34     last_name = forms.CharField(label=_('Last name'), max_length=128)
 
  35     contact = forms.EmailField(label=_('E-mail'), max_length=128)
 
  36     organization = forms.CharField(label=_('Organization'), max_length=256, required=False)
 
  37     country = forms.ChoiceField(label=_('Country of residence'), choices=zip(COUNTRIES, COUNTRIES))
 
  38     travel_grant = forms.BooleanField(
 
  39         label=_('I require financial assistance to attend CopyCamp 2017.'), required=False)
 
  40     travel_grant_motivation = forms.CharField(
 
  41         label=_('Please write us about yourself and why you want to come to CopyCamp. '
 
  42                 'This information will help us evaluate your travel grant application:'),
 
  43         help_text=_('Financial assistance for German audience is possible '
 
  44                     'thanks to the funds of the German Federal Foreign Office transferred by '
 
  45                     'the Foundation for Polish-German Cooperation.'),
 
  46         widget=forms.Textarea, max_length=600, required=False)
 
  48     days = forms.ChoiceField(
 
  49        label=_("I'm planning to show up on"),
 
  51            ('both', _('Both days of the conference')),
 
  52            ('only-28th', _('September 28th only')),
 
  53            ('only-29th', _('September 29th only')),
 
  54        ], widget=forms.RadioSelect())
 
  57     times_attended = forms.ChoiceField(
 
  59         label=_("1. How many times have you attended CopyCamp?"),
 
  64             ('3', _('three times')),
 
  65             ('4', _('four times')),
 
  66             ('5', _('five times')),
 
  67         ], widget=forms.RadioSelect())
 
  68     age = forms.ChoiceField(
 
  70         label=_("2. Please indicate your age bracket:"),
 
  72             ('0-19', _('19 or below')),
 
  73             ('20-25', _('20-25')),
 
  74             ('26-35', _('26-35')),
 
  75             ('36-45', _('36-45')),
 
  76             ('46-55', _('46-55')),
 
  77             ('56-65', _('56-65')),
 
  78             ('66+', _('66 or above')),
 
  79         ], widget=forms.RadioSelect())
 
  80     areas = forms.MultipleChoiceField(
 
  82         label=_("3. Please indicate up to 3 areas you feel most affiliated with"),
 
  84             ('sztuki plastyczne', _('visual art')),
 
  85             ('literatura', _('literature')),
 
  86             ('muzyka', _('music')),
 
  87             ('teatr', _('theatre')),
 
  88             ('film', _('film production')),
 
  89             ('wydawanie', _('publishing')),
 
  91             ('ekonomia', _('economy')),
 
  92             ('socjologia', _('sociology')),
 
  93             ('technika', _('technology')),
 
  94             ('edukacja', _('education')),
 
  95             ('studia', _('higher education')),
 
  96             ('nauka', _('academic research')),
 
  97             ('biblioteki', _('library science')),
 
  98             ('administracja', _('public administration')),
 
  99             ('ngo', _('nonprofit organisations')),
 
 100             ('other', _('other (please specify below)')),
 
 101         ], widget=forms.CheckboxSelectMultiple())
 
 102     areas_other = forms.CharField(required=False, label=_('Fill if you selected “other” above'))
 
 103     source = forms.ChoiceField(
 
 105         label=_("4. Please indicate how you received information about the conference:"),
 
 107             ('znajomi', _('through friends sharing on the web')),
 
 108             ('znajomi2', _('through friends by other means')),
 
 109             ('prasa', _('through press')),
 
 110             ('fnp', _('directly through the Foundation\'s facebook or website')),
 
 111             ('www', _('through other websites (please specify below)')),
 
 112             ('other', _('other (please specify below)')),
 
 113         ], widget=forms.RadioSelect())
 
 114     source_other = forms.CharField(required=False, label=_('Fill if you selected “other” or “other website” above'))
 
 115     motivation = forms.ChoiceField(
 
 117         label=_("6. Please indicate the most important factor for your willingness to participate:"),
 
 119             ('speaker', _('listening to particular speaker(s)')),
 
 120             ('networking', _('good networking occasion')),
 
 121             ('partnering', _('partnering with organisations present at the event')),
 
 122             ('other', _('other (please specify below)')),
 
 123         ], widget=forms.RadioSelect())
 
 124     motivation_other = forms.CharField(required=False, label=_('Fill if you selected “other” above'))
 
 126     agree_mailing = forms.BooleanField(
 
 127         label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
 
 130     agree_data = forms.BooleanField(
 
 131         label=_('Permission for data processing'),
 
 132         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.')
 
 134     agree_license = forms.BooleanField(
 
 135         label=_('Permission for publication'),
 
 136         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.')),
 
 140     def __init__(self, *args, **kwargs):
 
 141         super(RegistrationForm, self).__init__(*args, **kwargs)
 
 142         self.started = getattr(settings, 'REGISTRATION_STARTED', False)
 
 143         self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= settings.REGISTRATION_LIMIT
 
 145             url = Entry.objects.get(slug_pl='regulamin').get_absolute_url()
 
 146             self.fields['agree_toc'] = forms.BooleanField(
 
 148                 label=mark_safe(_('I accept <a href="%s">Terms and Conditions of CopyCamp</a>') % url)
 
 150         except Entry.DoesNotExist:
 
 153     def clean_areas(self):
 
 154         data = self.cleaned_data['areas']
 
 156             raise forms.ValidationError(_('Select at most 3 areas'))
 
 160         cleaned_data = self.cleaned_data
 
 161         country = cleaned_data['country']
 
 162         travel_grant = cleaned_data['travel_grant']
 
 163         motivation = cleaned_data['travel_grant_motivation']
 
 164         if country not in self.travel_grant_countries and travel_grant:
 
 165             raise forms.ValidationError(_('Travel grant is not provided for the selected country'))
 
 166         if travel_grant and not motivation:
 
 167             self._errors['travel_grant_motivation'] = _('Please provide this information')
 
 168             raise forms.ValidationError(_('To apply for a travel grant you must provide additional information.'))
 
 169         if not travel_grant and motivation:
 
 170             cleaned_data['motivation'] = ''
 
 173     def main_fields(self):
 
 174         return [self[name] for name in (
 
 175             'first_name', 'last_name', 'contact', 'organization', 'country',
 
 176             'travel_grant', 'travel_grant_motivation', 'days')]
 
 178     def survey_fields(self):
 
 179         return [self[name] for name in (
 
 180             'times_attended', 'age',
 
 181             'areas', 'areas_other', 'source', 'source_other', 'motivation', 'motivation_other')]
 
 183     def agreement_fields(self):
 
 184         return [self[name] for name in ('agree_mailing', 'agree_data', 'agree_license', 'agree_toc')]
 
 188     (_('business models, heritage digitization, remix'),
 
 189      _('What are the boundaries of appropriation in culture? '
 
 190        'Who owns the past and whether these exclusive rights allow to '
 
 191        'control present and future? How to make money from creativity without selling yourself?')),
 
 192     (_('health, food, security, and exclusive rights'),
 
 193      _('Who owns medicines and equipment necessary to provide health care? '
 
 194        'Who owns grain and machines used to harvest it? '
 
 195        'To what extent exclusive rights can affect what you eat, '
 
 196        'how you exercise, whether you can apply a specific treatment?')),
 
 197     (_('text and data mining, machine learning, online education'),
 
 198      _('Do you think own the data you feed to algorithms? Or maybe you think you own these algorithms? '
 
 199        'What if you can’t mine the data because you actually don’t own any of those rights? '
 
 200        'What does it mean to own data about someone, or data necessary for that person’s education?')),
 
 201     (_('IoT: autonomous cars, smart homes, wearables'),
 
 202      _('What does it mean to own exclusive rights to software and data used to construct autonomous agents? '
 
 203        'What will it mean in a near future?')),
 
 204     (_('hacking government data, public procurement, public aid in culture'),
 
 205      _('Who owns information created using public money? How can this information be appropriated? '
 
 206        'What is the role of government in the development of information infrastructure?')),
 
 210 class RegisterSpeaker(RegistrationForm):
 
 211     form_tag = 'register-speaker'
 
 212     save_as_tag = '2017-speaker'
 
 213     form_title = _('Open call for presentations')
 
 214     notify_on_register = False
 
 216     # inherited fields included so they are not translated
 
 217     first_name = forms.CharField(label=_('First name'), max_length=128)
 
 218     last_name = forms.CharField(label=_('Last name'), max_length=128)
 
 219     organization = forms.CharField(label=_('Organization'),
 
 220             max_length=256, required=False)
 
 221     agree_mailing = forms.BooleanField(
 
 222         label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
 
 225     agree_license = forms.BooleanField(
 
 226         label=_('Permission for publication'),
 
 227         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.')),
 
 231     presentation_thematic_track = forms.ChoiceField(
 
 232         label=_('Please select one thematic track'),
 
 233         choices=[(t, mark_safe('<strong>%s</strong><p style="margin-left: 20px;">%s</p>' % (t, desc))) for t, desc in tracks],
 
 234         widget=forms.RadioSelect())
 
 236     bio = forms.CharField(label=_('Short biographical note in English (max. 500 characters)'), widget=forms.Textarea,
 
 237                           max_length=500, required=False)
 
 238     photo = forms.FileField(label=_('Photo'), required=False)
 
 239     phone = forms.CharField(label=_('Phone number'), max_length=64,
 
 241                             help_text=_('Used only for organizational purposes.'))
 
 243     presentation_title = forms.CharField(
 
 244         label=mark_safe_lazy(_('Title of the presentation in English')),
 
 245         max_length=256, required=False)
 
 246     presentation_summary = forms.CharField(label=_('Summary of presentation (max. 1800 characters)'),
 
 247                                            widget=forms.Textarea, max_length=1800)
 
 249     # presentation_post_conference_publication = forms.BooleanField(
 
 250     #     label=_('I am interested in including my paper in the post-conference publication'),
 
 256     agree_terms = forms.BooleanField(
 
 257         label=mark_safe_lazy(_(u'I accept <a href="/en/info/terms-and-conditions/">'
 
 258                                u'CopyCamp Terms and Conditions</a>.'))
 
 261     # workshop = forms.BooleanField(label=_('Workshop'), required=False)
 
 262     # workshop_title = forms.CharField(label=_('Title of workshop'),
 
 263     #        max_length=256, required=False)
 
 264     # workshop_summary = forms.CharField(label=_('Summary of workshop (max. 1800 characters)'),
 
 265     #        widget=forms.Textarea, max_length=1800, required=False)
 
 267     def __init__(self, *args, **kw):
 
 268         super(RegisterSpeaker, self).__init__(*args, **kw)
 
 269         self.started = getattr(settings, 'REGISTRATION_SPEAKER_STARTED', False)
 
 270         self.closed = getattr(settings, 'REGISTRATION_SPEAKER_CLOSED', False)
 
 271         self.fields.keyOrder = [
 
 279             'presentation_title',
 
 280             'presentation_summary',
 
 281             'presentation_thematic_track',
 
 282             # 'presentation_post_conference_publication',
 
 285             # 'workshop_summary',
 
 294 class RemindForm(ContactForm):
 
 295     form_tag = 'remind-me'
 
 296     save_as_tag = 'remind-me-2017'
 
 297     form_title = u'CopyCamp 2017'
 
 298     notify_on_register = False
 
 302 class NextForm(ContactForm):
 
 304     form_title = _('Next CopyCamp')
 
 306     name = forms.CharField(label=_('Name'), max_length=128)
 
 307     contact = forms.EmailField(label=_('E-mail'), max_length=128)
 
 308     organization = forms.CharField(label=_('Organization'),
 
 309                                    max_length=256, required=False)
 
 312 def workshop_field(label):
 
 313     return forms.BooleanField(label=_(label), required=False)
 
 316 class WorkshopForm(ContactForm):
 
 317     form_tag = 'workshops'
 
 318     save_as_tag = 'workshops-2017'
 
 319     conference_name = u'CopyCamp 2017'
 
 320     form_title = _('Workshop')
 
 321     notify_on_register = False
 
 323     first_name = forms.CharField(label=_('First name'), max_length=128)
 
 324     last_name = forms.CharField(label=_('Last name'), max_length=128)
 
 325     contact = forms.EmailField(label=_('E-mail'), max_length=128)
 
 326     organization = forms.CharField(label=_('Organization'), max_length=256, required=False)
 
 327     country = forms.CharField(label=_('Country'), max_length=128)
 
 329     _header = HeaderField(
 
 330         label=mark_safe_lazy(_("<h3>I'll take a part in workshops</h3>")),
 
 331         help_text=_('Only workshops with any spots left are visible here.'))
 
 333     _h1 = HeaderField(label=mark_safe_lazy(_("<strong>Thursday, September 28th, 10 a.m.–12 noon</strong>")))
 
 335     w_mileszyk = workshop_field(
 
 336         u'Natalia Mileszyk, Dimitar Dimitrov, Diego Naranjo: School of Rock(ing) Copyright: United to #fixcopyright')  # 20
 
 337     w_wang = workshop_field(
 
 338         u'Jacob Riddersholm Wang, Pernille Feldt, Martin Appelt: Heritage gone digital - beyond legal rights')  # 20
 
 340     _h2 = HeaderField(label=mark_safe_lazy(_("<strong>Thursday, September 28th, 12 noon–2 p.m.</strong>")))
 
 342     w_vanderwaal = workshop_field(u'Sander van der Waal, Danny Lämmerhirt: Tackling open license proliferation')  # 20
 
 344     _h3 = HeaderField(label=mark_safe_lazy(_("<strong>Friday, September 29th, 10 a.m.–12 noon</strong>")))
 
 346     w_youtube = workshop_field(
 
 347         u'Kiki Ganzemüller: YouTube Songwriter Workshop: Rights Management & Building a Presence on YouTube')  # 40
 
 349     _h4 = HeaderField(label=mark_safe_lazy(_("<strong>Friday, September 29th, 12 noon–2 p.m.</strong>")))
 
 351     w_murray = workshop_field(
 
 352         u'Peter Murray-Rust: Wikidata, ContentMine and the automatic liberation of factual data: '
 
 353         u'(The Right to Read is the Right To Mine)')  # 30
 
 355     w_zimmermann = workshop_field(u'Jeremie Zimmermann: Hackers ethics and peer-to-peer philosophy in care')  # 30
 
 357     _header_1 = HeaderField(label='')
 
 358     _header_2 = HeaderField(label='')
 
 360     start_workshops = ('mileszyk', 'wang', 'vanderwaal', 'youtube', 'murray', 'zimmermann')
 
 362     slots = (('_h1', 'mileszyk', 'wang'), ('_h2', 'vanderwaal'), ('_h3', 'youtube'), ('_h4', 'murray', 'zimmermann'))
 
 373     agree_mailing = forms.BooleanField(
 
 374         label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
 
 376     agree_data = forms.BooleanField(
 
 377         label=_('Permission for data processing'),
 
 379             u'I hereby grant Modern Poland Foundation (Fundacja Nowoczesna Polska, ul. Marszałkowska 84/92, '
 
 380             u'00-514 Warszawa) permission to process my personal data (name, e-mail address) for purposes of '
 
 381             u'registration for CopyCamp conference.'))
 
 382     agree_license = forms.BooleanField(
 
 383         label=_('Permission for publication'),
 
 384         help_text=mark_safe_lazy(_(
 
 385             u'I agree to having materials, recorded during the conference, released under the terms of '
 
 386             u'<a href="http://creativecommons.org/licenses/by-sa/3.0/deed">CC\u00a0BY-SA</a> '
 
 387             u'license and to publishing my image.')),
 
 390     def __init__(self, *args, **kwargs):
 
 391         super(WorkshopForm, self).__init__(*args, **kwargs)
 
 393             url = Entry.objects.get(slug_pl='regulamin').get_absolute_url()
 
 394             self.fields['agree_toc'] = forms.BooleanField(
 
 396                 label=mark_safe(_('I accept <a href="%s">Terms and Conditions of CopyCamp</a>') % url)
 
 398         except Entry.DoesNotExist:
 
 400         counts = {k: 0 for k in self.start_workshops}
 
 401         for contact in Contact.objects.filter(form_tag=self.save_as_tag):
 
 402             for workshop in self.start_workshops:
 
 403                 if contact.body.get('w_%s' % workshop, False):
 
 404                     counts[workshop] += 1
 
 405                     if workshop == 'youtube' and counts[workshop] == 30:
 
 406                         send_mail(u'Warsztaty YouTube', u'Przekroczono limit 30 osób na warsztaty YouTube',
 
 407                                   'no-reply@copycamp.pl',
 
 408                                   ['krzysztof.siewicz@nowoczesnapolska.org.pl'],
 
 412         for k, v in counts.items():
 
 413             if v >= self.limits[k]:
 
 415                 if 'w_%s' % k in self.fields:
 
 416                     del self.fields['w_%s' % k]
 
 418             self.fields['_header'].help_text = None
 
 421         for slot in self.slots:
 
 422             if sum(1 for w in slot if self.cleaned_data.get('w_%s' % w)) > 1:
 
 423                 self._errors[slot[0]] = [_("You can't choose more than one workshop during the same period")]
 
 424         if not any(self.cleaned_data.get('w_%s' % w) for w in self.start_workshops):
 
 425             self._errors['_header'] = [_("Please choose at least one workshop.")]
 
 426         return self.cleaned_data