- self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= 60
-
- # counts = {k: 0 for k in self.start_workshops}
- # for contact in Contact.objects.filter(form_tag=self.save_as_tag):
- # for workshop in self.start_workshops:
- # if contact.body.get('w_%s' % workshop, False): counts[workshop] += 1
- # some_full = False
- # for k, v in counts.items():
- # if v >= 60:
- # some_full = True
- # if 'w_%s' % k in self.fields:
- # del self.fields['w_%s' % k]
- # if k in self.workshops:
- # self.workshops.remove(k)
- # if not some_full:
- # self.fields['_header'].help_text = None
-
- # def clean(self):
- # any_workshop = False
- # for w in self.start_workshops:
- # if self.cleaned_data.get('w_%s' % w):
- # any_workshop = True
- # if not any_workshop:
- # self._errors['_header'] = [_("Please choose at least one workshop.")]
- # return self.cleaned_data
+ # self.limit_reached = Contact.objects.filter(form_tag=self.save_as_tag).count() >= 60
+ try:
+ url = Entry.objects.get(slug_pl='regulamin').get_absolute_url()
+ self.fields['agree_toc'] = forms.BooleanField(
+ required=True,
+ label=mark_safe(_('I accept <a href="%s">Terms and Conditions of CopyCamp</a>') % url)
+ )
+ except Entry.DoesNotExist:
+ pass
+ counts = {k: 0 for k in self.start_workshops}
+ for contact in Contact.objects.filter(form_tag=self.save_as_tag):
+ for workshop in self.start_workshops:
+ if contact.body.get('w_%s' % workshop, False): counts[workshop] += 1
+ some_full = False
+ for k, v in counts.items():
+ if v >= 30:
+ some_full = True
+ if 'w_%s' % k in self.fields:
+ del self.fields['w_%s' % k]
+ # if k in self.workshops:
+ # self.workshops.remove(k)
+ if not some_full:
+ self.fields['_header'].help_text = None
+
+ def clean(self):
+ if self.cleaned_data.get('w_siewicz') and not self.cleaned_data.get('w_siewicz_project'):
+ self._errors['w_siewicz_project'] = [_("Please submit your answer to qualify for this workshop")]
+ for slot in self.slots:
+ if sum(1 for w in slot if self.cleaned_data.get('w_%s' % w)) > 1:
+ self._errors[slot[0]] = [_("You can't choose more than one workshop during the same period")]
+ if not any(self.cleaned_data.get('w_%s' % w) for w in self.start_workshops):
+ self._errors['_header'] = [_("Please choose at least one workshop.")]
+ return self.cleaned_data