Ejemplo n.º 1
0
class CanonItemEditorForm(CanonItemForm):
    draft = BooleanField(
        description=
        'Draft items are only visible to editors and any logged in user with a direct link.'
    )
    community = BooleanField(
        description='Community items are editable by any logged in user.')
Ejemplo n.º 2
0
class NewBookingConfirmForm(NewBookingPeriodForm):
    booked_for_user = PrincipalField(_(u'User'), [DataRequired()],
                                     allow_external=True)
    contact_email = StringField(
        _(u'Email'),
        [InputRequired(), IndicoEmail(multi=True)])
    contact_phone = StringField(_(u'Telephone'))
    booking_reason = TextAreaField(_(u'Reason'), [DataRequired()])
    uses_vc = BooleanField(_(u'I will use videoconference equipment'))
    used_equipment = IndicoQuerySelectMultipleCheckboxField(
        _(u'VC equipment'), get_label=lambda x: x.name)
    needs_vc_assistance = BooleanField(
        _(u'Request assistance for the startup of the videoconference session. '
          u'This support is usually performed remotely.'))
    needs_assistance = BooleanField(
        _(u'Request personal assistance for meeting startup'))
    submit_book = SubmitField(_(u'Create booking'))
    submit_prebook = SubmitField(_(u'Create pre-booking'))

    def validate_used_equipment(self, field):
        if field.data and not self.uses_vc.data:
            raise ValidationError(_(u'Videoconference equipment is not used.'))
        elif not field.data and self.uses_vc.data:
            raise ValidationError(
                _(u'You need to select some Videoconference equipment'))

    def validate_needs_vc_assistance(self, field):
        if field.data and not self.uses_vc.data:
            raise ValidationError(_(u'Videoconference equipment is not used.'))
Ejemplo n.º 3
0
class UserPreferencesForm(IndicoForm):
    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 = IndicoEnumSelectField(
        _('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(all_timezones, all_timezones)
Ejemplo n.º 4
0
class NewBookingConfirmForm(NewBookingPeriodForm):
    room_usage = RadioField(
        [DataRequired()],
        choices=[('current_user', _("I'll be using the room myself")),
                 ('other_user', _("I'm booking the room for someone else"))])
    booked_for_user = PrincipalField(
        _('User'), [HiddenUnless('room_usage', 'other_user'),
                    DataRequired()],
        allow_external=True)
    booking_reason = TextAreaField(_('Reason'), [DataRequired()])
    uses_vc = BooleanField(_('I will use videoconference equipment'))
    used_equipment = IndicoQuerySelectMultipleCheckboxField(
        _('VC equipment'), get_label=lambda x: x.name)
    needs_vc_assistance = BooleanField(
        _('Request assistance for the startup of the videoconference session. '
          'This support is usually performed remotely.'))
    needs_assistance = BooleanField(
        _('Request personal assistance for meeting startup'))
    submit_book = SubmitField(_('Create booking'))
    submit_prebook = SubmitField(_('Create pre-booking'))

    def validate_used_equipment(self, field):
        if field.data and not self.uses_vc.data:
            raise ValidationError(_('Videoconference equipment is not used.'))
        elif not field.data and self.uses_vc.data:
            raise ValidationError(
                _('Please select the type of videoconference that you will use.'
                  ))

    def validate_needs_vc_assistance(self, field):
        if field.data and not self.uses_vc.data:
            raise ValidationError(_('Videoconference equipment is not used.'))
Ejemplo n.º 5
0
class BookingSearchForm(IndicoForm):
    room_ids = SelectMultipleField('Rooms', [DataRequired()], coerce=int)

    start_date = DateField('Start Date', [InputRequired()],
                           parse_kwargs={'dayfirst': True})
    start_time = TimeField('Start Time', [InputRequired()])
    end_date = DateField('End Date', [InputRequired()],
                         parse_kwargs={'dayfirst': True})
    end_time = TimeField('End Time', [InputRequired()])

    booked_for_name = StringField('Booked For Name')
    reason = StringField('Reason')

    is_only_mine = BooleanField('Only Mine')
    is_only_my_rooms = BooleanField('Only My Rooms')
    is_only_confirmed_bookings = BooleanField('Only Confirmed Bookings')
    is_only_pending_bookings = BooleanField('Only Prebookings')

    is_rejected = BooleanField('Is Rejected')
    is_cancelled = BooleanField('Is Cancelled')
    is_archived = BooleanField('Is Archived')

    uses_vc = BooleanField(_('Uses Videoconference'))
    needs_vc_assistance = BooleanField(_('Videoconference Setup Assistance'))
    needs_assistance = BooleanField('General Assistance')

    @generated_data
    def start_dt(self):
        return datetime.combine(self.start_date.data, self.start_time.data)

    @generated_data
    def end_dt(self):
        return datetime.combine(self.end_date.data, self.end_time.data)
Ejemplo n.º 6
0
class AdminSettingsForm(IndicoForm):
    require_https = BooleanField(
        _('Require HTTPS'),
        widget=SwitchWidget(),
        description=_("Require HTTPS for all authenticated API requests."))
    allow_persistent = BooleanField(
        _('Persistent signatures'),
        widget=SwitchWidget(),
        description=_(
            "Allow users to enable persistent signatures (without timestamp).")
    )
    security_mode = IndicoEnumSelectField(
        _('Security mode'),
        enum=APIMode,
        titles=security_mode_titles,
        description=_('Specify if/when people need to use an API key or a '
                      'signed request.'))
    cache_ttl = IntegerField(
        _('Cache TTL'), [NumberRange(min=0)],
        description=_('Time to cache API results (in seconds)'))
    signature_ttl = IntegerField(
        _('Signature TTL'), [NumberRange(min=1)],
        description=
        _('Time after which a request signature expires. This should not be too '
          'low to account for small clock differences between the client and the '
          'server.'))
Ejemplo n.º 7
0
class ConfigurationForm(Form):
    map_width = IntegerField('map width', validators=(DataRequired(), NumberRange(5, 100)), filters=(int, ))
    map_height = IntegerField('map height', validators=(DataRequired(), NumberRange(5, 100)), filters=(int, ))
    blocks = IntegerField('count of blocks', validators=(DataRequired(), NumberRange(5 ** 2, 100 ** 2)),
                          filters=(int, ))
    treasures = IntegerField('count of treasures', validators=(DataRequired(), NumberRange(1, 5)), filters=(int, ))
    bots = IntegerField('count of bots', validators=(DataRequired(), NumberRange(1, 5)), filters=(int, ))
    rounded_game = BooleanField('game by rounds', default=False, validators=(), filters=(bool, ))
    maze_game = BooleanField('maze game', default=False, validators=(), filters=(bool, ))
    battery_game = BooleanField('battery game', default=False, validators=(), filters=(bool, ))
    laser_game = BooleanField('laser game', default=False, validators=(), filters=(bool, ))

    @property
    def as_configuration(self):
        if self.data.get('maze_game'):
            return CustomMazeConfiguration(**self.data)
        return CustomConfiguration(**self.data)

    def validate(self):
        if not super().validate():
            return False

        try:
            MapFactory.create(self.as_configuration)
        except ConfigurationError as e:
            self.bots.errors.append(str(e))
            return False

        return True
Ejemplo n.º 8
0
class AdvancedSearchForm(FlaskForm):
    searchterm = StringField('Search Term')
    primaryselect = SelectField('Primary', choices=[])
    secondaryfilterbool = BooleanField('Use Secondary Filter')
    secondaryselect = SelectField('Secondary', choices=[])
    tertiaryfilterbool = BooleanField('Use Tertiary Filter')
    tertiaryselect = SelectField('Tertiary', choices=[])
    advancedsearchbutton = SubmitField('Search')
Ejemplo n.º 9
0
class SearchForm(IndicoForm):
    last_name = StringField(_('Family name'))
    first_name = StringField(_('First name'))
    email = EmailField(_('Email'), filters=[lambda x: x.lower() if x else x])
    affiliation = StringField(_('Affiliation'))
    exact = BooleanField(_('Exact match'))
    include_deleted = BooleanField(_('Include deleted'))
    include_pending = BooleanField(_('Include pending'))
    external = BooleanField(_('External'))
Ejemplo n.º 10
0
class ChallengeForm(Form):
    title = StringField("Title", [validators.Length(min=4, max=25)])
    content = TextAreaField("Content")
    flag_or_answer = StringField("Flag/Answer")
    is_flag = BooleanField("Is Flag")
    tags = TagListField("Tags")
    hidden = BooleanField("Hidden")
    depreciated = BooleanField("Depreciated")
    points = IntegerField("Points", [validators.NumberRange(min=1)])
Ejemplo n.º 11
0
class AddCategoryForm(FlaskForm):
    categoryname = StringField(
        'Category Name', validators=[DataRequired(),
                                     Length(min=2, max=20)])
    primarybool = BooleanField('Check if Primary Category')
    primaryselect = SelectField('Primary', choices=[])
    secondarybool = BooleanField('Check if Subcategory')
    secondaryselect = SelectField('Secondary', choices=[])
    addbutton = SubmitField('Add Category')
Ejemplo n.º 12
0
class EditChatroomForm(IndicoForm):
    event_specific_fields = {'hidden', 'show_password'}

    # Room-wide options
    name = StringField(_('Name'), [DataRequired()], description=_('The name of the room'))
    description = TextAreaField(_('Description'), description=_('The description of the room'))
    password = StringField(_('Password'), description=_('An optional password required to join the room'))
    # Event-specific options
    hidden = BooleanField(_('Hidden'), description=_('Hides the room on public event pages.'))
    show_password = BooleanField(_('Show password'), description=_('Shows the room password on public event pages.'))
Ejemplo n.º 13
0
class ZoomAdvancedFormMixin(object):
    # Advanced options (per event)

    show_autojoin = BooleanField(
        _('Show Auto-join URL'),
        widget=SwitchWidget(),
        description=_("Show the auto-join URL on the event page"))
    show_phone_numbers = BooleanField(
        _('Show Phone Access numbers'),
        widget=SwitchWidget(),
        description=_("Show a link to the list of phone access numbers"))
class VCRoomAttachForm(VCRoomAttachFormBase):
    room_url_base = URLField('Redirector URL?',
                             description="vc room url redirector")
    show_join_button = BooleanField(
        _('Show join Button'),
        widget=SwitchWidget(),
        description=_("Show the join button on the event page"))
    only_registered_users = BooleanField(
        _('Only registered users'),
        widget=SwitchWidget(),
        description=_("Only registered users"))
Ejemplo n.º 15
0
class PluginSettingsForm(VCPluginSettingsFormBase):
    support_email = EmailField(_('Zoom email support'))

    api_key = StringField(_('API KEY'), [DataRequired()])

    api_secret = StringField(_('API SECRET'), [DataRequired()])

    auto_mute = BooleanField(
        _('Auto mute'),
        widget=SwitchWidget(_('On'), _('Off')),
        description=_(
            'The Zoom clients will join the VC room muted by default '))

    host_video = BooleanField(
        _('Host Video'),
        widget=SwitchWidget(_('On'), _('Off')),
        description=_('Start video when the host joins the meeting.'))

    participant_video = BooleanField(
        _('Participant Video'),
        widget=SwitchWidget(_('On'), _('Off')),
        description=_('Start video when participants join the meeting. '))

    join_before_host = BooleanField(
        _('Join Before Host'),
        widget=SwitchWidget(_('On'), _('Off')),
        description=
        _('Allow participants to join the meeting before the host starts the meeting. Only used for scheduled or recurring meetings.'
          ))

    #indico_room_prefix = IntegerField(_('Indico tenant prefix'), [NumberRange(min=0)],
    #                                  description=_('The tenant prefix for Indico rooms created on this server'))
    #room_group_name = StringField(_("Public rooms' group name"), [DataRequired()],
    #                              description=_('Group name for public videoconference rooms created by Indico'))
    num_days_old = IntegerField(
        _('VC room age threshold'),
        [NumberRange(min=1), DataRequired()],
        description=_(
            'Number of days after an Indico event when a videoconference room is '
            'considered old'))
    max_rooms_warning = IntegerField(
        _('Max. num. VC rooms before warning'),
        [NumberRange(min=1), DataRequired()],
        description=_(
            'Maximum number of rooms until a warning is sent to the managers'))
    zoom_phone_link = URLField(
        _('ZoomVoice phone number'),
        description=_('Link to the list of ZoomVoice phone numbers'))

    creation_email_footer = TextAreaField(
        _('Creation email footer'),
        widget=CKEditorWidget(),
        description=_(
            'Footer to append to emails sent upon creation of a VC room'))
Ejemplo n.º 16
0
class VCRoomAttachForm(VCRoomAttachFormBase):
    room_url = URLField('Room URL?', description="vc room url")
    extra_text = StringField('Extra infos',
                             description="Extra infos, e.g. password")
    show_join_button = BooleanField(
        _('Show join Button'),
        widget=SwitchWidget(),
        description=_("Show the join button on the event page"))
    only_registered_users = BooleanField(
        _('Only registered users'),
        widget=SwitchWidget(),
        description=_("Only registered users"))
Ejemplo n.º 17
0
class AdminUserSettingsForm(IndicoForm):
    notify_account_creation = BooleanField(_('Registration notifications'), widget=SwitchWidget(),
                                           description=_('Send an email to all administrators whenever someone '
                                                         'registers a new local account.'))
    email_blacklist = MultiStringField(_('Email blacklist'), field=('email_blacklist', _('email')),
                                       unique=True, flat=True,
                                       description=_('Prevent users from creating Indico accounts with these email '
                                                     'addresses. Supports wildcards, e.g. *@gmail.com'))
    allow_personal_tokens = BooleanField(_('Personal API tokens'), widget=SwitchWidget(),
                                         description=_('Whether users are allowed to generate personal API tokens. '
                                                       'If disabled, only admins can create them, but users will '
                                                       'still be able to regenerate the tokens assigned to them.'))
Ejemplo n.º 18
0
class EventSettingsForm(PaymentEventSettingsFormBase):

    use_event_api_keys = BooleanField(
        _('Use event API keys'),
        [Optional()],
        default=False,
        description=_(
            'Override the organization Stripe API keys.'
        ),
        widget=SwitchWidget(),
    )
    pub_key = StringField(
        _('Publishable key'),
        [
            HiddenUnless('use_event_api_keys'),
            UsedIf(lambda form, _: form.use_event_api_keys.data),
            DataRequired(),
        ],
        description=_('Publishable API key for the stripe.com account')
    )
    sec_key = StringField(
        _('Secret key'),
        [
            HiddenUnless('use_event_api_keys'),
            UsedIf(lambda form, _: form.use_event_api_keys.data),
            DataRequired(),
        ],
        description=_('Secret API key for the stripe.com account')
       )
    org_name = StringField(
        _('Organizer name'),
        [Optional()],
        default='Organization',
        description=_('Name of the event organizer')
    )
    description = StringField(
        _('Description'),
        [Optional()],
        default='Payment for conference',
        description=_('A description of the product or service being purchased')
    )
    require_postal_code = BooleanField(
        _('Require postal code input'),
        [Optional()],
        default=False,
        description=_(
            'Require registrants to input their postal code when filling the'
            ' payment form. Enabling this will decrease the chance of the'
            ' payment being marked as fraudulent.'
        ),
        widget=SwitchWidget(),
    )
Ejemplo n.º 19
0
class User(BaseModel):
    username = CharField(max_length=20, unique=True)
    email = CharField(max_length=50, unique=True)
    password = CharField()
    first_name = CharField(max_length=20)
    middle_name = CharField(max_length=20, null=True)
    last_name = CharField(max_length=20)
    created_at = DateTimeField(default=datetime.datetime.now)
    is_active = BooleanField(default=True)
    is_superuser = BooleanField(default=False)
    last_login = DateTimeField(null=True)

    def __str__(self):
        return self.username
Ejemplo n.º 20
0
class VidyoAdvancedFormMixin:
    # Advanced options (per event)
    show_pin = BooleanField(
        _('Show PIN'),
        widget=SwitchWidget(),
        description=_("Show the VC Room PIN on the event page (insecure!)"))
    show_autojoin = BooleanField(
        _('Show Auto-join URL'),
        widget=SwitchWidget(),
        description=_("Show the auto-join URL on the event page"))
    show_phone_numbers = BooleanField(
        _('Show Phone Access numbers'),
        widget=SwitchWidget(),
        description=_("Show a link to the list of phone access numbers"))
Ejemplo n.º 21
0
 def _set_fields(self, form):        
     setattr(form, 'brand_name', TextField('Brand Name (lowercase)'))
     setattr(form, 'brand_name_case', TextField('Brand Name (proper case)'))
     setattr(form, 'css_file', TextField('CSS File'))
     setattr(form, 'index_file', TextField('Index File'))
     setattr(form, 'categories_json', TextAreaField('Categories (JSON string)',  
                                                    validators=[custom_validators.JSONValidator()]))
     setattr(form, 'specialties_display', BooleanField('Display Specialties'))
     setattr(form, 'specialties_json', TextAreaField('Specialties (JSON string)',  
                                                    validators=[custom_validators.JSONValidator()]))
     setattr(form, 'associations_json', TextAreaField('Associations (JSON string)',  
                                                    validators=[custom_validators.JSONValidator()]))
     setattr(form, 'certifications_display', BooleanField('Display Certifications'))
     setattr(form, 'certifications_json', TextAreaField('Certifications (JSON string)',  
                                                    validators=[custom_validators.JSONValidator()]))
Ejemplo n.º 22
0
class OutlookUserPreferences(ExtraUserPreferences):
    fields = {
        'outlook_active':
        BooleanField(
            _('Sync with Outlook'),
            widget=SwitchWidget(),
            description=_(
                'Add Indico events in which I participate to my Outlook '
                'calendar')),
        'outlook_status':
        SelectField(_('Outlook entry status'),
                    [HiddenUnless('extra_outlook_active', preserve_data=True)],
                    choices=_status_choices,
                    description=_('The status for Outlook Calendar entries'))
    }

    def load(self):
        default_status = OutlookPlugin.settings.get('status')
        return {
            'outlook_active':
            OutlookPlugin.user_settings.get(self.user, 'enabled'),
            'outlook_status':
            OutlookPlugin.user_settings.get(self.user, 'status',
                                            default_status)
        }

    def save(self, data):
        OutlookPlugin.user_settings.set_multi(self.user, {
            'enabled': data['outlook_active'],
            'status': data['outlook_status']
        })
Ejemplo n.º 23
0
class SubmitAssignmentInput(Form):
    team_id = StringField(validators=[Length(max=36, min=2), InputRequired()])
    commit_sha = StringField(
        validators=[Length(max=40, min=20),
                    InputRequired()])
    extensions = IntegerField(default=0)
    dry_run = BooleanField(default=False)
Ejemplo n.º 24
0
class RunForm(FlaskForm):
    id_org = SelectField('Organization', [DataRequired()], choices=[("actc", "ACTC"), ("apat", "APAT"), ("aptp", "APTP"), (
        "auvo", "AUVO"), ("carx", "CARX"), ("cur", "CUR"), ("gpu", "GPU"), ("mss", "MSS"), ("tc", "TC"), ("tr", "TR")])
    year = IntegerField('Year')
    manual = BooleanField('Manual')
    org = HiddenField('org')
    submit = SubmitField('create')
Ejemplo n.º 25
0
class EditProjectForm(FlaskForm):
    name = StringField(_("Project name"), validators=[DataRequired()])
    password = StringField(_("Private code"), validators=[DataRequired()])
    contact_email = StringField(_("Email"),
                                validators=[DataRequired(),
                                            Email()])
    advanced_weighting_enabled = BooleanField(
        _("Advanced Weighting Enabled by Default?"), validators=[])

    def save(self):
        """Create a new project with the information given by this form.

        Returns the created instance
        """
        project = Project(
            name=self.name.data,
            id=self.id.data,
            password=generate_password_hash(self.password.data),
            contact_email=self.contact_email.data,
            advanced_weighting_enabled=self.advanced_weighting_enabled.data,
        )
        return project

    def update(self, project):
        """Update the project with the information from the form"""
        project.name = self.name.data
        project.password = generate_password_hash(self.password.data)
        project.contact_email = self.contact_email.data
        project.advanced_weighting_enabled = self.advanced_weighting_enabled.data
        return project
Ejemplo n.º 26
0
class AccessoryForm(BaseModelForm):
    state = SelectField(coerce=int,
                        label=gettext("State"),
                        choices=get_enum_states(),
                        default=0)
    state_notes = StringField(gettext("State notes"), [Length(max=255)])

    manufacturer = StringField(
        gettext("Manufacturer (required)"),
        [DataRequired(), Length(max=255)])
    model = StringField(gettext("Model (required)"),
                        [DataRequired(), Length(max=255)])
    model_notes = TextAreaField(gettext("Model notes"))
    description = TextAreaField(gettext("Description"))
    serial = StringField(gettext("Serial number (stay private)"),
                         [Length(max=255)])
    mount = StringField(gettext("Mount"), [Length(max=255)])
    batteries = StringField(gettext("Batteries type"))
    picture = FileField("Image", [FileAllowed(pictures, "Images only!")])

    private = BooleanField(gettext("Keep this private"))

    url1 = StringField(gettext("URL 1"), [Length(max=255)])
    url2 = StringField(gettext("URL 2"), [Length(max=255)])
    url3 = StringField(gettext("URL 3"), [Length(max=255)])
Ejemplo n.º 27
0
class LoginForm(FlaskForm):
    """ Login Form """
    email = EmailField(validators=[InputRequired('Please enter your email.')])
    password = PasswordField(
        validators=[InputRequired('Please enter your password.')])
    remember_me = BooleanField()
    submit = SubmitField('Login')
Ejemplo n.º 28
0
class EditCharacterForm(FlaskForm):
    """ Edit Character Form """
    id = HiddenField()
    name = StringField(
        label="Character",
        validators=[InputRequired('Please provide a character name')])
    is_dead = BooleanField(label="Is Dead")
Ejemplo n.º 29
0
class VenueForm(FlaskForm):
    def validate_phone(self, form, field):
        rule = re.compile(r"^[0-9]{3}-[0-9]{3}-[0-9]{4}$")
        if not re.search(rule, field.data):
            raise ValidationError(
                "Phone number not valid, kindly follow the format and enter numbers only"
            )

    def validate_genres(self, form, field):
        genres_values = [choice[1] for choice in genres_choice]
        for value in field.data:
            if value not in genres_values:
                raise ValidationError('Select genres Values')

    name = StringField('name', validators=[DataRequired()])
    city = StringField('city', validators=[DataRequired()])
    state = SelectField('state',
                        validators=[DataRequired()],
                        choices=states_choice)
    address = StringField('address', validators=[DataRequired()])
    phone = StringField('phone', validators=[DataRequired()])
    image_link = StringField('image_link')
    genres = SelectMultipleField('genres',
                                 validators=[DataRequired()],
                                 choices=genres_choice)
    facebook_link = StringField('facebook_link', validators=[URL()])
    website = StringField('website', validators=[URL()])
    seeking_talent = BooleanField('seeking_talent')
    seeking_description = StringField('seeking_description',
                                      validators=[Length(max=500)])
Ejemplo n.º 30
0
 def _add_form_fields(self, form_cls, **kwargs):
     exts = ', '.join(self.settings.get('valid_extensions'))
     return 'convert_to_pdf', \
            BooleanField(_("Convert to PDF"), widget=SwitchWidget(),
                         description=_("If enabled, your files will be be converted to PDF if possible. "
                                       "The following file types can be converted: {exts}").format(exts=exts),
                         default=True)