Beispiel #1
0
class SessionProtectionForm(fossirForm):
    protection_mode = fossirProtectionField(
        _('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,
        default_text=_('Restrict access to this session'),
        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)
Beispiel #2
0
class CategoryProtectionForm(fossirForm):
    _event_creation_fields = ('event_creation_restricted', 'event_creators', 'event_creation_notification_emails')

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

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

    def _init_visibility(self, category):
        self.visibility.choices = get_visibility_options(category, allow_invisible=False)
        # Check if category visibility would be affected by any of the parents
        real_horizon = category.real_visibility_horizon
        own_horizon = category.own_visibility_horizon
        if real_horizon and real_horizon.is_descendant_of(own_horizon):
            self.visibility.warning = _("This category's visibility is currently limited by that of '{}'.").format(
                real_horizon.title)
Beispiel #3
0
class PaperTeamsForm(fossirForm):
    managers = PrincipalListField(
        _('Paper managers'),
        groups=True,
        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
Beispiel #4
0
class VCPluginSettingsFormBase(fossirForm):
    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).'))
class RegistrationManagersForm(fossirForm):
    """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'))
Beispiel #6
0
class AbstractSubmissionSettingsForm(fossirForm):
    """Settings form for abstract submission"""

    announcement = fossirMarkdownField(_('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"))
    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 = fossirMarkdownField(
        _('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.'))
Beispiel #7
0
class SettingsForm(fossirForm):
    admin_principals = PrincipalListField(_('Administrators'), groups=True)
    authorized_principals = PrincipalListField(_('Authorized users/groups'),
                                               groups=True)
    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)
class EditGroupForm(fossirForm):
    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.'))
class CreateMultipleRegistrationsForm(fossirForm):
    """Form to create multiple registrations of fossir users at the same time."""

    user_principals = PrincipalListField(_("fossir 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))
Beispiel #10
0
class BlockingForm(fossirForm):
    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)
class AdminsForm(fossirForm):
    admins = PrincipalListField(_('Admins'), [DataRequired()])
class EventProtectionForm(fossirForm):
    protection_mode = fossirProtectionField(
        _('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 = fossirPasswordField(
        _('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)