Esempio n. 1
0
class LoginForm(FlaskForm):
    username = StringField('Username',
                           validators=[DataRequired(),
                                       Length(min=5, max=30)])
    password = PasswordField('Password', validators=[DataRequired()])
    remember = BooleanField('Remember me')
    submit = SubmitField('Login')
Esempio n. 2
0
class PasswordReminder(FlaskForm):
    id = StringField(_("Project identifier"), validators=[DataRequired()])
    submit = SubmitField(_("Send me the code by email"))

    def validate_id(form, field):
        if not Project.query.get(field.data):
            raise ValidationError(_("This project does not exists"))
Esempio n. 3
0
class GeneralForm(Form):
    mail_main = EmailField('Email Main', [DataRequired(), Length(30)])
    mail_ads = EmailField('Email Advertisement', [DataRequired(), Length(30)])
    mail_support = EmailField('Email Support', [DataRequired(), Length(30)])
    mail_rotation = EmailField('Email Rotation', [DataRequired(), Length(30)])
    phone_main = TelField('Phone Main', [Length(15), ])
    phone_secondary = TelField('Phone Secondary', [Length(15), ])
    skype = StringField('Skype', [Length(50), ])
    address = StringField('Address')
    copyright_holder_text = TextAreaField('Copyright holder text', [DataRequired(), ])
    facebook_link = URLField('Facebook link', [DataRequired(), ])
    instagram_link = URLField('Instagram link', [DataRequired(), ])
    soundcloud_link = URLField('Soundcloud link', [DataRequired(), ])
    youtube_link = URLField('Youtube link', [DataRequired(), ])
    playmarket_link = URLField('Playmarket link')
    appstore_link = URLField('Appstore link')
Esempio n. 4
0
class RegisterForm(FlaskForm):
    username = StringField('Username',
                           validators=[DataRequired(),
                                       Length(min=5, max=30)])
    user_email = EmailField(
        'Email', validators=[DataRequired(),
                             Length(min=5, max=30),
                             Email()])
    password = PasswordField('Password',
                             validators=[DataRequired(),
                                         Length(max=30)])
    confirm_password = PasswordField(
        'Confirm Password', validators=[DataRequired(),
                                        EqualTo('password')])
    accept = BooleanField('Accept conditions')
    submit = SubmitField('Register')

    def validate_username(self, username):
        user = User.objects(name=username.data).first()
        if user:
            raise ValidationError(
                message=
                'Account with given username already exists. Try a different one.'
            )

    def validate_user_email(self, user_email):
        user = User.objects(email=user_email.data).first()
        if user:
            raise ValidationError(
                message=
                'Account with given email already exists. Try a different one.'
            )
Esempio n. 5
0
class SettingsForm(IndicoForm):  # pragma: no cover
    debug = BooleanField(
        _('Debug mode'),
        widget=SwitchWidget(),
        description=_(
            "If enabled, no actual connect/disconnect requests are sent"),
    )
    api_endpoint = URLField(_('API endpoint'), [DataRequired()],
                            filters=[lambda x: x.rstrip('/') + '/'],
                            description=_('The endpoint for the RAVEM API'))
    username = StringField(
        _('Username'), [DataRequired()],
        description=_('The username used to connect to the RAVEM API'))
    password = IndicoPasswordField(
        _('Password'), [DataRequired()],
        toggle=True,
        description=_('The password used to connect to the RAVEM API'))
    prefix = IntegerField(
        _('Room IP prefix'), [NumberRange(min=0)],
        description=_('IP prefix to connect a room to a Vidyo room.'))
    timeout = IntegerField(
        _('Timeout'), [NumberRange(min=0)],
        description=_(
            'The amount of time in seconds to wait for RAVEM to reply<br>'
            '(0 to disable the timeout)'))
    polling_limit = IntegerField(
        _('Polling limit'), [NumberRange(min=1)],
        description=_(
            'The maximum number of time Indico should poll RAVEM for the status of '
            'an operation before considering it as failed<br>'
            '(delete the cached var.js to take effect)'))
    polling_interval = IntegerField(
        _('Polling interval'), [NumberRange(min=1000)],
        description=_('The delay between two polls in ms, at least 1000 ms<br>'
                      '(delete the cached var.js to take effect)'))
Esempio n. 6
0
class AddChatroomForm(EditChatroomForm):
    use_custom_server = BooleanField(_('Use custom server'))
    custom_server = StringField(_('Custom server'), [UsedIf(lambda form, field: form.use_custom_server.data),
                                                     DataRequired()],
                                filters=[lambda x: x.lower() if x else x],
                                description=_('External Jabber server.'))

    def __init__(self, *args, **kwargs):
        self._date = kwargs.pop('date')
        super(AddChatroomForm, self).__init__(*args, **kwargs)
        self.use_custom_server.description = _('Check in case you want to use an external Jabber server and not the '
                                               'default one ({0}).').format(current_plugin.settings.get('muc_server'))

    def validate_name(self, field):
        jid = generate_jid(field.data, self._date)
        if not jid:
            # This error is not very helpful to a user, but it is extremely unlikely - only if he uses a name
            # which does not contain a single char usable in a JID
            raise ValidationError(_('Could not convert name to a jabber ID'))
        if Chatroom.find_first(jid_node=jid, custom_server=self.custom_server.data):
            raise ValidationError(_('A room with this name already exists'))
        if not self.custom_server.data:
            tmp_room = Chatroom(jid_node=jid)
            if room_exists(tmp_room.jid):
                raise ValidationError(_('A room with this name/JID already exists on the Jabber server ({0})').format(
                    tmp_room.jid
                ))

    @generated_data
    def jid_node(self):
        return generate_jid(self.name.data, self._date)
Esempio n. 7
0
class MemberForm(FlaskForm):

    name = StringField(_("Name"), validators=[Required()])
    weight = CommaDecimalField(_("Weight"), default=1)
    submit = SubmitField(_("Add"))

    def __init__(self, project, edit=False, *args, **kwargs):
        super(MemberForm, self).__init__(*args, **kwargs)
        self.project = project
        self.edit = edit

    def validate_name(form, field):
        if field.data == form.name.default:
            raise ValidationError(_("User name incorrect"))
        if (not form.edit and Person.query.filter(
                Person.name == field.data, Person.project == form.project,
                Person.activated == True).all()):  # NOQA
            raise ValidationError(_("This project already have this member"))

    def save(self, project, person):
        # if the user is already bound to the project, just reactivate him
        person.name = self.name.data
        person.project = project
        person.weight = self.weight.data

        return person

    def fill(self, member):
        self.name.data = member.name
        self.weight.data = member.weight
Esempio n. 8
0
class VCRoomFormBase(VCRoomLinkFormBase):
    advanced_fields = {'show'}
    skip_fields = advanced_fields | VCRoomLinkFormBase.conditional_fields

    name = StringField(
        _('Name'),
        [DataRequired(),
         Length(min=3, max=60),
         IndicoRegexp(ROOM_NAME_RE)],
        description=_(
            'The name of the room. It can contain only alphanumerical characters, underscores '
            'and dashes. No spaces allowed.'))

    def validate_name(self, field):
        if field.data:
            room = VCRoom.find_first(VCRoom.name == field.data,
                                     VCRoom.status != VCRoomStatus.deleted,
                                     VCRoom.type == self.service_name)
            if room and room != self.vc_room:
                raise ValidationError(
                    _("There is already a room with this name"))

    def __init__(self, *args, **kwargs):
        super(VCRoomFormBase, self).__init__(*args, **kwargs)
        self.vc_room = kwargs.pop('vc_room')
        self.service_name = current_plugin.service_name
Esempio n. 9
0
class BillForm(FlaskForm):
    date = DateField(_("Date"), validators=[Required()], default=datetime.now)
    what = StringField(_("What?"), validators=[Required()])
    payer = SelectField(_("Payer"), validators=[Required()], coerce=int)
    amount = CommaDecimalField(_("Amount paid"), validators=[Required()])
    payed_for = SelectMultipleField(_("For whom?"),
                                    validators=[Required()],
                                    coerce=int)
    submit = SubmitField(_("Submit"))
    submit2 = SubmitField(_("Submit and add a new one"))

    def save(self, bill, project):
        bill.payer_id = self.payer.data
        bill.amount = self.amount.data
        bill.what = self.what.data
        bill.date = self.date.data
        bill.owers = [
            Person.query.get(ower, project) for ower in self.payed_for.data
        ]

        return bill

    def fill(self, bill):
        self.payer.data = bill.payer_id
        self.amount.data = bill.amount
        self.what.data = bill.what
        self.date.data = bill.date
        self.payed_for.data = [int(ower.id) for ower in bill.owers]

    def set_default(self):
        self.payed_for.data = self.payed_for.default

    def validate_amount(self, field):
        if field.data == 0:
            raise ValidationError(_("Bills can't be null"))
Esempio n. 10
0
class PluginSettingsForm(VCPluginSettingsFormBase):
    support_email = EmailField(_('Bluejeans email support'))
    username = StringField(_('Username'), [DataRequired()],
                           description=_('Indico username for Bluejeans'))
    password = IndicoPasswordField(
        _('Password'), [DataRequired()],
        toggle=True,
        description=_('Indico password for Bluejeans'))
    admin_api_wsdl = URLField(_('Admin API WSDL URL'), [DataRequired()])
    user_api_wsdl = URLField(_('User API WSDL URL'), [DataRequired()])
    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'))
    authenticators = StringField(
        _('Authenticators'), [DataRequired()],
        description=_(
            'Identity providers to convert Indico users to Bluejeans accounts')
    )
    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'))
    bluejeans_phone_link = URLField(
        _('BluejeansVoice phone number'),
        description=_('Link to the list of BluejeansVoice phone numbers'))
    client_chooser_url = URLField(
        _('Client Chooser URL'),
        description=_(
            "URL for client chooser interface. The room key will be passed as a "
            "'url' GET query argument"))
    creation_email_footer = TextAreaField(
        _('Creation email footer'),
        widget=CKEditorWidget(),
        description=_(
            'Footer to append to emails sent upon creation of a VC room'))
Esempio n. 11
0
class EditProjectForm(FlaskForm):
    name = StringField(_("Project name"), validators=[DataRequired()])
    password = StringField(_("Private code"), validators=[DataRequired()])
    contact_email = StringField(_("Email"),
                                validators=[DataRequired(),
                                            Email()])
    project_history = BooleanField(_("Enable project history"))
    ip_recording = BooleanField(_("Use IP tracking for project history"))

    @property
    def logging_preference(self):
        """Get the LoggingMode object corresponding to current form data."""
        if not self.project_history.data:
            return LoggingMode.DISABLED
        else:
            if self.ip_recording.data:
                return LoggingMode.RECORD_IP
            else:
                return LoggingMode.ENABLED

    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,
            logging_preference=self.logging_preference,
        )
        return project

    def update(self, project):
        """Update the project with the information from the form"""
        project.name = self.name.data

        # Only update password if changed to prevent spurious log entries
        if not check_password_hash(project.password, self.password.data):
            project.password = generate_password_hash(self.password.data)

        project.contact_email = self.contact_email.data
        project.logging_preference = self.logging_preference

        return project
Esempio 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.'))
Esempio n. 13
0
class ConferenceLayoutForm(LoggedLayoutForm):
    is_searchable = BooleanField(_("Enable search"), widget=SwitchWidget(),
                                 description=_("Enable search within the event"))
    show_nav_bar = BooleanField(_("Show navigation bar"), widget=SwitchWidget(),
                                description=_("Show the navigation bar at the top"))
    show_banner = BooleanField(_("\"Now happening\""), widget=SwitchWidget(on_label=_("ON"), off_label=_("OFF")),
                               description=_("Show a banner with the current entries from the timetable"))
    show_social_badges = BooleanField(_("Show social badges"), widget=SwitchWidget())
    name_format = IndicoEnumSelectField(_('Name format'), enum=NameFormat, none=_('Inherit from user preferences'),
                                        description=_('Format in which names are displayed'))

    # Style
    header_text_color = StringField(_("Text colour"), widget=ColorPickerWidget())
    header_background_color = StringField(_("Background colour"), widget=ColorPickerWidget())

    # Announcement
    announcement = StringField(_("Announcement"),
                               [UsedIf(lambda form, field: form.show_announcement.data)],
                               description=_("Short message shown below the title"))
    show_announcement = BooleanField(_("Show announcement"), widget=SwitchWidget(),
                                     description=_("Show the announcement message"))

    # Timetable
    timetable_by_room = BooleanField(_("Group by room"), widget=SwitchWidget(),
                                     description=_("Group the entries of the timetable by room by default"))
    timetable_detailed = BooleanField(_("Show detailed view"), widget=SwitchWidget(),
                                      description=_("Show the detailed view of the timetable by default."))
    timetable_theme = SelectField(_('Theme'), [Optional()], coerce=lambda x: x or None)
    # Themes
    use_custom_css = BooleanField(_("Use custom CSS"), widget=SwitchWidget(),
                                  description=_("Use a custom CSS file as a theme for the conference page. Deactivate "
                                                "this option to reveal the available Indico themes."))
    theme = SelectField(_("Theme"), [Optional(), HiddenUnless('use_custom_css', False)],
                        coerce=lambda x: (x or None),
                        description=_("Currently selected theme of the conference page. Click on the Preview button to "
                                      "preview and select a different one."))

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(ConferenceLayoutForm, self).__init__(*args, **kwargs)
        self.timetable_theme.choices = [('', _('Default'))] + _get_timetable_theme_choices(self.event)
        self.theme.choices = _get_conference_theme_choices()

    def validate_use_custom_css(self, field):
        if field.data and not self.event.has_stylesheet:
            raise ValidationError(_('Cannot enable custom stylesheet unless there is one.'))
Esempio n. 14
0
class MenuUserEntryFormBase(IndicoForm):
    title = StringField(_('Title'), [DataRequired()])
    is_enabled = BooleanField(_('Show'), widget=SwitchWidget())
    new_tab = BooleanField(_('Open in a new tab'), widget=SwitchWidget())
    registered_only = BooleanField(
        _('Restricted'),
        widget=SwitchWidget(),
        description=_('Visible to registered users only.'))
Esempio n. 15
0
class MenuUserEntryFormBase(IndicoForm):
    title = StringField(_('Title'), [DataRequired()])
    is_enabled = BooleanField(_('Show'), widget=SwitchWidget())
    new_tab = BooleanField(_('Open in a new tab'), widget=SwitchWidget())
    access = IndicoEnumRadioField(
        _('Visibility'),
        enum=MenuEntryAccess,
        description=_('Specify who can see this menu item.'))
Esempio n. 16
0
class PluginSettingsForm(VCPluginSettingsFormBase):
    bbb_api_link = URLField(
        _('API endpoint'), [DataRequired()],
        description=
        _('URL returned by "bbb-conf --secret", E.g., https://bbb.yourdomain.tld/bigbluebutton/'
          ))
    bbb_secret = StringField(
        _('BBB Secret'), [DataRequired()],
        description=_('Secret returned by "bbb-conf --secret"'))
Esempio n. 17
0
class BillForm(FlaskForm):
    date = DateField(_("Date"),
                     validators=[DataRequired()],
                     default=datetime.now)
    what = StringField(_("What?"), validators=[DataRequired()])
    payer = SelectField(_("Payer"), validators=[DataRequired()], coerce=int)
    amount = CalculatorStringField(_("Amount paid"),
                                   validators=[DataRequired()])
    external_link = URLField(
        _("External link"),
        validators=[Optional()],
        description=_("A link to an external document, related to this bill"),
    )
    payed_for = SelectMultipleField(_("For whom?"),
                                    validators=[DataRequired()],
                                    coerce=int)
    submit = SubmitField(_("Submit"))
    submit2 = SubmitField(_("Submit and add a new one"))

    def save(self, bill, project):
        bill.payer_id = self.payer.data
        bill.amount = self.amount.data
        bill.what = self.what.data
        bill.external_link = self.external_link.data
        bill.date = self.date.data
        bill.owers = [
            Person.query.get(ower, project) for ower in self.payed_for.data
        ]
        return bill

    def fake_form(self, bill, project):
        bill.payer_id = self.payer
        bill.amount = self.amount
        bill.what = self.what
        bill.external_link = ""
        bill.date = self.date
        bill.owers = [
            Person.query.get(ower, project) for ower in self.payed_for
        ]

        return bill

    def fill(self, bill):
        self.payer.data = bill.payer_id
        self.amount.data = bill.amount
        self.what.data = bill.what
        self.external_link.data = bill.external_link
        self.date.data = bill.date
        self.payed_for.data = [int(ower.id) for ower in bill.owers]

    def set_default(self):
        self.payed_for.data = self.payed_for.default

    def validate_amount(self, field):
        if field.data == 0:
            raise ValidationError(_("Bills can't be null"))
Esempio n. 18
0
class BillOwersForm(FlaskForm):
    weight_validators = [
        NumberRange(min=0, message="Weights should be positive")
    ]
    included = BooleanField("Included in the bill", validators=[])
    person_id = HiddenField("Person Id", validators=[DataRequired()])
    person_name = StringField("Ower")
    weight = CommaDecimalField(_("Weight"),
                               default=1,
                               validators=weight_validators)
Esempio n. 19
0
class InviteForm(FlaskForm):
    emails = StringField(_("People to notify"), render_kw={"class": "tag"})
    submit = SubmitField(_("Send invites"))

    def validate_emails(form, field):
        for email in [email.strip() for email in form.emails.data.split(",")]:
            try:
                email_validator.validate_email(email)
            except email_validator.EmailNotValidError:
                raise ValidationError(
                    _("The email %(email)s is not valid", email=email))
Esempio n. 20
0
class SettingsForm(IndicoForm):
    debug = BooleanField(
        _('Debug mode'),
        widget=SwitchWidget(),
        description=_(
            "If enabled, requests are not sent to the API but logged instead"))
    service_url = URLField(
        _('Service URL'), [URL(require_tld=False)],
        description=_("The URL of the CERN calendar service"))
    username = StringField(
        _('Username'), [DataRequired()],
        description=_(
            "The username used to authenticate with the CERN calendar service")
    )
    password = IndicoPasswordField(
        _('Password'), [DataRequired()],
        toggle=True,
        description=_(
            "The password used to authenticate with the CERN calendar service")
    )
    status = SelectField(
        _('Status'), [DataRequired()],
        choices=_status_choices,
        description=_("The default status of the event in the calendar"))
    reminder = BooleanField(_('Reminder'),
                            description=_("Enable calendar reminder"))
    reminder_minutes = IntegerField(
        _('Reminder time'), [NumberRange(min=0)],
        description=_("Remind users X minutes before the event"))
    id_prefix = StringField(
        _('Prefix'),
        description=_(
            "Prefix for calendar item IDs. If you change this, existing calendar entries "
            "cannot be deleted/updated anymore!"))
    timeout = FloatField(_('Request timeout'), [NumberRange(min=0.25)],
                         description=_("Request timeout in seconds"))
    max_event_duration = TimeDeltaField(
        _('Maximum Duration'), [DataRequired()],
        units=('days', ),
        description=_('Events lasting longer will not be sent to Exchange'))
Esempio n. 21
0
class ProjectForm(EditProjectForm):
    id = StringField(_("Project identifier"), validators=[DataRequired()])
    password = PasswordField(_("Private code"), validators=[DataRequired()])
    submit = SubmitField(_("Create the project"))

    def validate_id(form, field):
        form.id.data = slugify(field.data)
        if (form.id.data == "dashboard") or Project.query.get(form.id.data):
            message = _(
                "A project with this identifier (\"%(project)s\") already exists. "
                "Please choose a new identifier",
                project=form.id.data)
            raise ValidationError(Markup(message))
Esempio n. 22
0
class EditProjectForm(FlaskForm):
    name = StringField(_("Project name"), validators=[Required()])
    password = StringField(_("Private code"), validators=[Required()])
    contact_email = StringField(_("Email"), validators=[Required(), Email()])

    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=self.password.data,
                          contact_email=self.contact_email.data)
        return project

    def update(self, project):
        """Update the project with the information from the form"""
        project.name = self.name.data
        project.password = self.password.data
        project.contact_email = self.contact_email.data

        return project
Esempio n. 23
0
class MenuBuiltinEntryForm(IndicoForm):
    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
Esempio n. 24
0
class ProjectForm(EditProjectForm):
    id = StringField(_("Project identifier"), validators=[Required()])
    password = PasswordField(_("Private code"), validators=[Required()])
    submit = SubmitField(_("Create the project"))

    def validate_id(form, field):
        form.id.data = slugify(field.data)
        if (form.id.data == "dashboard") or Project.query.get(form.id.data):
            message = _("The project identifier is used to log in and for the "
                        "URL of the project. "
                        "We tried to generate an identifier for you but a "
                        "project with this identifier already exists. "
                        "Please create a new identifier that you will be able "
                        "to remember")
            raise ValidationError(Markup(message))
Esempio n. 25
0
class VCRoomFormBase(VCRoomLinkFormBase):
    advanced_fields = {'show'}
    skip_fields = advanced_fields | VCRoomLinkFormBase.conditional_fields

    name = StringField(_('Name'), [DataRequired(), Length(min=3, max=60)], description=_('The name of the room.'))

    def validate_name(self, field):
        if field.data:
            room = VCRoom.find_first(VCRoom.name == field.data, VCRoom.status != VCRoomStatus.deleted,
                                     VCRoom.type == self.service_name)
            if room and room != self.vc_room:
                raise ValidationError(_("There is already a room with this name"))

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.vc_room = kwargs.pop('vc_room')
        self.service_name = current_plugin.service_name
Esempio n. 26
0
class BluejeansAdvancedFormMixin(object):
    # Advanced options (per event)
    ### BEGIN TEST ###
    test_field = StringField(_('Test'), [DataRequired()],
                             description=_('write something here'))
    ### END TEST ###

    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"))
Esempio n. 27
0
class ProjectForm(EditProjectForm):
    id = StringField(_("Project identifier"), validators=[DataRequired()])
    password = PasswordField(_("Private code"), validators=[DataRequired()])
    submit = SubmitField(_("Create the project"))

    def save(self):
        # WTForms Boolean Fields don't insert the default value when the
        # request doesn't include any value the way that other fields do,
        # so we'll manually do it here
        self.project_history.data = LoggingMode.default(
        ) != LoggingMode.DISABLED
        self.ip_recording.data = LoggingMode.default() == LoggingMode.RECORD_IP
        return super().save()

    def validate_id(form, field):
        form.id.data = slugify(field.data)
        if (form.id.data == "dashboard") or Project.query.get(form.id.data):
            message = _(
                'A project with this identifier ("%(project)s") already exists. '
                "Please choose a new identifier",
                project=form.id.data,
            )
            raise ValidationError(Markup(message))
Esempio n. 28
0
class LoginForm(FlaskForm):
    email = StringField("E-mail", validators=[DataRequired(), Email()])
    password = PasswordField("Senha", validators=[DataRequired()])
    submit = SubmitField("Entrar")
Esempio n. 29
0
class MenuUserEntryFormBase(IndicoForm):
    title = StringField(_("Title"), [DataRequired()])
    is_enabled = BooleanField(_("Show"), widget=SwitchWidget())
    new_tab = BooleanField(_("Open in a new tab"), widget=SwitchWidget())
Esempio n. 30
0
class AttachmentLinkFormMixin(object):
    title = StringField(_("Title"), [DataRequired()])
    link_url = URLField(_("URL"), [DataRequired()])