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 2017'
 
  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-27th', _('October 27th only')),
 
  38            ('only-28th', _('October 28th 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             ('znajomi2', _('through friends by other means')),
 
 102             ('prasa', _('through press')),
 
 103             ('fnp', _('directly through the Foundation\'s facebook or website')),
 
 104             ('www', _('through other websites (please specify below)')),
 
 105             ('other', _('other (please specify below)')),
 
 106         ], widget=forms.RadioSelect())
 
 107     source_other = forms.CharField(required=False, label=_('Fill if you selected “other” or “other website” above'))
 
 108     motivation = forms.ChoiceField(
 
 110         label=_("6. Please indicate the most important factor for your willingness to participate:"),
 
 112             ('idea', _('the main idea of the conference')),
 
 113             ('speaker', _('particular speaker(s)')),
 
 114             ('networking', _('good networking occasion')),
 
 115             ('other', _('other (please specify below)')),
 
 116         ], widget=forms.RadioSelect())
 
 117     motivation_other = forms.CharField(required=False, label=_('Fill if you selected “other” above'))
 
 119     agree_mailing = forms.BooleanField(
 
 120         label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
 
 123     agree_data = forms.BooleanField(
 
 124         label=_('Permission for data processing'),
 
 125         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.')
 
 127     agree_license = forms.BooleanField(
 
 128         label=_('Permission for publication'),
 
 129         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.')),
 
 133     def __init__(self, *args, **kwargs):
 
 134         super(RegistrationForm, self).__init__(*args, **kwargs)
 
 135         self.started = getattr(settings, 'REGISTRATION_STARTED', False)
 
 136         self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= settings.REGISTRATION_LIMIT
 
 138             url = Entry.objects.get(slug_pl='regulamin').get_absolute_url()
 
 139             self.fields['agree_toc'] = forms.BooleanField(
 
 141                 label=mark_safe(_('I accept <a href="%s">Terms and Conditions of CopyCamp</a>') % url)
 
 143         except Entry.DoesNotExist:
 
 146     def clean_areas(self):
 
 147         data = self.cleaned_data['areas']
 
 149             raise forms.ValidationError(_('Select at most 3 areas'))
 
 152     def main_fields(self):
 
 153         return [self[name] for name in ('first_name', 'last_name', 'contact', 'organization', 'country', 'days')]
 
 155     def survey_fields(self):
 
 156         return [self[name] for name in (
 
 157             'times_attended', 'age', 'distance',
 
 158             'areas', 'areas_other', 'source', 'source_other', 'motivation', 'motivation_other')]
 
 160     def agreement_fields(self):
 
 161         return [self[name] for name in ('agree_mailing', 'agree_data', 'agree_license', 'agree_toc')]
 
 165     (_('business models, heritage digitization, remix'),
 
 166      _('What are the boundaries of appropriation in culture? '
 
 167        'Who owns the past and whether these exclusive rights allow to '
 
 168        'control present and future? How to make money from creativity without selling yourself?')),
 
 169     (_('health, food, security, and exclusive rights'),
 
 170      _('Who owns medicines and equipment necessary to provide health care? '
 
 171        'Who owns grain and machines used to harvest it? '
 
 172        'To what extent exclusive rights can affect what you eat, '
 
 173        'how you exercise, whether you can apply a specific treatment?')),
 
 174     (_('text and data mining, machine learning, online education'),
 
 175      _('Do you think own the data you feed to algorithms? Or maybe you think you own these algorithms? '
 
 176        'What if you can’t mine the data because you actually don’t own any of those rights? '
 
 177        'What does it mean to own data about someone, or data necessary for that person’s education?')),
 
 178     (_('IoT: autonomous cars, smart homes, wearables'),
 
 179      _('What does it mean to own exclusive rights to software and data used to construct autonomous agents? '
 
 180        'What will it mean in a near future?')),
 
 181     (_('hacking government data, public procurement, public aid in culture'),
 
 182      _('Who owns information created using public money? How can this information be appropriated? '
 
 183        'What is the role of government in the development of information infrastructure?')),
 
 187 class RegisterSpeaker(RegistrationForm):
 
 188     from django.utils.translation import ugettext_noop as _
 
 189     form_tag = 'register-speaker'
 
 190     save_as_tag = '2017-speaker'
 
 191     form_title = _('Open call for presentations')
 
 192     notify_on_register = False
 
 194     # inherited fields included so they are not translated
 
 195     first_name = forms.CharField(label=_('First name'), max_length=128)
 
 196     last_name = forms.CharField(label=_('Last name'), max_length=128)
 
 197     organization = forms.CharField(label=_('Organization'),
 
 198             max_length=256, required=False)
 
 199     agree_mailing = forms.BooleanField(
 
 200         label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
 
 203     agree_license = forms.BooleanField(
 
 204         label=_('Permission for publication'),
 
 205         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.')),
 
 209     presentation_thematic_track = forms.ChoiceField(
 
 210         label=_('Please select one thematic track'),
 
 211         choices=[(t, mark_safe('<strong>%s</strong><p style="margin-left: 20px;">%s</p>' % (t, desc))) for t, desc in tracks],
 
 212         widget=forms.RadioSelect())
 
 214     bio = forms.CharField(label=_('Short biographical note in English (max. 500 characters)'), widget=forms.Textarea,
 
 215                           max_length=500, required=False)
 
 216     photo = forms.FileField(label=_('Photo'), required=False)
 
 217     phone = forms.CharField(label=_('Phone number'), max_length=64,
 
 219                             help_text=_('Used only for organizational purposes.'))
 
 221     presentation_title = forms.CharField(
 
 222         label=mark_safe_lazy(_('Title of the presentation in English')),
 
 223         max_length=256, required=False)
 
 224     presentation_summary = forms.CharField(label=_('Summary of presentation (max. 1800 characters)'),
 
 225                                            widget=forms.Textarea, max_length=1800)
 
 227     # presentation_post_conference_publication = forms.BooleanField(
 
 228     #     label=_('I am interested in including my paper in the post-conference publication'),
 
 234     agree_terms = forms.BooleanField(
 
 235         label=mark_safe_lazy(_(u'I accept <a href="/en/info/terms-and-conditions/">'
 
 236                                u'CopyCamp Terms and Conditions</a>.'))
 
 239     # workshop = forms.BooleanField(label=_('Workshop'), required=False)
 
 240     # workshop_title = forms.CharField(label=_('Title of workshop'),
 
 241     #        max_length=256, required=False)
 
 242     # workshop_summary = forms.CharField(label=_('Summary of workshop (max. 1800 characters)'),
 
 243     #        widget=forms.Textarea, max_length=1800, required=False)
 
 245     def __init__(self, *args, **kw):
 
 246         super(RegisterSpeaker, self).__init__(*args, **kw)
 
 247         self.started = getattr(settings, 'REGISTRATION_SPEAKER_STARTED', False)
 
 248         self.closed = getattr(settings, 'REGISTRATION_SPEAKER_CLOSED', False)
 
 249         self.fields.keyOrder = [
 
 257             'presentation_title',
 
 258             'presentation_summary',
 
 259             'presentation_thematic_track',
 
 260             # 'presentation_post_conference_publication',
 
 263             # 'workshop_summary',
 
 272 class RemindForm(ContactForm):
 
 273     form_tag = 'remind-me'
 
 274     save_as_tag = 'remind-me-2017'
 
 275     form_title = u'CopyCamp 2017'
 
 276     notify_on_register = False
 
 280 class NextForm(ContactForm):
 
 282     form_title = _('Next CopyCamp')
 
 284     name = forms.CharField(label=_('Name'), max_length=128)
 
 285     contact = forms.EmailField(label=_('E-mail'), max_length=128)
 
 286     organization = forms.CharField(label=_('Organization'),
 
 287                                    max_length=256, required=False)
 
 290 class WorkshopForm(ContactForm):
 
 291     form_tag = 'workshops'
 
 292     save_as_tag = 'workshops-2017'
 
 293     conference_name = u'CopyCamp 2017'
 
 294     form_title = _('Workshop')
 
 296     name = forms.CharField(label=_('Name'), max_length=128)
 
 297     contact = forms.EmailField(label=_('E-mail'), max_length=128)
 
 298     organization = forms.CharField(label=_('Organization'),
 
 299                                    max_length=256, required=False)
 
 300     country = forms.CharField(label=_('Country'), max_length=128)
 
 302     _header = HeaderField(
 
 303         label=mark_safe_lazy(_("<h3>I'll take a part in workshops</h3>")),
 
 304         help_text=_('Only workshops with any spots left are visible here.'))
 
 306     _h1 = HeaderField(label=mark_safe_lazy(_("<strong>Thursday, October 27th, 10 a.m.–12 noon</strong>")))
 
 308     w_dimitrov = forms.BooleanField(label=_(u'Dimitar Dimitrov: Hacking Brussels'), required=False)
 
 309     w_vangompel = forms.BooleanField(label=_(
 
 310         u'Stef van Gompel: Methods and constraints for including evidence in IP lawmaking'), required=False)
 
 312     _h2 = HeaderField(label=mark_safe_lazy(_("<strong>Friday, October 28th, 10 a.m.–12 noon</strong>")))
 
 314     w_siewicz = forms.BooleanField(label=_(
 
 315         u'dr Krzysztof Siewicz, dr Marta Hoffman-Sommer: '
 
 316         u'Legal aspects of using research data in the age of Open Data'), required=False)
 
 317     w_siewicz_project = forms.CharField(
 
 319             u'<p style="margin-top: 0"><strong>Qualification for this workshop will be based on the answers '
 
 320             u'for the following problem:</strong></p>'
 
 321             u'Please choose a particular dataset from any research project you are involved in and provide '
 
 322             u'a description (no more than 1800 characters). Selected datasets will be discussed during '
 
 323             u'the workshop as case studies. In your description, please include the following information: '
 
 324             u'What is the research goal of the project (in the context of the chosen dataset)? '
 
 325             u'What data is being collected and how is it stored? What is the process of data collection '
 
 326             u'or generation? Who is involved in collecting or producing the data and in what manner?'),
 
 327         max_length=1800, widget=forms.Textarea, required=False)
 
 328     w_google = forms.BooleanField(label=_(
 
 329         u'Marcin Olender, Google: Prawo autorskie na YouTube (workshop in Polish)'), required=False)
 
 331     _h3 = HeaderField(label=mark_safe_lazy(_("<strong>Friday, October 28th, 12 noon–2 p.m.</strong>")))
 
 333     w_patronite = forms.BooleanField(label=_(
 
 334         u'Mateusz Górski, Michał Leksiński, Patronite: Jak zarabiać i się nie sprzedać – warsztaty dla twórców '
 
 335         u'(workshop in Polish)'),
 
 338     w_gurionova = forms.BooleanField(label=_(
 
 339         u'Olga Goriunova: The Lurker and the politics of knowledge in data culture'), required=False)
 
 341     _header_1 = HeaderField(label='')
 
 343     start_workshops = ('dimitrov', 'vangompel', 'siewicz', 'google', 'patronite', 'gurionova')
 
 345     slots = (('_h1', 'dimitrov', 'vangompel'), ('_h2', 'siewicz', 'google'), ('_h3', 'patronite', 'gurionova'))
 
 347     agree_mailing = forms.BooleanField(
 
 348         label=_('I am interested in receiving information about the Modern Poland Foundation\'s activities by e-mail'),
 
 350     agree_data = forms.BooleanField(
 
 351         label=_('Permission for data processing'),
 
 353             u'I hereby grant Modern Poland Foundation (Fundacja Nowoczesna Polska, ul. Marszałkowska 84/92, '
 
 354             u'00-514 Warszawa) permission to process my personal data (name, e-mail address) for purposes of '
 
 355             u'registration for CopyCamp conference.'))
 
 356     agree_license = forms.BooleanField(
 
 357         label=_('Permission for publication'),
 
 358         help_text=mark_safe_lazy(_(
 
 359             u'I agree to having materials, recorded during the conference, released under the terms of '
 
 360             u'<a href="http://creativecommons.org/licenses/by-sa/3.0/deed">CC\u00a0BY-SA</a> '
 
 361             u'license and to publishing my image.')),
 
 364     def __init__(self, *args, **kwargs):
 
 365         super(WorkshopForm, self).__init__(*args, **kwargs)
 
 366         # self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= 60
 
 368             url = Entry.objects.get(slug_pl='regulamin').get_absolute_url()
 
 369             self.fields['agree_toc'] = forms.BooleanField(
 
 371                 label=mark_safe(_('I accept <a href="%s">Terms and Conditions of CopyCamp</a>') % url)
 
 373         except Entry.DoesNotExist:
 
 375         counts = {k: 0 for k in self.start_workshops}
 
 376         for contact in Contact.objects.filter(form_tag=self.save_as_tag):
 
 377             for workshop in self.start_workshops:
 
 378                 if contact.body.get('w_%s' % workshop, False): counts[workshop] += 1
 
 380         for k, v in counts.items():
 
 383                 if 'w_%s' % k in self.fields:
 
 384                     del self.fields['w_%s' % k]
 
 385                 # if k in self.workshops:
 
 386                 #     self.workshops.remove(k)
 
 388             self.fields['_header'].help_text = None
 
 391         if self.cleaned_data.get('w_siewicz') and not self.cleaned_data.get('w_siewicz_project'):
 
 392             self._errors['w_siewicz_project'] = [_("Please submit your answer to qualify for this workshop")]
 
 393         for slot in self.slots:
 
 394             if sum(1 for w in slot if self.cleaned_data.get('w_%s' % w)) > 1:
 
 395                 self._errors[slot[0]] = [_("You can't choose more than one workshop during the same period")]
 
 396         if not any(self.cleaned_data.get('w_%s' % w) for w in self.start_workshops):
 
 397             self._errors['_header'] = [_("Please choose at least one workshop.")]
 
 398         return self.cleaned_data