Beispiel #1
0
class EmailEventPersonsForm(IndicoForm):
    from_address = SelectField(_('From'), [DataRequired()])
    subject = StringField(_('Subject'), [DataRequired()])
    body = TextAreaField(_('Email body'), [DataRequired()],
                         widget=CKEditorWidget(simple=True))
    recipients = IndicoEmailRecipientsField(_('Recipients'))
    copy_for_sender = BooleanField(
        _('Send copy to me'),
        widget=SwitchWidget(),
        description=_('Send copy of each email to my mailbox'))
    person_id = HiddenFieldList()
    user_id = HiddenFieldList()
    submitted = HiddenField()

    def __init__(self, *args, **kwargs):
        register_link = kwargs.pop('register_link')
        super(EmailEventPersonsForm, self).__init__(*args, **kwargs)
        from_addresses = [
            '{} <{}>'.format(session.user.full_name, email)
            for email in sorted(session.user.all_emails,
                                key=lambda x: x != session.user.email)
        ]
        self.from_address.choices = zip(from_addresses, from_addresses)
        self.body.description = render_placeholder_info(
            'event-persons-email',
            event=None,
            person=None,
            register_link=register_link)

    def is_submitted(self):
        return super(EmailEventPersonsForm,
                     self).is_submitted() and 'submitted' in request.form
Beispiel #2
0
class EmailEventPersonsForm(IndicoForm):
    from_address = SelectField(_('From'), [DataRequired()])
    subject = StringField(_('Subject'), [DataRequired()])
    body = TextAreaField(_('Email body'), [DataRequired()],
                         widget=CKEditorWidget(simple=True, images=True))
    recipients = IndicoEmailRecipientsField(_('Recipients'))
    copy_for_sender = BooleanField(
        _('Send copy to me'),
        widget=SwitchWidget(),
        description=_('Send copy of each email to my mailbox'))
    person_id = HiddenFieldList()
    user_id = HiddenFieldList()
    submitted = HiddenField()

    def __init__(self, *args, **kwargs):
        register_link = kwargs.pop('register_link')
        event = kwargs.pop('event')
        super(EmailEventPersonsForm, self).__init__(*args, **kwargs)
        self.from_address.choices = event.get_allowed_sender_emails().items()
        self.body.description = render_placeholder_info(
            'event-persons-email',
            event=None,
            person=None,
            register_link=register_link)

    def is_submitted(self):
        return super(EmailEventPersonsForm,
                     self).is_submitted() and 'submitted' in request.form
Beispiel #3
0
class SplitCategoryForm(IndicoForm):
    first_category = StringField(
        _('Category name #1'), [DataRequired()],
        description=_(
            'Selected events will be moved into a new sub-category with this '
            'title.'))
    second_category = StringField(
        _('Category name #2'),
        description=
        _('Events that were not selected will be moved into a new sub-category '
          'with this title. If omitted, those events will remain in the current '
          'category.'))
    event_id = HiddenFieldList()
    all_selected = BooleanField(widget=HiddenCheckbox())
    submitted = HiddenField()

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if self.all_selected.data:
            self.event_id.data = []
            self.first_category.label.text = _('Category name')
            self.first_category.description = _(
                'The events will be moved into a new sub-category with this title.'
            )
            del self.second_category

    def is_submitted(self):
        return super().is_submitted() and 'submitted' in request.form
Beispiel #4
0
class BulkAbstractJudgmentForm(AbstractJudgmentFormBase):
    judgment = HiddenEnumField(enum=AbstractAction,
                               skip={AbstractAction.change_tracks})
    abstract_id = HiddenFieldList()
    submitted = HiddenField()

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(BulkAbstractJudgmentForm, self).__init__(*args, **kwargs)
        self.duplicate_of.excluded_abstract_ids = set(kwargs['abstract_id'])
        self.merged_into.excluded_abstract_ids = set(kwargs['abstract_id'])
        if kwargs['judgment']:
            self._remove_unused_fields(kwargs['judgment'])

    def _remove_unused_fields(self, judgment):
        for field in list(self):
            validator = next(
                (v for v in field.validators
                 if isinstance(v, HiddenUnless) and v.field == 'judgment'),
                None)
            if validator is None:
                continue
            if not any(v.name == judgment for v in validator.value):
                delattr(self, field.name)

    def is_submitted(self):
        return super(BulkAbstractJudgmentForm,
                     self).is_submitted() and 'submitted' in request.form
Beispiel #5
0
class BulkPaperJudgmentForm(PaperJudgmentFormBase):
    judgment = HiddenEnumField(enum=PaperAction)
    contribution_id = HiddenFieldList()
    submitted = HiddenField()

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

    def is_submitted(self):
        return super(BulkPaperJudgmentForm, self).is_submitted() and 'submitted' in request.form
Beispiel #6
0
class BulkAbstractJudgmentForm(AbstractJudgmentFormBase):
    _order = ('judgment', 'accepted_track', 'override_contrib_type', 'accepted_contrib_type', 'session', 'duplicate_of',
              'merged_into', 'merge_persons', 'judgment_comment', 'send_notifications')

    judgment = HiddenEnumField(enum=AbstractAction, skip={AbstractAction.change_tracks})
    abstract_id = HiddenFieldList()
    submitted = HiddenField()
    override_contrib_type = BooleanField(_("Override contribution type"),
                                         [HiddenUnless('judgment', AbstractAction.accept)], widget=SwitchWidget(),
                                         description=_("Override the contribution type for all selected abstracts"))

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(BulkAbstractJudgmentForm, self).__init__(*args, **kwargs)
        if self.accepted_track:
            self.accepted_track.description = _("The abstracts will be accepted in this track")
        if self.accepted_contrib_type:
            self.accepted_contrib_type.description = _("The abstracts will be converted into a contribution of this "
                                                       "type")
        else:
            del self.override_contrib_type
        if self.session:
            self.session.description = _("The generated contributions will be allocated in this session")
        self.duplicate_of.description = _("The selected abstracts will be marked as duplicate of the specified "
                                          "abstract")
        self.merged_into.description = _("The selected abstracts will be merged into the specified abstract")
        self.merge_persons.description = _("Authors and speakers of the selected abstracts will be added to the "
                                           "specified abstract")
        self.duplicate_of.excluded_abstract_ids = set(kwargs['abstract_id'])
        self.merged_into.excluded_abstract_ids = set(kwargs['abstract_id'])
        if kwargs['judgment']:
            self._remove_unused_fields(kwargs['judgment'])

    def _remove_unused_fields(self, judgment):
        for field in list(self):
            validator = next((v for v in field.validators if isinstance(v, HiddenUnless) and v.field == 'judgment'),
                             None)
            if validator is None:
                continue
            if not any(v.name == judgment for v in validator.value):
                delattr(self, field.name)

    def is_submitted(self):
        return super(BulkAbstractJudgmentForm, self).is_submitted() and 'submitted' in request.form

    @classmethod
    def _add_contrib_type_hidden_unless(cls):
        # In the bulk form we need to hide/disable the contrib type selector unless we want to
        # override the type specified in the abstract.  However, multiple HiddenUnless validators
        # are not supported in the client-side JS so we only add it to this form - it removes
        # inactive fields on the server side so it still works (the JavaScript picks up the last
        # HiddenUnless validator)
        inject_validators(BulkAbstractJudgmentForm, 'accepted_contrib_type', [HiddenUnless('override_contrib_type')])
Beispiel #7
0
class BulkPaperJudgmentForm(IndicoForm):
    judgment = HiddenEnumField(enum=PaperAction)
    contribution_id = HiddenFieldList()
    submitted = HiddenField()
    judgment_comment = TextAreaField(_("Comment"), render_kw={'placeholder': _("Leave a comment for the submitter..."),
                                                              'class': 'grow'})

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

    def is_submitted(self):
        return super().is_submitted() and 'submitted' in request.form
Beispiel #8
0
class ContributionExportTeXForm(IndicoForm):
    """Form for TeX-based export selection"""
    format = SelectField(_('Format'), default='PDF')
    sort_by = IndicoEnumSelectField(_('Sort by'), enum=BOASortField, default=BOASortField.abstract_title,
                                    sorted=True)
    contribution_ids = HiddenFieldList()
    submitted = HiddenField()

    def __init__(self, *args, **kwargs):
        self.contribs = kwargs.get('contribs')
        super(ContributionExportTeXForm, self).__init__(*args, **kwargs)
        if not self.contribution_ids.data:
            self.contribution_ids.data = [c.id for c in self.contribs]

    def is_submitted(self):
        return super(ContributionExportTeXForm, self).is_submitted() and 'submitted' in request.form
Beispiel #9
0
class EmailEventPersonsForm(IndicoForm):
    from_address = SelectField(_('From'), [DataRequired()])
    subject = StringField(_('Subject'), [DataRequired()])
    body = TextAreaField(_('Email body'), [DataRequired()], widget=CKEditorWidget(simple=True))
    recipients = IndicoStaticTextField(_('Recipients'))
    person_id = HiddenFieldList(validators=[DataRequired()])
    submitted = HiddenField()

    def __init__(self, *args, **kwargs):
        super(EmailEventPersonsForm, self).__init__(*args, **kwargs)
        from_addresses = ['{} <{}>'.format(session.user.full_name, email)
                          for email in sorted(session.user.all_emails, key=lambda x: x != session.user.email)]
        self.from_address.choices = zip(from_addresses, from_addresses)

    def is_submitted(self):
        return super(EmailEventPersonsForm, self).is_submitted() and 'submitted' in request.form