self.fields['photo512'].help_text = 'Photo will be rescaled to {}x{} pixels. We reserve the right to make minor edits to speaker photos if necessary'.format(*PRIMARY_SPEAKER_PHOTO_RESOLUTION)
- for classname, social, impl in sorted(get_all_conference_social_media(), key=lambda x: x[1]):
+ for classname, social, impl in sorted(get_all_conference_social_media('speaker'), key=lambda x: x[1]):
self.fields['social_{}'.format(social)] = forms.CharField(label="{} name".format(social.title()), max_length=250, required=False)
self.fields['social_{}'.format(social)].initial = self.instance.attributes.get('social', {}).get(social, '')
def clean(self):
cleaned_data = super().clean()
- for classname, social, impl in sorted(get_all_conference_social_media(), key=lambda x: x[1]):
+ for classname, social, impl in sorted(get_all_conference_social_media('speaker'), key=lambda x: x[1]):
fn = 'social_{}'.format(social)
if cleaned_data.get(fn, None):
try:
- cleaned_data[fn] = impl.clean_identifier_form_value(cleaned_data[fn])
+ cleaned_data[fn] = impl.clean_identifier_form_value('speaker', cleaned_data[fn])
except ValidationError as v:
self.add_error(fn, v)
if 'social' not in obj.attributes:
obj.attributes['social'] = {}
- for classname, social, impl in sorted(get_all_conference_social_media(), key=lambda x: x[1]):
+ for classname, social, impl in sorted(get_all_conference_social_media('speaker'), key=lambda x: x[1]):
v = self.cleaned_data['social_{}'.format(social)]
if v:
obj.attributes['social'][social] = v
return versions
-def get_all_conference_social_media():
+def get_all_conference_social_media(whatfor):
# When using .distinct() in django it randomly adds either "id" or "internalname" to the SQL
# query and thus doesn't actually return distinct values. Rather than trying to debug
# the horror that's an ORM, just run the query because queries are easy.
for classname, in exec_to_list("SELECT DISTINCT classname FROM confreg_messagingprovider WHERE series_id IS NOT NULL"):
c = get_messaging_class(classname)
- if c.can_broadcast:
+ if c.can_broadcast and c.can_track_users_for(whatfor):
yield (classname, c.typename.lower(), c)
@property
def nosave_fields(self):
- return ['social_{}'.format(social) for classname, social, impl in get_all_conference_social_media()]
+ return ['social_{}'.format(social) for classname, social, impl in get_all_conference_social_media('sponsor')]
def fix_fields(self):
- for classname, social, impl in sorted(get_all_conference_social_media(), key=lambda x: x[1]):
+ for classname, social, impl in sorted(get_all_conference_social_media('sponsor'), key=lambda x: x[1]):
fn = "social_{}".format(social)
self.fields[fn] = django.forms.CharField(label="{} name".format(social.title()), max_length=250, required=False)
self.fields[fn].initial = self.instance.social.get(social, '')
self.update_protected_fields()
def post_save(self):
- for classname, social, impl in get_all_conference_social_media():
+ for classname, social, impl in get_all_conference_social_media('sponsor'):
v = self.cleaned_data['social_{}'.format(social)]
if v:
self.instance.social[social] = v
def clean(self):
cleaned_data = super().clean()
- for classname, social, impl in get_all_conference_social_media():
+ for classname, social, impl in get_all_conference_social_media('sponsor'):
fn = 'social_{}'.format(social)
if cleaned_data.get(fn, None):
try:
- cleaned_data[fn] = impl.clean_identifier_form_value(cleaned_data[fn])
+ cleaned_data[fn] = impl.clean_identifier_form_value('sponsor', cleaned_data[fn])
except ValidationError as v:
self.add_error(fn, v)
super(SponsorSignupForm, self).__init__(*args, **kwargs)
- for classname, social, impl in sorted(get_all_conference_social_media(), key=lambda x: x[1]):
+ for classname, social, impl in sorted(get_all_conference_social_media('sponsor'), key=lambda x: x[1]):
fn = "social_{}".format(social)
self.fields[fn] = forms.CharField(label="Company {}".format(social.title()), max_length=250, required=False)
def clean(self):
cleaned_data = super(SponsorSignupForm, self).clean()
- for classname, social, impl in get_all_conference_social_media():
+ for classname, social, impl in get_all_conference_social_media('sponsor'):
fn = 'social_{}'.format(social)
if cleaned_data.get(fn, None):
try:
- cleaned_data[fn] = impl.clean_identifier_form_value(cleaned_data[fn])
+ cleaned_data[fn] = impl.clean_identifier_form_value('sponsor', cleaned_data[fn])
except ValidationError as v:
self.add_error(fn, v)
if request.POST.get('contractchoice', '') not in ('0', '1') and not level.instantbuy:
return _render_contract_choices()
- social = {social: form.cleaned_data['social_{}'.format(social)] for classname, social, impl in get_all_conference_social_media() if form.cleaned_data['social_{}'.format(social)]}
+ social = {
+ social: form.cleaned_data['social_{}'.format(social)]
+ for classname, social, impl
+ in get_all_conference_social_media('sponsor')
+ if form.cleaned_data['social_{}'.format(social)]
+ }
sponsor = Sponsor(conference=conference,
signupat=timezone.now(),
handle_regexp = re.compile(r'^@([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})$', re.I)
+ @classmethod
+ def can_track_users_for(self, whatfor):
+ return True
+
@classmethod
def validate_baseurl(self, baseurl):
if not OAuthApplication.objects.filter(name='mastodon', baseurl=baseurl).exists():
return 'Global OAuth credentials for {} missing'.format(baseurl)
@classmethod
- def clean_identifier_form_value(self, value):
+ def clean_identifier_form_value(self, whatfor, value):
if not self.handle_regexp.fullmatch(value):
raise ValidationError("Invalid format of Mastodon username. Must use format @name@site.")
return value
direct_message_max_length = None
typename = 'Telegram'
+ @classmethod
+ def can_track_users_for(self, whatfor):
+ return True
+
@classmethod
def validate_baseurl(self, baseurl):
return None
@classmethod
- def clean_identifier_form_value(self, value):
+ def clean_identifier_form_value(self, whatfor, value):
if not re.fullmatch('^[a-z0-9_]{5,}$', value, re.I):
raise ValidationError("Invalid format of Telegram username")
return value
typename = 'Twitter'
max_post_length = 280
+ @classmethod
+ def can_track_users_for(self, whatfor):
+ return True
+
@classmethod
def validate_baseurl(self, baseurl):
return None
@classmethod
- def clean_identifier_form_value(self, value):
+ def clean_identifier_form_value(self, whatfor, value):
# Always add the @ at the beginning. The validator forcibly strips it
# so for backwards compatibility as long as that validator is used elsewhere,
# we add it back here.