Пример #1
0
class AccessIdentityDataForm(IndicoForm):
    birth_date = IndicoDateField(_('Birth date'), [DataRequired()])
    nationality = SelectField(_('Country of birth'), [DataRequired()])
    birth_place = StringField(_('Place of birth'), [DataRequired()])
    by_car = BooleanField(_('Are you bringing your own car?'), [Optional()], widget=SwitchWidget())
    license_plate = StringField(
        _('License plate'),
        [
            HiddenUnless('by_car'),
            Length(min=3),
            IndicoRegexp(r'^[0-9A-Za-z]+([- ][ ]*[0-9A-Za-z]+)*$',
                         message=_('Wrong format. Only letters and numbers separated by dashes (-) or spaces allowed'))
        ]
    )

    def __init__(self, *args, **kwargs):
        super(AccessIdentityDataForm, self).__init__(*args, **kwargs)
        self.nationality.choices = [('', '')] + sorted(get_countries().iteritems(), key=itemgetter(1))

    def validate_birth_date(self, field):
        if field.data > datetime.now().date():
            raise ValidationError(_('The specified date is in the future'))

    def validate_license_plate(self, field):
        if self.by_car.data and not sanitize_license_plate(field.data):
            raise ValidationError(_('Please insert a valid license plate number!'))
Пример #2
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
Пример #3
0
class EventSettingsForm(PaymentEventSettingsFormBase):
    """Configuration form for the plugin for a specific event."""

    account_id = StringField(
        label=_('Account ID'),
        validators=[DataRequired(),
                    IndicoRegexp(r'^[0-9-]{0,15}$')],
        description=_('The Saferpay account ID, such as "123456-12345678".'))
    order_description = StringField(
        label=_('Order Description'),
        validators=[DataRequired(), FormatField(max_length=80)],
        description=_(
            'The description of each order in a human readable way. '
            'It is presented to the registrant during the transaction with Saferpay. '
            'Supported placeholders: {}').format(', '.join(
                f'{{{p}}}' for p in FormatField.default_field_map)))
    order_identifier = StringField(
        label=_('Order Identifier'),
        validators=[DataRequired(),
                    FormatField(max_length=80, id_safe=True)],
        description=_(
            'The default identifier of each order for further processing. '
            'Supported placeholders: {}').format(', '.join(
                f'{{{p}}}' for p in FormatField.id_safe_field_map)))
    notification_mail = StringField(
        label=_('Notification Email'),
        validators=[DataRequired(), Email(),
                    Length(0, 50)],
        description=_(
            'Email address to receive notifications of transactions. '
            "This is independent of Indico's own payment notifications."))
Пример #4
0
class PluginSettingsForm(PaymentPluginSettingsFormBase):
    """Configuration form for the Plugin across all events."""

    url = URLField(
        label=_('API URL'),
        validators=[DataRequired()],
        description=_('URL to contact the Saferpay JSON API'),
    )
    username = StringField(
        label=_('API username'),
        validators=[DataRequired()],
        description=_('The username to access the SaferPay JSON API'))
    password = IndicoPasswordField(
        label=_('API password'),
        validators=[DataRequired()],
        description=_('The password to access the SaferPay JSON API'),
        toggle=True,
    )
    account_id = StringField(
        label=_('Account ID'),
        validators=[Optional(), IndicoRegexp(r'^[0-9-]{0,15}$')],
        description=_(
            'Default Saferpay account ID, such as "123456-12345678". '
            'Event managers will be able to override this.'))
    order_description = StringField(
        label=_('Order Description'),
        validators=[DataRequired(), FormatField(max_length=80)],
        description=_(
            'The default description of each order in a human readable way. '
            'It is presented to the registrant during the transaction with Saferpay. '
            'Event managers will be able to override this. '
            'Supported placeholders: {}').format(', '.join(
                f'{{{p}}}' for p in FormatField.default_field_map)))
    order_identifier = StringField(
        label=_('Order Identifier'),
        validators=[DataRequired(),
                    FormatField(max_length=80, id_safe=True)],
        description=_(
            'The default identifier of each order for further processing. '
            'Event managers will be able to override this. '
            'Supported placeholders: {}').format(', '.join(
                f'{{{p}}}' for p in FormatField.id_safe_field_map)))
    notification_mail = StringField(
        label=_('Notification Email'),
        validators=[Optional(), Email(), Length(0, 50)],
        description=_(
            'Email address to receive notifications of transactions. '
            "This is independent of Indico's own payment notifications. "
            'Event managers will be able to override this.'))
Пример #5
0
class SettingsForm(IndicoForm):
    # Core settings
    core_site_title = StringField(_('Title'), [DataRequired()], description=_("The global title of this Indico site."))
    core_site_organization = StringField(_('Organization'),
                                         description=_("The organization that runs this Indico site."))

    # Social settings
    social_enabled = BooleanField(_('Enabled'), widget=SwitchWidget())
    social_facebook_app_id = StringField('Facebook App ID', [IndicoRegexp(r'^\d*$')])

    @property
    def _fieldsets(self):
        return [
            (_('Site'), [x for x in self._fields if x.startswith('core_')]),
            (_('Social'), [x for x in self._fields if x.startswith('social_')]),
        ]
Пример #6
0
class VCRoomForm(VCRoomFormBase):
    """Contains all information concerning a Zoom booking."""

    advanced_fields = {
        'mute_audio', 'mute_host_video', 'mute_participant_video'
    } | VCRoomFormBase.advanced_fields

    skip_fields = advanced_fields | VCRoomFormBase.conditional_fields

    meeting_type = IndicoRadioField(
        _('Meeting Type'),
        description=_('The type of Zoom meeting to be created'),
        orientation='horizontal',
        choices=[('regular', _('Regular Meeting')), ('webinar', _('Webinar'))])

    host_choice = IndicoRadioField(_('Meeting Host'), [DataRequired()],
                                   choices=[('myself', _('Myself')),
                                            ('someone_else', _('Someone else'))
                                            ])

    host_user = PrincipalField(
        _('User'),
        [HiddenUnless('host_choice', 'someone_else'),
         DataRequired()])

    password = StringField(
        _('Passcode'),
        [DataRequired(), IndicoRegexp(r'^\d{8,10}$')],
        description=_('Meeting passcode (8-10 digits)'))

    password_visibility = IndicoRadioField(
        _('Passcode visibility'),
        description=_("Who should be able to know this meeting's passcode"),
        orientation='horizontal',
        choices=[('everyone', _('Everyone')),
                 ('logged_in', _('Logged-in users')),
                 ('registered', _('Registered participants')),
                 ('no_one', _('No one'))])

    mute_audio = BooleanField(
        _('Mute audio'),
        widget=SwitchWidget(),
        description=_('Participants will join the VC room muted by default '))

    mute_host_video = BooleanField(
        _('Mute video (host)'),
        widget=SwitchWidget(),
        description=_('The host will join the VC room with video disabled'))

    mute_participant_video = BooleanField(
        _('Mute video (participants)'),
        widget=SwitchWidget(),
        description=_(
            'Participants will join the VC room with video disabled'))

    waiting_room = BooleanField(
        _('Waiting room'),
        widget=SwitchWidget(),
        description=_(
            'Participants may be kept in a waiting room by the host'))

    description = TextAreaField(
        _('Description'), description=_('Optional description for this room'))

    def __init__(self, *args, **kwargs):
        defaults = kwargs['obj']
        if defaults.host_user is None and defaults.host is not None:
            host = principal_from_identifier(defaults.host)
            defaults.host_choice = 'myself' if host == session.user else 'someone_else'
            defaults.host_user = None if host == session.user else host

        allow_webinars = current_plugin.settings.get('allow_webinars')

        if allow_webinars:
            for field_name in {
                    'mute_audio', 'mute_participant_video', 'waiting_room'
            }:
                inject_validators(self, field_name,
                                  [HiddenUnless('meeting_type', 'regular')])

        super().__init__(*args, **kwargs)

        if not allow_webinars:
            del self.meeting_type

    def validate_host_choice(self, field):
        if field.data == 'myself':
            self._check_zoom_user(session.user)

    def validate_host_user(self, field):
        if self.host_choice.data == 'someone_else':
            self._check_zoom_user(field.data)

    def _check_zoom_user(self, user):
        if find_enterprise_email(user) is None:
            raise ValidationError(_('This user has no Zoom account'))

    def validate_name(self, field):
        # Duplicate names are fine on Zoom
        pass

    @generated_data
    def host(self):
        if self.host_choice is None:
            return None
        elif self.host_choice.data == 'myself':
            return session.user.identifier
        else:
            return self.host_user.data.identifier if self.host_user.data else None