Example #1
0
class SettingsForm(IndicoForm):
    admin_principals = PrincipalListField(_('Administrators'), groups=True)
    authorized_principals = PrincipalListField(_('Authorized users/groups'),
                                               groups=True)
    excluded_categories = MultipleItemsField(
        _('Excluded categories'),
        fields=[{
            'id': 'id',
            'caption': 'Category ID'
        }],
        description=_(
            'Disable quick-book on event creation in these categories'))
    assistance_emails = EmailListField(
        _('Assistance email addresses (one per line)'))
    notification_before_days = IntegerField(
        _('Send booking reminders X days before (single/daily)'),
        [InputRequired(), NumberRange(min=1, max=30)])
    notification_before_days_weekly = IntegerField(
        _('Send booking reminders X days before (weekly)'),
        [InputRequired(), NumberRange(min=1, max=30)])
    notification_before_days_monthly = IntegerField(
        _('Send booking reminders X days before (monthly)'),
        [InputRequired(), NumberRange(min=1, max=30)])
    notifications_enabled = BooleanField(_('Reminders enabled'))
    vc_support_emails = EmailListField(
        _('Videoconference support email addresses (one per line)'))
    booking_limit = IntegerField(
        _('Maximum length of booking (days)'),
        [InputRequired(), NumberRange(min=1)])
    google_maps_api_key = StringField(_('Google Maps API key'),
                                      description=GOOGLE_API_KEY_DESC)
Example #2
0
class EventProtectionForm(IndicoForm):
    protection_mode = IndicoProtectionField(_('Protection mode'),
                                            protected_object=lambda form: form.protected_object,
                                            acl_message_url=lambda form: url_for('event_management.acl_message',
                                                                                 form.protected_object))
    acl = AccessControlListField(_('Access control list'), groups=True, allow_emails=True, allow_networks=True,
                                 allow_external=True, default_text=_('Restrict access to this event'),
                                 description=_('List of users allowed to access the event.'))
    access_key = IndicoPasswordField(_('Access key'), toggle=True,
                                     description=_('It is more secure to use only the ACL and not set an access key. '
                                                   '<strong>It will have no effect if the event is not '
                                                   'protected</strong>'))
    own_no_access_contact = StringField(_('No access contact'),
                                        description=_('Contact information shown when someone lacks access to the '
                                                      'event'))
    managers = PrincipalListField(_('Managers'), groups=True, allow_emails=True, allow_external=True,
                                  description=_('List of users allowed to modify the event'))
    submitters = PrincipalListField(_('Submitters'), allow_emails=True, allow_external=True,
                                    description=_('List of users with submission rights'))
    priv_fields = set()

    def __init__(self, *args, **kwargs):
        self.protected_object = kwargs.pop('event')
        super(EventProtectionForm, self).__init__(*args, **kwargs)

    @classmethod
    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)
Example #3
0
class CategoryProtectionForm(IndicoForm):
    _event_creation_fields = ('event_creation_restricted', 'event_creators',
                              'event_creation_notification_emails')

    protection_mode = IndicoProtectionField(
        _('Protection mode'),
        protected_object=lambda form: form.protected_object)
    acl = AccessControlListField(_('Access control list'),
                                 groups=True,
                                 allow_external=True,
                                 allow_networks=True)
    managers = PrincipalListField(_('Managers'), groups=True)
    own_no_access_contact = StringField(
        _('No access contact'),
        description=_(
            'Contact information shown when someone lacks access to the '
            'category'))
    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 = kwargs.pop('category')
        super(CategoryProtectionForm, self).__init__(*args, **kwargs)
Example #4
0
class PaperTeamsForm(IndicoForm):
    managers = PrincipalListField(
        _('Paper managers'),
        groups=True,
        event=lambda form: form.event,
        description=_('List of users allowed to manage the call for papers'))
    judges = PrincipalListField(
        _('Judges'), description=_('List of users allowed to judge papers'))
    content_reviewers = PrincipalListField(
        _('Content reviewers'),
        description=_(
            'List of users allowed to review the content of the assigned '
            'papers'))
    layout_reviewers = PrincipalListField(
        _('Layout reviewers'),
        description=_(
            'List of users allowed to review the layout of the assigned '
            'papers'))

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(PaperTeamsForm, self).__init__(*args, **kwargs)
        if not self.event.cfp.content_reviewing_enabled:
            del self.content_reviewers
        if not self.event.cfp.layout_reviewing_enabled:
            del self.layout_reviewers
Example #5
0
class VCPluginSettingsFormBase(IndicoForm):
    managers = PrincipalListField(_('Managers'), groups=True, description=_('Service managers'))
    acl = PrincipalListField(_('ACL'), groups=True,
                             description=_('Users and Groups authorised to create videoconference rooms'))
    notification_emails = EmailListField(_('Notification email addresses'),
                                         description=_('Notifications about videoconference rooms are sent to '
                                                       'these email addresses (one per line).'))
Example #6
0
class CategoryProtectionForm(IndicoForm):
    _event_creation_fields = ('event_creation_restricted', 'event_creators', 'event_creation_notification_emails')

    protection_mode = IndicoProtectionField(_('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)
Example #7
0
class ContributionProtectionForm(IndicoForm):
    protection_mode = IndicoProtectionField(
        _('Protection mode'),
        protected_object=lambda form: form.protected_object,
        acl_message_url=lambda form: url_for('contributions.acl_message', form.
                                             protected_object))
    acl = AccessControlListField(
        _('Access control list'),
        [UsedIf(lambda form, field: form.protected_object.is_protected)],
        groups=True,
        allow_emails=True,
        default_text=_('Restrict access to this contribution'),
        description=_('List of users allowed to access the contribution'))
    managers = PrincipalListField(
        _('Managers'),
        groups=True,
        allow_emails=True,
        description=_('List of users allowed to modify the contribution'))
    submitters = PrincipalListField(
        _('Submitters'),
        groups=True,
        allow_emails=True,
        description=_(
            'List of users allowed to submit materials for this contribution'))

    def __init__(self, *args, **kwargs):
        self.protected_object = kwargs.pop('contrib')
        super(ContributionProtectionForm, self).__init__(*args, **kwargs)
Example #8
0
class SettingsForm(IndicoForm):
    admin_principals = PrincipalListField(_(u'Administrators'), groups=True)
    authorized_principals = PrincipalListField(_(u'Authorized users/groups'), groups=True)
    assistance_emails = EmailListField(_(u'Assistance email addresses (one per line)'))
    notification_hour = IntegerField(_(u'Hour at which booking reminders should be sent'),
                                     [InputRequired(), NumberRange(0, 23)])
    notification_before_days = IntegerField(_(u'Send booking reminders X days before'),
                                            [InputRequired(), NumberRange(min=1, max=9)])
    notifications_enabled = BooleanField(_(u'Reminders enabled'))
    vc_support_emails = EmailListField(_(u'Videoconference support email addresses (one per line)'))
Example #9
0
class EventProtectionForm(IndicoForm):
    protection_mode = IndicoProtectionField(_('Protection mode'),
                                            protected_object=lambda form: form.protected_object,
                                            acl_message_url=lambda form: url_for('event_management.acl_message',
                                                                                 form.protected_object))
    acl = AccessControlListField(_('Access control list'), groups=True, allow_emails=True, allow_networks=True,
                                 allow_external=True, default_text=_('Restrict access to this event'),
                                 description=_('List of users allowed to access the event.'))
    access_key = IndicoPasswordField(_('Access key'), toggle=True,
                                     description=_('It is more secure to use only the ACL and not set an access key. '
                                                   '<strong>It will have no effect if the event is not '
                                                   'protected</strong>'))
    own_no_access_contact = StringField(_('No access contact'),
                                        description=_('Contact information shown when someone lacks access to the '
                                                      'event'))
    managers = PrincipalListField(_('Managers'), groups=True, allow_emails=True, allow_external=True,
                                  description=_('List of users allowed to modify the event'))
    submitters = PrincipalListField(_('Submitters'), groups=True, allow_emails=True, allow_external=True,
                                    description=_('List of users with submission rights'))
    visibility = SelectField(_("Visibility"), [Optional()], coerce=lambda x: None if x == '' else int(x),
                             description=_("""From which point in the category tree this event will be visible from """
                                           """(number of categories upwards). Applies to "Today's events" and """
                                           """Calendar only. If the event is moved, this number will be preserved."""))
    priv_fields = set()

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

    def _get_event_own_visibility_horizon(self, event):
        if self.visibility.data is None:  # unlimited
            return Category.get_root()
        elif self.visibility.data == 0:  # invisible
            return None
        else:
            return event.category.nth_parent(self.visibility.data - 1)

    def _init_visibility(self, event):
        self.visibility.choices = get_visibility_options(event, allow_invisible=True)
        # Check if event visibility would be affected by any of the categories
        real_horizon = event.category.real_visibility_horizon
        own_horizon = self._get_event_own_visibility_horizon(event)
        if own_horizon and real_horizon and real_horizon.is_descendant_of(own_horizon):
            self.visibility.warning = _("This event's visibility is currently limited by that of '{}'.").format(
                real_horizon.title)

    @classmethod
    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)
Example #10
0
class PluginSettingsForm(IndicoForm):
    managers = PrincipalListField(_('Managers'), groups=True,
                                  description=_('List of users who can manage recording/webcast requests.'))
    notification_emails = EmailListField(_('Notification email addresses'),
                                         description=_('Notifications about recording/webcast requests are sent to '
                                                       'these email addresses (one per line).'))
    notification_reply_email = StringField(_('E-mail notification "reply" address'),
                                           [IndicoEmail()],
                                           description=_('Notifications that are sent to event managers will use '
                                                         'this address in their "Reply-To:" fields.'))
    webcast_audiences = MultipleItemsField(_('Webcast Audiences'),
                                           fields=[{'id': 'audience', 'caption': _('Audience'), 'required': True}],
                                           unique_field='audience',
                                           description=_('List of audiences for non-public webcasts.'))
    webcast_ping_url = URLField(_('Webcast Ping URL'),
                                description=_("A ping is sent via HTTP GET to this URL whenever a webcast request "
                                              "enters/leaves the 'accepted' state."))
    webcast_url = URLField(_('Webcast URL'), [DataRequired()],
                           description=_("The URL to watch the webcast for an event. Can contain {event_id} which "
                                         "will be replaced with the ID of the event."))
    agreement_paper_url = URLField(_('Agreement Paper URL'),
                                   description=_("The URL to the agreement that can be printed and signed offline."))
    recording_cds_url = URLField(_('CDS URL'),
                                 description=_("The URL used when creating recording links. Must contain the {cds_id} "
                                               "placeholder."))
    room_feature = QuerySelectField(_("Room feature"), [DataRequired()], allow_blank=True,
                                    query_factory=lambda: RoomFeature.query, get_label='title',
                                    description=_("The feature indicating that a room supports webcast/recording."))

    def validate_recording_cds_url(self, field):
        if field.data and '{cds_id}' not in field.data:
            raise ValidationError('{cds_id} placeholder is missing')
Example #11
0
class VCRoomForm(VCRoomFormBase, BBBAdvancedFormMixin):
    advanced_fields = [
        'welcome', 'record', 'auto_start_recording',
        'allow_start_stop_recording', 'mute_on_start',
        'allow_mods_to_unmute_users', 'webcams_only_for_moderator',
        'lock_settings_disable_cam', 'lock_settings_disable_mic',
        'lock_setiings_disable_private_chat',
        'lock_settings_disable_public_chat', 'lock_settings_disable_note',
        'lock_settings_locked_layout', 'guest_policy', 'show'
    ]
    skip_fields = set(advanced_fields) | VCRoomFormBase.conditional_fields

    mod_users = PrincipalListField(_('Moderators'), [DataRequired()])

    @generated_data
    def moderators(self):
        return list(mod_user.as_principal for mod_user in self.mod_users.data)

    def __init__(self, *args, **kwargs):
        defaults = kwargs['obj']
        if defaults.mod_users is None and defaults.moderators is not None:
            defaults.mod_users = set()
            for moderator in defaults.moderators:
                defaults.mod_users.add(retrieve_principal(moderator))
        if defaults.mod_users is None:
            defaults.mod_users = [session.user]
        super(VCRoomForm, self).__init__(*args, **kwargs)
Example #12
0
class PluginSettingsForm(PaymentPluginSettingsFormBase):
    authorized_users = PrincipalListField(
        _('Authorized users'),
        allow_groups=True,
        description=_(
            'List of users/groups who are authorized to configure the CERN '
            'Payment module for any event.'))
    fp_email_address = EmailField(
        _('FP email adress'), [DataRequired()],
        description=_('Email address to contact FP.'))
    fp_department_name = StringField(_('FP department name'), [DataRequired()])
    payment_url = URLField(_('Payment URL'), [DataRequired()],
                           description=_('URL used for the epayment'))
    shop_id_chf = StringField(_('Shop ID (CHF)'), [DataRequired()])
    shop_id_eur = StringField(_('Shop ID (EUR)'), [DataRequired()])
    hash_seed_chf = StringField(_('Hash seed (CHF)'), [DataRequired()])
    hash_seed_eur = StringField(_('Hash seed (EUR)'), [DataRequired()])
    hash_seed_out_chf = StringField(_('Hash seed out (CHF)'), [DataRequired()])
    hash_seed_out_eur = StringField(_('Hash seed out (EUR)'), [DataRequired()])
    server_url_suffix = StringField(
        _('Server URL Suffix'),
        description='Server URL Suffix (indico[suffix].cern.ch)')
    order_id_prefix = StringField(_('Order ID Prefix'))
    payment_methods = MultipleItemsField(_('Payment Methods'),
                                         fields=PAYMENT_METHODS_FIELDS,
                                         unique_field='name')
Example #13
0
class PluginSettingsForm(IndicoForm):
    adams_url = URLField(_('ADaMS URL'), [DataRequired()],
                         description=_('The URL of the ADaMS REST API'))
    username = StringField(_('Username'), [DataRequired()],
                           description=_('The login used to authenticate with ADaMS service'))
    password = IndicoPasswordField(_('Password'), [DataRequired()],
                                   description=_('The password used to authenticate with ADaMS service'))
    secret_key = IndicoPasswordField(_('Secret key'), [DataRequired()],
                                     description=_('Secret key to sign ADaMS requests'))
    authorized_users = PrincipalListField(_('Authorized users'), allow_groups=True,
                                          description=_('List of users/groups who can send requests'))
    excluded_categories = MultipleItemsField('Excluded categories', fields=[{'id': 'id', 'caption': 'Category ID'}])
    access_ticket_template = QuerySelectField(_("Access ticket template"), allow_blank=True,
                                              blank_text=_("No access ticket selected"), get_label='title',
                                              description=_("Ticket template allowing access to CERN"))
    earliest_start_dt = IndicoDateTimeField(_("Earliest start date"), [Optional()], default_time=time(0, 0),
                                            description=_("The earliest date an event can start to qualify for CERN "
                                                          "access badges"))
    delete_personal_data_after = TimeDeltaField(_('Delete personal data'), [DataRequired()], units=('days',),
                                                description=_('Personal data will be deleted once the event has '
                                                              'finished and the duration specified here has been '
                                                              'exceeded. Once the data has been deleted, access badges '
                                                              'will not be accessible anymore.'))
    api_username = StringField(_('Username'), [DataRequired()], description=_('The username to access the API'))
    api_password = IndicoPasswordField(_('Password'), [DataRequired()], toggle=True,
                                       description=_('The password to access the API'))

    def __init__(self, *args, **kwargs):
        super(PluginSettingsForm, self).__init__(*args, **kwargs)
        self.access_ticket_template.query = (DesignerTemplate.query
                                             .filter(DesignerTemplate.category_id == 0,
                                                     DesignerTemplate.type == TemplateType.badge)
                                             .order_by(db.func.lower(DesignerTemplate.title)))
Example #14
0
class PluginSettingsForm(IndicoForm):
    managers = PrincipalListField(_('Managers'), groups=True,
                                  description=_('List of users who can manage recording/webcast requests.'))
    notification_emails = EmailListField(_('Notification email addresses'),
                                         description=_('Notifications about recording/webcast requests are sent to '
                                                       'these email addresses (one per line).'))
    webcast_audiences = MultipleItemsField(_('Webcast Audiences'),
                                           fields=[{'id': 'audience', 'caption': _('Audience'), 'required': True}],
                                           unique_field='audience',
                                           description=_('List of audiences for non-public webcasts.'))
    webcast_ping_url = URLField(_('Webcast Ping URL'),
                                description=_("A ping is sent via HTTP GET to this URL whenever a webcast request "
                                              "enters/leaves the 'accepted' state."))
    webcast_url = URLField(_('Webcast URL'), [DataRequired()],
                           description=_("The URL to watch the webcast for an event. Can contain {event_id} which "
                                         "will be replaced with the ID of the event."))
    agreement_paper_url = URLField(_('Agreement Paper URL'),
                                   description=_("The URL to the agreement that can be printed and signed offline."))
    recording_cds_url = URLField(_('CDS URL'),
                                 description=_("The URL used when creating recording links. Must contain the {cds_id} "
                                               "placeholder."))

    def validate_recording_cds_url(self, field):
        if field.data and '{cds_id}' not in field.data:
            raise ValidationError('{cds_id} placeholder is missing')
Example #15
0
class RoomAssistanceForm(IndicoForm):
    _fieldsets = [
        ('Startup assistance emails', [
            'room_assistance_recipients', 'rooms_with_assistance',
            'room_assistance_support'
        ]),
    ]

    room_assistance_recipients = EmailListField(
        _('Recipients'),
        description=_('Notifications about room assistance requests are sent '
                      'to these email addresses (one per line)'))
    rooms_with_assistance = IndicoQuerySelectMultipleField(
        'Rooms',
        query_factory=lambda: Room.query,
        description=_('Rooms for which users can request startup '
                      'assistance'),
        get_label='full_name',
        collection_class=set,
        render_kw={'size': 20},
        modify_object_list=_order_func)
    room_assistance_support = PrincipalListField(
        _('Room assistance support'),
        groups=True,
        description=_('List of users who can view the list of events with '
                      'room startup assistance.'))
Example #16
0
class AttachmentFolderForm(IndicoForm):
    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 = PrincipalListField(_("Grant Access To"), [UsedIf(lambda form, field: form.protected.data)],
                             groups=True, serializable=False, allow_external=True,
                             description=_("The list of users and groups with access to 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,
                                                                   linked_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
Example #17
0
class RegistrationManagersForm(IndicoForm):
    """Form to manage users with privileges to modify registration-related items"""

    managers = PrincipalListField(
        _('Registration managers'),
        groups=True,
        allow_emails=True,
        allow_external=True,
        description=_('List of users allowed to modify registrations'))
Example #18
0
class AbstractSubmissionSettingsForm(IndicoForm):
    """Settings form for abstract submission"""

    announcement = IndicoMarkdownField(_('Announcement'), editor=True)
    allow_multiple_tracks = BooleanField(
        _('Multiple tracks'),
        widget=SwitchWidget(),
        description=_("Allow the selection of multiple tracks"))
    tracks_required = BooleanField(
        _('Require tracks'),
        widget=SwitchWidget(),
        description=_("Make the track selection mandatory"))
    contrib_type_required = BooleanField(
        _('Require contrib. type'),
        widget=SwitchWidget(),
        description=_("Make the selection of a contribution type mandatory"))
    allow_attachments = BooleanField(
        _('Allow attachments'),
        widget=SwitchWidget(),
        description=_("Allow files to be attached to the abstract"))
    copy_attachments = BooleanField(
        _('Copy attachments'), [HiddenUnless('allow_attachments')],
        widget=SwitchWidget(),
        description=_(
            "Copy attachments to the contribution when accepting an abstract"))
    allow_speakers = BooleanField(
        _('Allow speakers'),
        widget=SwitchWidget(),
        description=_("Allow the selection of the abstract speakers"))
    speakers_required = BooleanField(
        _('Require a speaker'), [HiddenUnless('allow_speakers')],
        widget=SwitchWidget(),
        description=_(
            "Make the selection of at least one author as speaker mandatory"))
    authorized_submitters = PrincipalListField(
        _("Authorized submitters"),
        description=_("These users may always submit abstracts, even outside "
                      "the regular submission period."))
    submission_instructions = IndicoMarkdownField(
        _('Instructions'),
        editor=True,
        description=_("These instructions will be displayed right before the "
                      "submission form."))

    @generated_data
    def announcement_render_mode(self):
        return RenderMode.markdown

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(AbstractSubmissionSettingsForm, self).__init__(*args, **kwargs)

    def validate_contrib_type_required(self, field):
        if field.data and not self.event.contribution_types.count():
            raise ValidationError(
                _('The event has no contribution types defined.'))
Example #19
0
class RegistrationManagersForm(IndicoForm):
    """Form to manage users with privileges to modify registration-related items"""

    managers = PrincipalListField(_('Registration managers'), groups=True, allow_emails=True, allow_external=True,
                                  description=_('List of users allowed to modify registrations'),
                                  event=lambda form: form.event)

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(RegistrationManagersForm, self).__init__(*args, **kwargs)
class SettingsForm(IndicoForm):
    admins = PrincipalListField(
        _('Administrators'),
        groups=True,
        description=_(
            'List of users/groups who can manage chatrooms for all events'))
    server = StringField(_('XMPP server'), [DataRequired()],
                         description=_('The hostname of the XMPP server'))
    muc_server = StringField(
        _('XMPP MUC server'), [DataRequired()],
        description=_("The hostname of the XMPP MUC server"))
    bot_jid = StringField(
        _('Bot JID'), [DataRequired()],
        description=_(
            "Jabber ID of the XMPP bot. Can be just a username (in that case the default "
            "server is assumed) or a username@server."))
    bot_password = IndicoPasswordField(_('Bot Password'), [DataRequired()],
                                       toggle=True,
                                       description=_("Password for the bot"))
    notify_emails = EmailListField(
        _('Notification emails'),
        description=_(
            "Email addresses to sent notifications to (one per line)"))
    log_url = URLField(
        _('Log URL'),
        description=_(
            'You can set this to the URL of the '
            '<a href="https://github.com/indico/jabber-logs/">jabber-logs '
            'app</a>, running on the jabber server to let event managers can '
            'retrieve chat logs for rooms on that server.'))
    chat_links = MultipleItemsField(
        _('Chatroom links'),
        fields=[{
            'id': 'title',
            'caption': _("Title"),
            'required': True
        }, {
            'id': 'link',
            'caption': _("Link"),
            'required': True
        }],
        description=_(
            "Links to join the chatroom. You can use the placeholders {room} for "
            "the room name and {server} for the MUC server."))
    how_to_connect = TextAreaField(
        _('How to connect'),
        widget=CKEditorWidget(),
        description=_("Text shown below the chatrooms on an event page"))

    def validate_chat_links(self, field):
        for item in field.data:
            if not all(item.values()):
                raise ValidationError(_('All fields must contain a value.'))
Example #21
0
class PluginSettingsForm(IndicoForm):
    authorized = PrincipalListField(
        _('Authorized users'),
        groups=True,
        description=_(
            'List of users who can request videoconference assistance.'))
    vc_support = PrincipalListField(
        _('Videoconference support'),
        groups=True,
        description=_(
            'List of users who can view the list of events with videoconference '
            'assistance.'))
    support_email = EmailField(
        _('Support email'), [DataRequired()],
        description=_('Videoconference email support address'))
    room_feature = QuerySelectField(
        _("Room feature"), [DataRequired()],
        allow_blank=True,
        query_factory=lambda: RoomFeature.query,
        get_label='title',
        description=_(
            "The feature indicating that a room supports videoconference."))
Example #22
0
class EditGroupForm(IndicoForm):
    name = StringField(_('Group name'), [DataRequired()])
    members = PrincipalListField(_('Group members'))

    def __init__(self, *args, **kwargs):
        self.group = kwargs.pop('group', None)
        super(EditGroupForm, self).__init__(*args, **kwargs)

    def validate_name(self, field):
        query = LocalGroup.find(db.func.lower(LocalGroup.name) == field.data.lower())
        if self.group:
            query = query.filter(LocalGroup.id != self.group.id)
        if query.count():
            raise ValidationError(_('A group with this name already exists.'))
Example #23
0
class SessionProtectionForm(IndicoForm):
    protection_mode = IndicoProtectionField(
        _('Protection mode'),
        protected_object=lambda form: form.protected_object,
        acl_message_url=lambda form: url_for('sessions.acl_message', form.
                                             protected_object))
    acl = AccessControlListField(
        _('Access control list'),
        [UsedIf(lambda form, field: form.protected_object.is_protected)],
        groups=True,
        allow_emails=True,
        description=_('List of users allowed to access the session.'))
    managers = PrincipalListField(
        _('Managers'),
        groups=True,
        allow_emails=True,
        description=_('List of users allowed to modify the session'))
    coordinators = PrincipalListField(_('Coordinators'),
                                      groups=True,
                                      allow_emails=True)

    def __init__(self, *args, **kwargs):
        self.protected_object = kwargs.pop('session')
        super(SessionProtectionForm, self).__init__(*args, **kwargs)
Example #24
0
class VCRoomAttachForm(VCRoomAttachFormBase):

    mod_users = PrincipalListField(_('Moderators'), [DataRequired()])

    @generated_data
    def moderators(self):
        return list(mod_user.as_principal for mod_user in self.mod_users.data)

    def __init__(self, *args, **kwargs):
        defaults = kwargs['obj']

        if defaults.mod_users is None and defaults.moderators is not None:
            defaults.mod_users = set()
            for moderator in defaults.moderators:
                defaults.mod_users.add(retrieve_principal(moderator))
        if defaults.mod_users is None:
            defaults.mod_users = [session.user]
        super(VCRoomAttachForm, self).__init__(*args, **kwargs)
Example #25
0
class AttachmentFormBase(IndicoForm):
    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 = PrincipalListField(_("Grant Access To"), [UsedIf(lambda form, field: form.protected.data)],
                             groups=True, serializable=False, allow_external=True,
                             description=_("The list of users and groups with access to the material"))

    def __init__(self, *args, **kwargs):
        linked_object = kwargs.pop('linked_object')
        super(AttachmentFormBase, self).__init__(*args, **kwargs)
        self.folder.query = (AttachmentFolder
                             .find(linked_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
Example #26
0
class CreateMultipleRegistrationsForm(IndicoForm):
    """Form to create multiple registrations of Indico users at the same time."""

    user_principals = PrincipalListField(_("Indico users"), [DataRequired()])
    notify_users = BooleanField(_("Send e-mail notifications"),
                                default=True,
                                description=_("Notify the users about the registration."),
                                widget=SwitchWidget())

    def __init__(self, *args, **kwargs):
        self._regform = kwargs.pop('regform')
        open_add_user_dialog = kwargs.pop('open_add_user_dialog', False)
        super(CreateMultipleRegistrationsForm, self).__init__(*args, **kwargs)
        self.user_principals.open_immediately = open_add_user_dialog

    def validate_user_principals(self, field):
        for user in field.data:
            if user.registrations.filter_by(registration_form=self._regform, is_deleted=False).one_or_none():
                raise ValidationError(_("A registration for {} already exists.").format(user.full_name))
Example #27
0
class BlockingForm(IndicoForm):
    reason = TextAreaField(_(u'Reason'), [DataRequired()])
    principals = PrincipalListField(groups=True, allow_external=True)
    blocked_rooms = JSONField(default=[])

    def validate_blocked_rooms(self, field):
        try:
            field.data = map(int, field.data)
        except Exception as e:
            # In case someone sent crappy data
            raise ValidationError(str(e))

        # Make sure all room ids are valid
        if len(field.data) != Room.find(Room.id.in_(field.data)).count():
            raise ValidationError('Invalid rooms')

        if hasattr(self, '_blocking'):
            start_date = self._blocking.start_date
            end_date = self._blocking.end_date
            blocking_id = self._blocking.id
        else:
            start_date = self.start_date.data
            end_date = self.end_date.data
            blocking_id = None

        overlap = BlockedRoom.find_first(
            BlockedRoom.room_id.in_(field.data),
            BlockedRoom.state != BlockedRoom.State.rejected,
            Blocking.start_date <= end_date,
            Blocking.end_date >= start_date,
            Blocking.id != blocking_id,
            _join=Blocking)
        if overlap:
            msg = 'Your blocking for {} is overlapping with another blocking.'.format(
                overlap.room.full_name)
            raise ValidationError(msg)
Example #28
0
class AdminsForm(IndicoForm):
    admins = PrincipalListField(_('Admins'), [DataRequired()])