class InvitationForm(fossirForm): from_address = SelectField(_('From'), [DataRequired()]) subject = StringField(_('Subject'), [DataRequired()]) body = TextAreaField(_('Email body'), [DataRequired()], widget=CKEditorWidget(simple=True)) recipients = EmailListField(_('Recipients'), [DataRequired()], description=_('One email address per line.')) copy_for_sender = BooleanField(_('Send copy to me'), widget=SwitchWidget()) submitted = HiddenField() def __init__(self, *args, **kwargs): event = kwargs.pop('event') super(InvitationForm, self).__init__(*args, **kwargs) self.from_address.choices = event.get_allowed_sender_emails().items() self.body.description = render_placeholder_info('survey-link-email', event=None, survey=None) def is_submitted(self): return super(InvitationForm, self).is_submitted() and 'submitted' in request.form def validate_body(self, field): missing = get_missing_placeholders('survey-link-email', field.data, event=None, survey=None) if missing: raise ValidationError( _('Missing placeholders: {}').format(', '.join(missing)))
class InvitationFormBase(fossirForm): _invitation_fields = ('skip_moderation', ) _email_fields = ('email_from', 'email_subject', 'email_body') email_from = SelectField(_('From'), [DataRequired()]) email_subject = StringField(_("Email subject"), [DataRequired()]) email_body = TextAreaField(_("Email body"), [DataRequired()], widget=CKEditorWidget(simple=True)) skip_moderation = BooleanField( _("Skip moderation"), widget=SwitchWidget(), description= _("If enabled, the user's registration will be approved automatically." )) def __init__(self, *args, **kwargs): self.regform = kwargs.pop('regform') event = self.regform.event super(InvitationFormBase, self).__init__(*args, **kwargs) if not self.regform.moderation_enabled: del self.skip_moderation self.email_from.choices = event.get_allowed_sender_emails().items() self.email_body.description = render_placeholder_info( 'registration-invitation-email', invitation=None) def validate_email_body(self, field): missing = get_missing_placeholders('registration-invitation-email', field.data, invitation=None) if missing: raise ValidationError( _('Missing placeholders: {}').format(', '.join(missing)))
class EventContactInfoForm(fossirForm): _contact_fields = ('contact_title', 'contact_emails', 'contact_phones') contact_title = StringField(_('Title'), [DataRequired()]) contact_emails = MultiStringField(_('Emails'), field=('email', _('email')), unique=True, flat=True, sortable=True) contact_phones = MultiStringField(_('Phone numbers'), field=('phone', _('number')), unique=True, flat=True, sortable=True) organizer_info = TextAreaField(_('Organizers')) additional_info = TextAreaField( _('Additional information'), widget=CKEditorWidget(simple=True, images=True, height=250), description=_("This text is displayed on the main conference page.")) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') super(EventContactInfoForm, self).__init__(*args, **kwargs) if self.event.type_ != EventType.lecture: del self.organizer_info if self.event.type_ != EventType.conference: del self.additional_info def validate_contact_emails(self, field): for email in field.data: if not is_valid_mail(email, False): raise ValidationError( _('Invalid email address: {}').format(escape(email)))
class LectureCreationForm(EventCreationFormBase): _field_order = ('title', 'occurrences', 'timezone', 'location_data', 'person_link_data', 'protection_mode') _advanced_field_order = ('description', 'theme') occurrences = OccurrencesField(_("Dates"), [DataRequired()], default_time=time(8), default_duration=timedelta(minutes=90)) person_link_data = EventPersonLinkListField(_('Speakers')) description = TextAreaField(_('Description'), widget=CKEditorWidget()) theme = fossirThemeSelectField(_('Theme'), event_type=EventType.lecture, allow_default=True)
class AgreementEmailForm(fossirForm): from_address = SelectField(_("From"), [DataRequired()]) cc_addresses = EmailField(_("CC"), description=_("Warning: this email address will be able to sign the agreement!")) body = TextAreaField(_("Email body"), widget=CKEditorWidget(simple=True)) def __init__(self, *args, **kwargs): self._definition = kwargs.pop('definition') event = kwargs.pop('event') super(AgreementEmailForm, self).__init__(*args, **kwargs) self.from_address.choices = event.get_allowed_sender_emails().items() self.body.description = render_placeholder_info('agreement-email', definition=self._definition, agreement=None) def validate_body(self, field): missing = get_missing_placeholders('agreement-email', field.data, definition=self._definition, agreement=None) if missing: raise ValidationError(_('Missing placeholders: {}').format(', '.join(missing)))
class EventDataForm(fossirForm): title = StringField(_('Event title'), [DataRequired()]) description = TextAreaField(_('Description'), widget=CKEditorWidget(simple=True, images=True, height=250)) url_shortcut = StringField(_('URL shortcut'), filters=[lambda x: (x or None)]) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') super(EventDataForm, self).__init__(*args, **kwargs) # TODO: Add a custom widget showing the prefix right before the field prefix = '{}/e/'.format(config.BASE_URL) self.url_shortcut.description = _( '<strong>{}SHORTCUT</strong> - the URL shortcut must be unique within ' 'this fossir instance and is not case sensitive.').format(prefix) def validate_url_shortcut(self, field): shortcut = field.data if not shortcut: return if shortcut.isdigit(): raise ValidationError( _("The URL shortcut must contain at least one character that is not a digit." )) if not re.match(r'^[a-zA-Z0-9/._-]+$', shortcut): raise ValidationError( _("The URL shortcut contains an invalid character.")) if '//' in shortcut: raise ValidationError( _("The URL shortcut may not contain two consecutive slashes.")) if shortcut[0] == '/' or shortcut[-1] == '/': raise ValidationError( _("The URL shortcut may not begin/end with a slash.")) conflict = (Event.query.filter( db.func.lower(Event.url_shortcut) == shortcut.lower(), ~Event.is_deleted, Event.id != self.event.id).has_rows()) if conflict: raise ValidationError( _("The URL shortcut is already used in another event.")) if LegacyEventMapping.query.filter_by( legacy_event_id=shortcut).has_rows(): # Reject existing event ids. It'd be EXTREMELY confusing and broken to allow such a shorturl # Non-legacy event IDs are already covered by the `isdigit` check above. raise ValidationError( _("This URL shortcut is not available.") % shortcut)
class EmailRegistrantsForm(fossirForm): from_address = SelectField(_("From"), [DataRequired()]) cc_addresses = EmailListField( _("CC"), description=_( "Beware, addresses in this field will receive one mail per " "registrant.")) subject = StringField(_("Subject"), [DataRequired()]) body = TextAreaField(_("Email body"), [DataRequired()], widget=CKEditorWidget(simple=True)) recipients = fossirEmailRecipientsField(_('Recipients')) copy_for_sender = BooleanField( _('Send copy to me'), widget=SwitchWidget(), description=_('Send copy of each email to my mailbox')) attach_ticket = BooleanField(_('Attach ticket'), widget=SwitchWidget(), description=_('Attach tickets to emails')) registration_id = HiddenFieldList() submitted = HiddenField() def __init__(self, *args, **kwargs): self.regform = kwargs.pop('regform') event = self.regform.event super(EmailRegistrantsForm, self).__init__(*args, **kwargs) self.from_address.choices = event.get_allowed_sender_emails().items() self.body.description = render_placeholder_info('registration-email', regform=self.regform, registration=None) def validate_body(self, field): missing = get_missing_placeholders('registration-email', field.data, regform=self.regform, registration=None) if missing: raise ValidationError( _('Missing placeholders: {}').format(', '.join(missing))) def is_submitted(self): return super(EmailRegistrantsForm, self).is_submitted() and 'submitted' in request.form
class EmailEventPersonsForm(fossirForm): from_address = SelectField(_('From'), [DataRequired()]) subject = StringField(_('Subject'), [DataRequired()]) body = TextAreaField(_('Email body'), [DataRequired()], widget=CKEditorWidget(simple=True)) recipients = fossirEmailRecipientsField(_('Recipients')) copy_for_sender = BooleanField(_('Send copy to me'), widget=SwitchWidget(), description=_('Send copy of each email to my mailbox')) person_id = HiddenFieldList() user_id = HiddenFieldList() submitted = HiddenField() def __init__(self, *args, **kwargs): register_link = kwargs.pop('register_link') event = kwargs.pop('event') super(EmailEventPersonsForm, self).__init__(*args, **kwargs) self.from_address.choices = event.get_allowed_sender_emails().items() self.body.description = render_placeholder_info('event-persons-email', event=None, person=None, register_link=register_link) def is_submitted(self): return super(EmailEventPersonsForm, self).is_submitted() and 'submitted' in request.form
class MenuPageForm(MenuUserEntryFormBase): html = TextAreaField(_("Content"), [DataRequired()], widget=CKEditorWidget())
class LegalMessagesForm(fossirForm): network_protected_disclaimer = TextAreaField( _("Network-protected information disclaimer"), widget=CKEditorWidget()) restricted_disclaimer = TextAreaField( _("Restricted information disclaimer"), widget=CKEditorWidget()) tos = TextAreaField(_("Terms and conditions"), widget=CKEditorWidget())
class NewsForm(fossirForm): title = StringField(_('Title'), [DataRequired()]) content = TextAreaField(_('Content'), [DataRequired()], widget=CKEditorWidget())
class NoteForm(fossirForm): # TODO: use something switchable source = TextAreaField(_("Minutes"), widget=CKEditorWidget())