Example #1
0
class VCPluginSettingsFormBase(IndicoForm):
    managers = PrincipalListField(_('Managers'), allow_groups=True, description=_('Service managers'))
    acl = PrincipalListField(_('ACL'), allow_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 #2
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().__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 #3
0
class InvitationFormExisting(InvitationFormBase):
    _invitation_fields = (
        'users_field', ) + InvitationFormBase._invitation_fields
    users_field = PrincipalListField(
        _('Users'), [DataRequired()],
        allow_external_users=True,
        description=_("Select the users to invite."))

    @generated_data
    def users(self):
        return [{
            'first_name': x.first_name,
            'last_name': x.last_name,
            'email': x.email.lower(),
            'affiliation': x.affiliation
        } for x in self.users_field.data]

    def validate_users_field(self, field):
        emails = {x.email.lower() for x in field.data}
        # invitations
        existing = {x.email for x in self.regform.invitations} & emails
        if existing:
            raise ValidationError(
                _("There are already invitations for the following email addresses: {emails}"
                  ).format(emails=', '.join(sorted(existing))))
        # registrations
        existing = {
            x.email
            for x in self.regform.registrations if x.is_active
        } & emails
        if existing:
            raise ValidationError(
                _("There are already registrations with the following email addresses: {emails}"
                  ).format(emails=', '.join(sorted(existing))))
Example #4
0
class CreateMultipleRegistrationsForm(IndicoForm):
    """
    Form to create multiple registrations of Indico users at the same time.
    """

    user_principals = PrincipalListField(_("Indico users"), [DataRequired()],
                                         allow_external_users=True)
    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().__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 in db.session and self._regform.get_registration(
                    user=user):
                raise ValidationError(
                    _("A registration for {} already exists.").format(
                        user.full_name))
            elif self._regform.get_registration(email=user.email):
                raise ValidationError(
                    _("A registration for {} already exists.").format(
                        user.email))
Example #5
0
class PaperTeamsForm(IndicoForm):
    managers = PrincipalListField(_('Paper managers'), allow_groups=True, allow_emails=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().__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 #6
0
class RegistrationManagersForm(IndicoForm):
    """
    Form to manage users with privileges to modify registration-related items.
    """

    managers = PrincipalListField(_('Registration managers'), allow_groups=True, allow_emails=True,
                                  allow_external_users=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().__init__(*args, **kwargs)
Example #7
0
class UnlistedEventsForm(IndicoForm):
    enabled = BooleanField(_('Enabled'), widget=SwitchWidget(), default=False)
    restricted = BooleanField(
        _('Restrict creation'), [HiddenUnless('enabled', preserve_data=True)],
        widget=SwitchWidget(),
        description=
        _('Restrict creation of unlisted events to the authorized users below.'
          ))
    authorized_creators = PrincipalListField(
        _('Authorized users'), [HiddenUnless('enabled', preserve_data=True)],
        allow_external_users=True,
        allow_groups=True,
        description=_('These users may create unlisted events.'))
Example #8
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().__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 #9
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'))
    allow_editing = IndicoEnumSelectField(_('Allow editing'), enum=AllowEditingType, sorted=True,
                                          description=_('Specify who will be able to edit the abstract'))
    contribution_submitters = IndicoEnumSelectField(_('Contribution submitters'),
                                                    enum=SubmissionRightsType, sorted=True,
                                                    description=_('Specify who will get contribution submission rights '
                                                                  'once an abstract has been accepted'))
    authorized_submitters = PrincipalListField(_('Authorized submitters'), event=lambda form: form.event,
                                               allow_external_users=True, allow_groups=True,
                                               allow_event_roles=True, allow_category_roles=True,
                                               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().__init__(*args, **kwargs)
        if self.event and self.event.is_unlisted:
            self.authorized_submitters.allow_category_roles = False

    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.'))