class IPNetworkGroupForm(fossirForm):
    """Form to create or edit an IPNetworkGroup"""

    name = StringField(_("Name"), [DataRequired()])
    description = TextAreaField(_("Description"))
    networks = MultiIPNetworkField(
        _('Subnets'), description=_("IPv4 or IPv6 subnets in CIDR notation"))
    hidden = BooleanField(
        _('Hidden'),
        widget=SwitchWidget(),
        description=_("Hidden IP networks cannot be added to ACLs by users"))
    attachment_access_override = BooleanField(
        _('Full attachment access'),
        widget=SwitchWidget(confirm_enable=attachment_access_override_warning),
        description=_("If enabled, these IPs have unrestricted access to all "
                      "attachments without having to be logged in."))

    def __init__(self, *args, **kwargs):
        self._network_group_id = kwargs['obj'].id if 'obj' in kwargs else None
        super(IPNetworkGroupForm, self).__init__(*args, **kwargs)

    def validate_name(self, field):
        query = IPNetworkGroup.find(
            db.func.lower(IPNetworkGroup.name) == field.data.lower())
        if self._network_group_id is not None:
            query = query.filter(IPNetworkGroup.id != self._network_group_id)
        if query.first():
            raise ValueError(_("An IP network with this name already exists."))
Beispiel #2
0
class CategorySettingsForm(fossirForm):
    BASIC_FIELDS = ('title', 'description', 'timezone', 'lecture_theme', 'meeting_theme', 'visibility',
                    'suggestions_disabled', 'event_creation_notification_emails', 'notify_managers')
    EVENT_HEADER_FIELDS = ('event_message_mode', 'event_message')

    title = StringField(_("Title"), [DataRequired()])
    description = fossirMarkdownField(_("Description"))
    timezone = fossirTimezoneSelectField(_("Timezone"), [DataRequired()],
                                         description=_("Default timezone event lists will show up in. It will also be "
                                                       "used as a default for new events."))
    lecture_theme = fossirThemeSelectField(_("Theme for Lectures"), [DataRequired()], event_type=EventType.lecture,
                                           description=_("Default timetable theme used for lecture events"))
    meeting_theme = fossirThemeSelectField(_("Theme for Meetings"), [DataRequired()], event_type=EventType.meeting,
                                           description=_("Default timetable theme used for meeting events"))
    suggestions_disabled = BooleanField(_('Disable Suggestions'), widget=SwitchWidget(),
                                        description=_("Enable this if you don't want fossir to suggest this category as"
                                                      " a possible addition to a user's favourites."))
    event_message_mode = fossirEnumSelectField(_("Message Type"), enum=EventMessageMode,
                                               default=EventMessageMode.disabled,
                                               description=_("This message will show up at the top of every event page "
                                                             "in this category"))
    event_message = fossirMarkdownField(_("Content"))
    notify_managers = BooleanField(_("Notify managers"), widget=SwitchWidget(),
                                   description=_("Whether to send email notifications to all managers of this category "
                                                 "when an event is created inside it or in any of its subcategories."))
    event_creation_notification_emails = EmailListField(_("Notification E-mails"),
                                                        description=_("List of emails that will receive a notification "
                                                                      "every time a new event is created inside the "
                                                                      "category or one of its subcategories. "
                                                                      "One email address per line."))
class UserPreferencesForm(fossirForm):
    lang = SelectField(_('Language'))
    timezone = SelectField(_('Timezone'))

    force_timezone = BooleanField(
        _('Use my timezone'),
        widget=SwitchWidget(),
        description=_(
            "Always use my current timezone instead of an event's timezone."))

    show_past_events = BooleanField(
        _('Show past events'),
        widget=SwitchWidget(),
        description=_('Show past events by default.'))

    name_format = fossirEnumSelectField(
        _('Name format'),
        enum=NameFormat,
        description=_('Default format in which names are displayed'))

    use_previewer_pdf = BooleanField(
        _('Use previewer for PDF files'),
        widget=SwitchWidget(),
        description=
        _('The previewer is used by default for image and text files, but not for PDF files.'
          ))

    def __init__(self, *args, **kwargs):
        super(UserPreferencesForm, self).__init__(*args, **kwargs)
        self.lang.choices = sorted(get_all_locales().items(),
                                   key=itemgetter(1))
        self.timezone.choices = zip(common_timezones, common_timezones)
        if self.timezone.object_data and self.timezone.object_data not in common_timezones_set:
            self.timezone.choices.append(
                (self.timezone.object_data, self.timezone.object_data))
Beispiel #4
0
class ContribFieldConfigForm(fossirForm):
    title = StringField(_('Title'), [DataRequired()], description=_("The title of the field"))
    description = TextAreaField(_('Description'), description=_("The description of the field"))
    is_required = BooleanField(_('Required'), widget=SwitchWidget(),
                               description=_("Whether the user has to fill out the field"))
    is_active = BooleanField(_('Active'), widget=SwitchWidget(),
                             description=_("Whether the field is available."),
                             default=True)
Beispiel #5
0
class AbstractContentSettingsForm(fossirForm):
    """Configure the content field of abstracts"""

    is_active = BooleanField(
        _('Active'),
        widget=SwitchWidget(),
        description=_("Whether the content field is available."))
    is_required = BooleanField(
        _('Required'),
        widget=SwitchWidget(),
        description=_("Whether the user has to fill the content field."))
    max_length = IntegerField(_('Max length'),
                              [Optional(), NumberRange(min=1)])
    max_words = IntegerField(_('Max words'), [Optional(), NumberRange(min=1)])
Beispiel #6
0
class NewsSettingsForm(fossirForm):
    show_recent = BooleanField(
        'Show headlines',
        widget=SwitchWidget(),
        description=_(
            'Whether to show the latest news headlines on the fossir home page.'
        ))
    max_entries = IntegerField(
        _('Max. headlines'),
        [HiddenUnless('show_recent'),
         DataRequired(),
         NumberRange(min=1)],
        description=
        _("The maximum number of news headlines to show on the fossir home page."
          ))
    max_age = IntegerField(
        _('Max. age'),
        [HiddenUnless('show_recent'),
         InputRequired(),
         NumberRange(min=0)],
        description=_(
            "The maximum age in days for news to show up on the fossir home page. "
            "Setting it to 0 will show news no matter how old they are."))
    new_days = IntegerField(
        _('"New" threshold'),
        [InputRequired(), NumberRange(min=0)],
        description=_(
            'The maximum age in days for news to be considered "new". Setting it to 0 '
            'will disable the "new" label altogether.'))
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)))
Beispiel #8
0
class AttachmentFormBase(fossirForm):
    protected = BooleanField(_("Protected"), widget=SwitchWidget())
    folder = QuerySelectField(
        _("Folder"),
        allow_blank=True,
        blank_text=_("No folder selected"),
        get_label='title',
        description=_(
            "Adding materials to folders allow grouping and easier permission "
            "management."))
    acl = AccessControlListField(
        _("Access control list"),
        [UsedIf(lambda form, field: form.protected.data)],
        groups=True,
        allow_external=True,
        default_text=_('Restrict access to this material'),
        description=_(
            "The list of users and groups allowed to access the material"))

    def __init__(self, *args, **kwargs):
        linked_object = kwargs.pop('linked_object')
        super(AttachmentFormBase, self).__init__(*args, **kwargs)
        self.folder.query = (AttachmentFolder.find(
            object=linked_object, is_default=False,
            is_deleted=False).order_by(db.func.lower(AttachmentFolder.title)))

    @generated_data
    def protection_mode(self):
        return ProtectionMode.protected if self.protected.data else ProtectionMode.inheriting
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)))
Beispiel #10
0
class CategoryProtectionForm(fossirForm):
    _event_creation_fields = ('event_creation_restricted', 'event_creators', 'event_creation_notification_emails')

    protection_mode = fossirProtectionField(_('Protection mode'), protected_object=lambda form: form.protected_object)
    acl = AccessControlListField(_('Access control list'), groups=True, allow_external=True, allow_networks=True,
                                 default_text=_('Restrict access to this category'),
                                 description=_('List of users allowed to access the category.'))
    managers = PrincipalListField(_('Managers'), groups=True)
    own_no_access_contact = StringField(_('No access contact'),
                                        description=_('Contact information shown when someone lacks access to the '
                                                      'category'))
    visibility = SelectField(_("Event visibility"), [Optional()], coerce=lambda x: None if x == '' else int(x),
                             description=_("""From which point in the category tree contents will be visible from """
                                           """(number of categories upwards). Applies to "Today's events" and """
                                           """Calendar. If the category is moved, this number will be preserved."""))
    event_creation_restricted = BooleanField(_('Restricted event creation'), widget=SwitchWidget(),
                                             description=_('Whether the event creation should be restricted '
                                                           'to a list of specific persons'))
    event_creators = PrincipalListField(_('Event creators'), groups=True, allow_external=True,
                                        description=_('Users allowed to create events in this category'))

    def __init__(self, *args, **kwargs):
        self.protected_object = category = kwargs.pop('category')
        super(CategoryProtectionForm, self).__init__(*args, **kwargs)
        self._init_visibility(category)

    def _init_visibility(self, category):
        self.visibility.choices = get_visibility_options(category, allow_invisible=False)
        # Check if category visibility would be affected by any of the parents
        real_horizon = category.real_visibility_horizon
        own_horizon = category.own_visibility_horizon
        if real_horizon and real_horizon.is_descendant_of(own_horizon):
            self.visibility.warning = _("This category's visibility is currently limited by that of '{}'.").format(
                real_horizon.title)
Beispiel #11
0
class SessionForm(fossirForm):
    title = StringField(_('Title'), [DataRequired()])
    code = StringField(
        _('Session code'),
        description=_('The code that will identify the session in the Book of '
                      'Abstracts.'))
    description = TextAreaField(_('Description'))
    default_contribution_duration = TimeDeltaField(
        _('Default contribution duration'),
        units=('minutes', 'hours'),
        description=_('Duration that a contribution created within this '
                      'session will have by default.'),
        default=timedelta(minutes=20))
    location_data = fossirLocationField(
        _("Default location"),
        description=_("Default location for blocks inside the session."))
    colors = fossirPalettePickerField(_('Colours'), color_list=get_colors())
    is_poster = BooleanField(
        _('Poster session'),
        widget=SwitchWidget(),
        description=
        _('Whether the session is a poster session or contains normal presentations.'
          ))

    def __init__(self, *args, **kwargs):
        event = kwargs.pop('event')
        super(SessionForm, self).__init__(*args, **kwargs)
        if event.type != 'conference':
            del self.is_poster
            del self.code
class TicketsForm(fossirForm):
    tickets_enabled = BooleanField(
        _('Enable Tickets'),
        widget=SwitchWidget(),
        description=_(
            'Create tickets for registrations using this registration form.'))
    ticket_on_email = BooleanField(
        _('Send with an e-mail'),
        [HiddenUnless('tickets_enabled', preserve_data=True)],
        widget=SwitchWidget(),
        description=_(
            'Attach PDF ticket to the email sent to a user after completing '
            'their registration.'))
    ticket_on_event_page = BooleanField(
        _('Download from event homepage'),
        [HiddenUnless('tickets_enabled', preserve_data=True)],
        widget=SwitchWidget(),
        description=_('Allow users to download their ticket from the '
                      'conference homepage.'))
    ticket_on_summary_page = BooleanField(
        _('Download from summary page'),
        [HiddenUnless('tickets_enabled', preserve_data=True)],
        widget=SwitchWidget(),
        description=_(
            'Allow users to download their ticket from the registration '
            'summary page.'))

    ticket_template_id = SelectField(
        _('Ticket template'),
        [HiddenUnless('tickets_enabled', preserve_data=True),
         Optional()],
        coerce=int)

    def __init__(self, *args, **kwargs):
        event = kwargs.pop('event')
        super(TicketsForm, self).__init__(*args, **kwargs)
        default_tpl = get_default_template_on_category(event.category)
        all_templates = set(
            event.designer_templates) | get_inherited_templates(event)
        badge_templates = [
            (tpl.id, tpl.title) for tpl in all_templates
            if tpl.type == TemplateType.badge and tpl != default_tpl
        ]
        # Show the default template first
        badge_templates.insert(0, (default_tpl.id, '{} ({})'.format(
            default_tpl.title, _('Default category template'))))
        self.ticket_template_id.choices = badge_templates
Beispiel #13
0
    class RegistrationFormWTF(fossirForm):
        if management:
            notify_user = BooleanField(_("Send email"), widget=SwitchWidget())

        def validate_email(self, field):
            status = check_registration_email(regform, field.data, registration, management=management)
            if status['status'] == 'error':
                raise ValidationError('Email validation failed: ' + status['conflict'])
 def _create_coordinator_priv_fields(cls):
     for name, title in sorted(COORDINATOR_PRIV_TITLES.iteritems(),
                               key=itemgetter(1)):
         setattr(
             cls, name,
             BooleanField(title,
                          widget=SwitchWidget(),
                          description=COORDINATOR_PRIV_DESCS[name]))
         cls.priv_fields.add(name)
Beispiel #15
0
class DeadlineForm(fossirForm):
    deadline = fossirDateTimeField(_("Deadline"), [Optional()],
                                   default_time=time(23, 59))
    enforce = BooleanField(_("Enforce deadline"), [HiddenUnless('deadline')],
                           widget=SwitchWidget())

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(DeadlineForm, self).__init__(*args, **kwargs)
class BadgeSettingsForm(fossirForm):
    template = SelectField(_('Template'))
    save_values = BooleanField(
        _("Save values for next time"),
        widget=SwitchWidget(),
        description=_("Save these values in the event settings"))
    dashed_border = BooleanField(
        _("Dashed border around each badge"),
        widget=SwitchWidget(),
        description=_("Display a dashed border around each badge"))
    page_size = fossirEnumSelectField(_('Page size'), enum=PageSize)
    page_orientation = fossirEnumSelectField(_('Page orientation'),
                                             enum=PageOrientation)
    page_layout = fossirEnumSelectField(
        _('Page layout'),
        enum=PageLayout,
        description=_(
            'The single sided (foldable) option is only available if the '
            'template orientation is the same as the page orientation and '
            'its width is exactly half of the page width'))

    top_margin = FloatField(_('Top margin'), [InputRequired()])
    left_margin = FloatField(_('Left margin'), [InputRequired()])
    right_margin = FloatField(_('Right margin'), [InputRequired()])
    bottom_margin = FloatField(_('Bottom margin'), [InputRequired()])
    margin_columns = FloatField(_('Margin between columns'), [InputRequired()])
    margin_rows = FloatField(_('Margin between rows'), [InputRequired()])

    submitted = HiddenField()

    def __init__(self, event, **kwargs):
        all_templates = set(
            event.designer_templates) | get_inherited_templates(event)
        badge_templates = [
            tpl for tpl in all_templates if tpl.type.name == 'badge'
        ]
        super(BadgeSettingsForm, self).__init__(**kwargs)
        self.template.choices = sorted(
            ((unicode(tpl.id), tpl.title) for tpl in badge_templates),
            key=itemgetter(1))

    def is_submitted(self):
        return super(BadgeSettingsForm,
                     self).is_submitted() and 'submitted' in request.form
Beispiel #17
0
class ApplicationForm(fossirForm):
    name = StringField(_("Name"), [DataRequired()])
    description = TextAreaField(_("Description"))
    redirect_uris = RedirectURIField(
        _("Allowed authorization callback URLs"), [DataRequired()],
        description=_(
            "More than one URL can be specified adding new lines. The "
            "redirect_uri sent by the OAuth client must use the same protocol "
            "and host/port. If an entry contains a path, the redirect_uri's "
            "path must start with this path."))
    default_scopes = fossirSelectMultipleCheckboxField(
        'Allowed scopes', [DataRequired()],
        choices=sorted(SCOPES.items(), key=itemgetter(1)))
    is_enabled = BooleanField(
        _("Enabled"),
        widget=SwitchWidget(),
        description=_(
            "If an application is not enabled, its OAuth tokens cannot be used and "
            "user cannot be prompted to authorize the application."))
    is_trusted = BooleanField(
        _("Trusted"),
        widget=SwitchWidget(),
        description=
        _("Trusted applications will be granted authorization automatically and "
          "no intermediate page will be displayed during the authorization process."
          ))

    def __init__(self, *args, **kwargs):
        self.application = kwargs.pop('application', None)
        super(ApplicationForm, self).__init__(*args, **kwargs)
        if self.application is not None:
            for field in self.application.system_app_type.enforced_data:
                # preserve existing value for disabled fields
                self[field].data = self[field].object_data

    def validate_name(self, field):
        query = OAuthApplication.find(name=field.data)
        if self.application:
            query = query.filter(
                db.func.lower(OAuthApplication.name) !=
                self.application.name.lower())
        if query.count():
            raise ValidationError(
                _("There is already an application with this name"))
class TimetablePDFExportForm(fossirForm):
    _pdf_options_fields = {'pagesize', 'fontsize', 'firstPageNumber'}

    advanced = BooleanField(_("Advanced timetable"),
                            widget=SwitchWidget(),
                            description=_("Advanced customization options"))
    document_settings = fossirSelectMultipleCheckboxBooleanField(
        _('Document settings'), [HiddenUnless('advanced')],
        choices=_DOCUMENT_SETTINGS_CHOICES)
    contribution_info = fossirSelectMultipleCheckboxBooleanField(
        _('Contributions related info'), [HiddenUnless('advanced')],
        choices=_CONTRIBUTION_CHOICES)
    session_info = fossirSelectMultipleCheckboxBooleanField(
        _('Sessions related info'), [HiddenUnless('advanced')],
        choices=_SESSION_CHOICES)
    visible_entries = fossirSelectMultipleCheckboxBooleanField(
        _('Breaks and contributions'), [HiddenUnless('advanced')],
        choices=_VISIBLE_ENTRIES_CHOICES)
    other = fossirSelectMultipleCheckboxBooleanField(_('Miscellaneous'),
                                                     choices=_OTHER_CHOICES)
    pagesize = SelectField(_('Page size'),
                           choices=[('A0', 'A0'), ('A1', 'A1'), ('A2', 'A2'),
                                    ('A3', 'A3'), ('A4', 'A4'), ('A5', 'A5'),
                                    ('Letter', 'Letter')],
                           default='A4')
    fontsize = SelectField(_('Font size'),
                           choices=[('xxx-small', _('xxx-small')),
                                    ('xx-small', _('xx-small')),
                                    ('x-small', _('x-small')),
                                    ('smaller', _('smaller')),
                                    ('small', _('small')),
                                    ('normal', _('normal')),
                                    ('large', _('large')),
                                    ('larger', _('larger'))],
                           default='normal')
    firstPageNumber = IntegerField(_('Number for the first page'),
                                   [NumberRange(min=1)],
                                   default=1,
                                   widget=NumberInput(step=1))
    submitted = HiddenField()

    def is_submitted(self):
        return 'submitted' in request.args

    @property
    def data_for_format(self):
        if not self.advanced.data:
            fields = ('visible_entries', )
        else:
            fields = set(
                get_form_field_names(TimetablePDFExportForm)
            ) - self._pdf_options_fields - {'csrf_token', 'advanced'}
        data = {}
        for fieldname in fields:
            data.update(getattr(self, fieldname).data)
        return data
Beispiel #19
0
class SurveyFieldConfigForm(fossirForm):
    title = StringField(_('Title'), [DataRequired()],
                        description=_("The title of the question"))
    description = TextAreaField(
        _('Description'),
        description=_("The description (shown below the question's field.)"))
    is_required = BooleanField(
        _('Required'),
        widget=SwitchWidget(),
        description=_("If the user has to answer the question."))
Beispiel #20
0
class TextConfigForm(object):
    max_length = IntegerField(_('Max length'),
                              [Optional(), NumberRange(min=1)])
    max_words = IntegerField(_('Max words'), [Optional(), NumberRange(min=1)])
    multiline = BooleanField(
        _('Multiline'),
        widget=SwitchWidget(),
        description=_(
            "If the field should be rendered as a textarea instead of a single-line "
            "text field."))
class MenuBuiltinEntryForm(fossirForm):
    custom_title = BooleanField(_("Custom title"), widget=SwitchWidget())
    title = StringField(_("Title"),
                        [HiddenUnless('custom_title'),
                         DataRequired()])
    is_enabled = BooleanField(_("Show"), widget=SwitchWidget())

    def __init__(self, *args, **kwargs):
        entry = kwargs.pop('entry')
        super(MenuBuiltinEntryForm, self).__init__(*args, **kwargs)
        self.custom_title.description = _(
            "If you customize the title, that title is used regardless of the user's "
            "language preference.  The default title <strong>{title}</strong> is "
            "displayed in the user's language.").format(
                title=entry.default_data.title)

    def post_validate(self):
        if not self.custom_title.data:
            self.title.data = None
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 AddTemplateForm(fossirForm):
    title = StringField(_('Title'), [DataRequired()])
    type = fossirEnumSelectField(_('Template'),
                                 enum=TemplateType,
                                 default=TemplateType.poster)
    is_clonable = BooleanField(
        _('Allow cloning'),
        widget=SwitchWidget(),
        default=True,
        description=_(
            "Allow cloning this template in subcategories and events"))
Beispiel #24
0
class AttachmentFolderForm(fossirForm):
    title = HiddenField(_("Name"), [DataRequired()],
                        widget=TypeaheadWidget(),
                        description=_("The name of the folder."))
    description = TextAreaField(
        _("Description"),
        description=_("Description of the folder and its content"))
    protected = BooleanField(_("Protected"), widget=SwitchWidget())
    acl = AccessControlListField(
        _("Access control list"),
        [UsedIf(lambda form, field: form.protected.data)],
        groups=True,
        allow_external=True,
        default_text=_('Restrict access to this folder'),
        description=_(
            "The list of users and groups allowed to access the folder"))
    is_always_visible = BooleanField(
        _("Always Visible"),
        widget=SwitchWidget(),
        description=_(
            "By default, folders are always visible, even if a user cannot "
            "access them. You can disable this behavior here, hiding the folder "
            "for anyone who does not have permission to access it."))

    def __init__(self, *args, **kwargs):
        self.linked_object = kwargs.pop('linked_object')
        super(AttachmentFolderForm, self).__init__(*args, **kwargs)
        self.title.choices = self._get_title_suggestions()

    def _get_title_suggestions(self):
        query = db.session.query(AttachmentFolder.title).filter_by(
            is_deleted=False, is_default=False, object=self.linked_object)
        existing = set(x[0] for x in query)
        suggestions = set(get_default_folder_names()) - existing
        if self.title.data:
            suggestions.add(self.title.data)
        return sorted(suggestions)

    @generated_data
    def protection_mode(self):
        return ProtectionMode.protected if self.protected.data else ProtectionMode.inheriting
Beispiel #25
0
class CephalopodForm(fossirForm):
    joined = BooleanField('Join the community', widget=SwitchWidget())
    contact_name = StringField(
        'Contact Name',
        [UsedIfChecked('joined'), DataRequired()],
        description=_(
            'Name of the person responsible for your fossir server.'))
    contact_email = EmailField(
        'Contact Email',
        [UsedIfChecked('joined'),
         DataRequired(), Email()],
        description=_(
            'Email address of the person responsible for your fossir server.'))
class BootstrapForm(LocalRegistrationForm):
    first_name = StringField('First Name', [DataRequired()])
    last_name = StringField('Last Name', [DataRequired()])
    email = EmailField(_('Email address'), [DataRequired()])
    affiliation = StringField('Affiliation', [DataRequired()])
    enable_tracking = BooleanField('Join the community', widget=SwitchWidget())
    contact_name = StringField(
        'Contact Name', [UsedIfChecked('enable_tracking'),
                         DataRequired()])
    contact_email = EmailField(
        'Contact Email Address',
        [UsedIfChecked('enable_tracking'),
         DataRequired(),
         Email()])
Beispiel #27
0
class EditEmailTemplateTextForm(fossirForm):
    """Form for editing the text of a new e-mail template."""

    reply_to_address = SelectField(_('"Reply to" address'), [DataRequired()])
    include_submitter = BooleanField(_('Send to submitter'),
                                     widget=SwitchWidget())
    include_authors = BooleanField(_('Send to primary authors'),
                                   widget=SwitchWidget())
    include_coauthors = BooleanField(_('Send to co-authors'),
                                     widget=SwitchWidget())
    extra_cc_emails = EmailListField(
        _("CC"),
        description=_("Additional CC e-mail addresses (one per line)"))
    subject = StringField(_("Subject"), [DataRequired()])
    body = TextAreaField(_("Body"), [DataRequired()])

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(EditEmailTemplateTextForm, self).__init__(*args, **kwargs)
        self.reply_to_address.choices = (self.event.get_allowed_sender_emails(
            extra=self.reply_to_address.object_data).items())
        self.body.description = render_placeholder_info(
            'abstract-notification-email', event=self.event)
class PaymentEventSettingsFormBase(fossirForm):
    enabled = BooleanField(
        _('Enabled'),
        widget=SwitchWidget(),
        description=_(
            'Only enabled payment methods can be selected by registrants.'))
    method_name = StringField(
        _('Name'), [DataRequired()],
        description=_("The name of the payment method displayed to the user."))

    def __init__(self, *args, **kwargs):
        # Provide the plugin settings in case a plugin needs them for more complex form fields.
        self._plugin_settings = kwargs.pop('plugin_settings')
        super(PaymentEventSettingsFormBase, self).__init__(*args, **kwargs)
Beispiel #29
0
 def _make_form(self):
     form_class = type(b'FeaturesForm', (fossirForm, ), {})
     disallowed = get_disallowed_features(self.event)
     for name, feature in sorted(get_feature_definitions().iteritems(),
                                 key=lambda x: x[1].friendly_name):
         if name in disallowed:
             continue
         field = BooleanField(feature.friendly_name,
                              widget=SwitchWidget(on_label=_('On'),
                                                  off_label=_('Off')),
                              description=feature.description)
         setattr(form_class, name, field)
     defaults = {name: True for name in get_enabled_features(self.event)}
     return form_class(csrf_enabled=False, obj=FormDefaults(defaults))
class BaseEntryForm(EntryFormMixin, fossirForm):
    shift_later = BooleanField(
        _('Shift down'),
        widget=SwitchWidget(),
        description=_("Shift down everything else that starts after this"))

    def __init__(self, *args, **kwargs):
        self.entry = kwargs.pop('entry')
        self._entry_type = self.entry.type
        super(BaseEntryForm, self).__init__(*args, **kwargs)

    def validate_duration(self, field):
        super(BaseEntryForm, self).validate_duration(field)
        if self.entry.type == TimetableEntryType.SESSION_BLOCK and self.entry.children:
            SessionBlockEntryForm._validate_duration(self.entry, field,
                                                     self.start_dt)