super(ConferenceRegistrationForm, self).__init__(*args, **kwargs)
self.user = user
self.fields['regtype'].queryset = RegistrationType.objects.filter(conference=self.instance.conference).order_by('sortkey')
- if not self.instance.conference.asktshirt:
- del self.fields['shirtsize']
- if not self.instance.conference.asknick:
- del self.fields['nick']
- if not self.instance.conference.asktwitter:
- del self.fields['twittername']
- else:
- self.fields['twittername'].validators.append(TwitterValidator)
- if not self.instance.conference.askphotoconsent:
- del self.fields['photoconsent']
- else:
- self.fields['photoconsent'].required = True
+ self.fields['photoconsent'].required = True
+ for f in self.instance.conference.remove_fields:
+ del self.fields[f]
if self.regforother:
self.fields['email'].widget.attrs['readonly'] = True
('address', models.TextField(max_length=200, verbose_name=b'Address', blank=True)),
('phone', models.CharField(max_length=100, verbose_name=b'Phone number', blank=True)),
('dietary', models.CharField(max_length=100, verbose_name=b'Special dietary needs', blank=True)),
- ('twittername', models.CharField(max_length=100, verbose_name=b'Twitter account', blank=True)),
+ ('twittername', models.CharField(max_length=100, verbose_name=b'Twitter account', blank=True, validators=[postgresqleu.util.validators.TwitterValidator])),
('nick', models.CharField(max_length=100, verbose_name=b'Nickname', blank=True)),
('shareemail', models.BooleanField(default=False, verbose_name=b'Share e-mail address with sponsors')),
('payconfirmedat', models.DateField(null=True, verbose_name=b'Payment confirmed', blank=True)),
from django.contrib.postgres.fields import DateTimeRangeField
from postgresqleu.util.validators import validate_lowercase
+from postgresqleu.util.validators import TwitterValidator
from postgresqleu.util.forms import ChoiceArrayField
from postgresqleu.confreg.dbimage import SpeakerImageStorage
else:
return self.startdate.strftime("%Y-%m-%d")
+ @property
+ def remove_fields(self):
+ if not self.asktshirt:
+ yield 'shirtsize'
+ if not self.asknick:
+ yield 'nick'
+ if not self.asktwitter:
+ yield 'twittername'
+ if not self.askphotoconsent:
+ yield 'photoconsent'
+
@property
def pending_session_notifications(self):
# How many speaker notifications are currently pending for this
shirtsize = models.ForeignKey(ShirtSize, null=True, blank=True, verbose_name="Preferred T-shirt size")
dietary = models.CharField(max_length=100, null=False, blank=True, verbose_name="Special dietary needs")
additionaloptions = models.ManyToManyField(ConferenceAdditionalOption, blank=True, verbose_name="Additional options")
- twittername = models.CharField(max_length=100, null=False, blank=True, verbose_name="Twitter account")
+ twittername = models.CharField(max_length=100, null=False, blank=True, verbose_name="Twitter account", validators=[TwitterValidator, ])
nick = models.CharField(max_length=100, null=False, blank=True, verbose_name="Nickname")
shareemail = models.BooleanField(null=False, blank=False, default=False, verbose_name="Share e-mail address with sponsors")
photoconsent = models.NullBooleanField(null=True, blank=False, verbose_name="Consent to having your photo taken at the event by the organisers")