Ejemplo n.º 1
0
class PaperReviewForm(fossirForm):
    """Form for reviewing a paper"""

    _order = ('proposed_action', 'comment')

    comment = TextAreaField(_("Comment"),
                            render_kw={
                                'placeholder':
                                _("You may leave a comment (only visible to "
                                  "reviewers and judges)...")
                            })
    proposed_action = fossirEnumSelectField(_("Proposed Action"),
                                            [DataRequired()],
                                            enum=PaperAction)

    def __init__(self, edit=False, *args, **kwargs):
        paper = kwargs.pop('paper')
        super(PaperReviewForm, self).__init__(*args, **kwargs)
        self.event = paper.event
        if not edit:
            self.proposed_action.none = _("Propose an action...")

    @property
    def split_data(self):
        data = self.data
        return {
            'questions_data':
            {k: v
             for k, v in data.iteritems() if k.startswith('question_')},
            'review_data': {
                k: v
                for k, v in data.iteritems() if not k.startswith('question_')
            }
        }
Ejemplo n.º 2
0
class CategorySettingsForm(fossirForm):
    BASIC_FIELDS = ('title', 'description', 'timezone', 'lecture_theme', 'meeting_theme', 'visibility',
                    'suggestions_disabled', 'event_creation_notification_emails', 'notify_managers')
    EVENT_HEADER_FIELDS = ('event_message_mode', 'event_message')

    title = StringField(_("Title"), [DataRequired()])
    description = fossirMarkdownField(_("Description"))
    timezone = fossirTimezoneSelectField(_("Timezone"), [DataRequired()],
                                         description=_("Default timezone event lists will show up in. It will also be "
                                                       "used as a default for new events."))
    lecture_theme = fossirThemeSelectField(_("Theme for Lectures"), [DataRequired()], event_type=EventType.lecture,
                                           description=_("Default timetable theme used for lecture events"))
    meeting_theme = fossirThemeSelectField(_("Theme for Meetings"), [DataRequired()], event_type=EventType.meeting,
                                           description=_("Default timetable theme used for meeting events"))
    suggestions_disabled = BooleanField(_('Disable Suggestions'), widget=SwitchWidget(),
                                        description=_("Enable this if you don't want fossir to suggest this category as"
                                                      " a possible addition to a user's favourites."))
    event_message_mode = fossirEnumSelectField(_("Message Type"), enum=EventMessageMode,
                                               default=EventMessageMode.disabled,
                                               description=_("This message will show up at the top of every event page "
                                                             "in this category"))
    event_message = fossirMarkdownField(_("Content"))
    notify_managers = BooleanField(_("Notify managers"), widget=SwitchWidget(),
                                   description=_("Whether to send email notifications to all managers of this category "
                                                 "when an event is created inside it or in any of its subcategories."))
    event_creation_notification_emails = EmailListField(_("Notification E-mails"),
                                                        description=_("List of emails that will receive a notification "
                                                                      "every time a new event is created inside the "
                                                                      "category or one of its subcategories. "
                                                                      "One email address per line."))
Ejemplo n.º 3
0
class UserPreferencesForm(fossirForm):
    lang = SelectField(_('Language'))
    timezone = SelectField(_('Timezone'))

    force_timezone = BooleanField(
        _('Use my timezone'),
        widget=SwitchWidget(),
        description=_(
            "Always use my current timezone instead of an event's timezone."))

    show_past_events = BooleanField(
        _('Show past events'),
        widget=SwitchWidget(),
        description=_('Show past events by default.'))

    name_format = fossirEnumSelectField(
        _('Name format'),
        enum=NameFormat,
        description=_('Default format in which names are displayed'))

    use_previewer_pdf = BooleanField(
        _('Use previewer for PDF files'),
        widget=SwitchWidget(),
        description=
        _('The previewer is used by default for image and text files, but not for PDF files.'
          ))

    def __init__(self, *args, **kwargs):
        super(UserPreferencesForm, self).__init__(*args, **kwargs)
        self.lang.choices = sorted(get_all_locales().items(),
                                   key=itemgetter(1))
        self.timezone.choices = zip(common_timezones, common_timezones)
        if self.timezone.object_data and self.timezone.object_data not in common_timezones_set:
            self.timezone.choices.append(
                (self.timezone.object_data, self.timezone.object_data))
Ejemplo n.º 4
0
class EventPersonForm(fossirForm):
    title = fossirEnumSelectField(_('Title'), enum=UserTitle)
    first_name = StringField(_('First name'), [DataRequired()])
    last_name = StringField(_('Family name'), [DataRequired()])
    affiliation = StringField(_('Affiliation'))
    address = TextAreaField(_('Address'))
    phone = StringField(_('Phone number'))
Ejemplo n.º 5
0
class BOASettingsForm(fossirForm):
    """Settings form for the 'Book of Abstracts'"""

    extra_text = fossirMarkdownField(_('Additional text'),
                                     editor=True,
                                     mathjax=True)
    sort_by = fossirEnumSelectField(_('Sort by'), [DataRequired()],
                                    enum=BOASortField,
                                    sorted=True)
    corresponding_author = fossirEnumSelectField(
        _('Corresponding author'), [DataRequired()],
        enum=BOACorrespondingAuthorType,
        sorted=True)
    show_abstract_ids = BooleanField(
        _('Show abstract IDs'),
        widget=SwitchWidget(),
        description=_("Show abstract IDs in the table of contents."))
Ejemplo n.º 6
0
class BadgeSettingsForm(fossirForm):
    template = SelectField(_('Template'))
    save_values = BooleanField(
        _("Save values for next time"),
        widget=SwitchWidget(),
        description=_("Save these values in the event settings"))
    dashed_border = BooleanField(
        _("Dashed border around each badge"),
        widget=SwitchWidget(),
        description=_("Display a dashed border around each badge"))
    page_size = fossirEnumSelectField(_('Page size'), enum=PageSize)
    page_orientation = fossirEnumSelectField(_('Page orientation'),
                                             enum=PageOrientation)
    page_layout = fossirEnumSelectField(
        _('Page layout'),
        enum=PageLayout,
        description=_(
            'The single sided (foldable) option is only available if the '
            'template orientation is the same as the page orientation and '
            'its width is exactly half of the page width'))

    top_margin = FloatField(_('Top margin'), [InputRequired()])
    left_margin = FloatField(_('Left margin'), [InputRequired()])
    right_margin = FloatField(_('Right margin'), [InputRequired()])
    bottom_margin = FloatField(_('Bottom margin'), [InputRequired()])
    margin_columns = FloatField(_('Margin between columns'), [InputRequired()])
    margin_rows = FloatField(_('Margin between rows'), [InputRequired()])

    submitted = HiddenField()

    def __init__(self, event, **kwargs):
        all_templates = set(
            event.designer_templates) | get_inherited_templates(event)
        badge_templates = [
            tpl for tpl in all_templates if tpl.type.name == 'badge'
        ]
        super(BadgeSettingsForm, self).__init__(**kwargs)
        self.template.choices = sorted(
            ((unicode(tpl.id), tpl.title) for tpl in badge_templates),
            key=itemgetter(1))

    def is_submitted(self):
        return super(BadgeSettingsForm,
                     self).is_submitted() and 'submitted' in request.form
Ejemplo n.º 7
0
class AddTemplateForm(fossirForm):
    title = StringField(_('Title'), [DataRequired()])
    type = fossirEnumSelectField(_('Template'),
                                 enum=TemplateType,
                                 default=TemplateType.poster)
    is_clonable = BooleanField(
        _('Allow cloning'),
        widget=SwitchWidget(),
        default=True,
        description=_(
            "Allow cloning this template in subcategories and events"))
Ejemplo n.º 8
0
class PaperJudgmentForm(PaperJudgmentFormBase):
    """Form for judging a single paper"""

    _order = ('judgment', 'judgment_comment')

    judgment = fossirEnumSelectField(_("Judgment"), [DataRequired()],
                                     enum=PaperAction)

    def __init__(self, *args, **kwargs):
        self.paper = kwargs.pop('paper')
        super(PaperJudgmentForm, self).__init__(*args, **kwargs)
        if self.paper.state == PaperRevisionState.to_be_corrected:
            self.judgment.skip.add(PaperAction.to_be_corrected)
Ejemplo n.º 9
0
class UserDetailsForm(SyncedInputsMixin, fossirForm):
    title = fossirEnumSelectField(_('Title'), enum=UserTitle)
    first_name = StringField(
        _('First name'),
        [used_if_not_synced, DataRequired()],
        widget=SyncedInputWidget())
    last_name = StringField(
        _('Family name'),
        [used_if_not_synced, DataRequired()],
        widget=SyncedInputWidget())
    affiliation = StringField(_('Affiliation'), widget=SyncedInputWidget())
    address = TextAreaField(_('Address'),
                            widget=SyncedInputWidget(textarea=True))
    phone = StringField(_('Phone number'), widget=SyncedInputWidget())
Ejemplo n.º 10
0
class PaperCommentForm(fossirForm):
    text = TextAreaField(_("Comment"), [DataRequired()],
                         render_kw={'placeholder': _("Leave a comment...")})
    visibility = fossirEnumSelectField(_("Visibility"), [DataRequired()],
                                       enum=PaperCommentVisibility,
                                       skip={PaperCommentVisibility.users})

    def __init__(self, *args, **kwargs):
        comment = kwargs.get('obj')
        user = comment.user if comment else kwargs.pop('user')
        paper = kwargs.pop('paper')
        super(fossirForm, self).__init__(*args, **kwargs)
        if not paper.can_judge(user):
            self.visibility.skip.add(PaperCommentVisibility.judges)
        if not paper.can_review(user):
            del self.visibility
Ejemplo n.º 11
0
class AbstractCommentForm(fossirForm):
    text = TextAreaField(_("Comment"), [DataRequired()],
                         render_kw={'placeholder': _("Leave a comment...")})
    visibility = fossirEnumSelectField(_("Visibility"), [DataRequired()],
                                       enum=AbstractCommentVisibility,
                                       skip={AbstractCommentVisibility.users})

    def __init__(self, *args, **kwargs):
        comment = kwargs.get('obj')
        user = comment.user if comment else kwargs.pop('user')
        abstract = kwargs.pop('abstract')
        super(fossirForm, self).__init__(*args, **kwargs)
        if not abstract.event.cfa.allow_contributors_in_comments:
            self.visibility.skip.add(AbstractCommentVisibility.contributors)
        if not abstract.can_judge(user) and not abstract.can_convene(user):
            self.visibility.skip.add(AbstractCommentVisibility.judges)
            if not abstract.can_review(user):
                del self.visibility
Ejemplo n.º 12
0
class PosterPrintingForm(fossirForm):
    template = SelectField(_('Template'))
    margin_horizontal = FloatField(_('Horizontal margins'), [InputRequired()],
                                   default=0)
    margin_vertical = FloatField(_('Vertical margins'), [InputRequired()],
                                 default=0)
    page_size = fossirEnumSelectField(_('Page size'),
                                      enum=PageSize,
                                      default=PageSize.A4)

    def __init__(self, event, **kwargs):
        all_templates = set(
            event.designer_templates) | get_inherited_templates(event)
        poster_templates = [
            tpl for tpl in all_templates if tpl.type.name == 'poster'
        ]
        super(PosterPrintingForm, self).__init__(**kwargs)
        self.template.choices = sorted(
            ((unicode(tpl.id), tpl.title) for tpl in poster_templates),
            key=itemgetter(1))
Ejemplo n.º 13
0
class AdminSettingsForm(fossirForm):
    allow_persistent = BooleanField(
        _('Persistent signatures'),
        widget=SwitchWidget(),
        description=_(
            "Allow users to enable persistent signatures (without timestamp).")
    )
    security_mode = fossirEnumSelectField(
        _('Security mode'),
        enum=APIMode,
        titles=security_mode_titles,
        description=_('Specify if/when people need to use an API key or a '
                      'signed request.'))
    cache_ttl = IntegerField(
        _('Cache TTL'), [NumberRange(min=0)],
        description=_('Time to cache API results (in seconds)'))
    signature_ttl = IntegerField(
        _('Signature TTL'), [NumberRange(min=1)],
        description=
        _('Time after which a request signature expires. This should not be too '
          'low to account for small clock differences between the client and the '
          'server.'))
Ejemplo n.º 14
0
class AbstractJudgmentForm(AbstractJudgmentFormBase):
    """Form for judging an abstract"""

    judgment = fossirEnumSelectField(_("Judgment"), [DataRequired()],
                                     enum=AbstractAction,
                                     skip={AbstractAction.change_tracks})

    def __init__(self, *args, **kwargs):
        abstract = kwargs.pop('abstract')
        self.event = abstract.event
        candidate_tracks = list(abstract.candidate_tracks)
        candidate_contrib_types = list(abstract.candidate_contrib_types)
        if len(candidate_tracks) == 1:
            kwargs.setdefault('accepted_track', candidate_tracks[0])
        if len(candidate_contrib_types) == 1:
            kwargs.setdefault('accepted_contrib_type',
                              candidate_contrib_types[0])
        elif not abstract.reviews:
            kwargs.setdefault('accepted_contrib_type',
                              abstract.submitted_contrib_type)
        super(AbstractJudgmentForm, self).__init__(*args, **kwargs)
        self.duplicate_of.excluded_abstract_ids = {abstract.id}
        self.merged_into.excluded_abstract_ids = {abstract.id}
Ejemplo n.º 15
0
class AbstractReviewForm(fossirForm):
    """Form for reviewing an abstract"""

    _order = ('proposed_action', 'proposed_contribution_type',
              'proposed_related_abstract', 'proposed_tracks', 'comment')

    comment = TextAreaField(_("Comment"),
                            render_kw={
                                'placeholder':
                                _("You may leave a comment (only visible to "
                                  "conveners and judges)...")
                            })
    proposed_action = fossirEnumSelectField(_("Proposed Action"),
                                            [DataRequired()],
                                            enum=AbstractAction)
    proposed_related_abstract = AbstractField(
        _("Target Abstract"), [
            HiddenUnless(
                'proposed_action',
                {AbstractAction.mark_as_duplicate, AbstractAction.merge}),
            DataRequired()
        ],
        description=
        _("The current abstract should be marked as duplicate of the selected one"
          ),
        ajax_endpoint='abstracts.other_abstracts')
    proposed_contribution_type = QuerySelectField(
        _("Contribution type"),
        [HiddenUnless('proposed_action', AbstractAction.accept)],
        get_label=lambda x: x.name.title(),
        allow_blank=True,
        blank_text=_("You may propose a contribution type..."))
    proposed_tracks = fossirQuerySelectMultipleCheckboxField(
        _("Propose for tracks"), [
            HiddenUnless('proposed_action', AbstractAction.change_tracks),
            DataRequired()
        ],
        collection_class=set,
        get_label='title')

    def __init__(self, edit=False, *args, **kwargs):
        abstract = kwargs.pop('abstract')
        super(AbstractReviewForm, self).__init__(*args, **kwargs)
        self.event = abstract.event
        if not edit:
            self.proposed_action.none = _("Propose an action...")
        self.proposed_related_abstract.excluded_abstract_ids = {abstract.id}
        self.proposed_contribution_type.query = (
            ContributionType.query.with_parent(self.event).order_by(
                ContributionType.name))
        if not self.proposed_contribution_type.query.count():
            del self.proposed_contribution_type
        reviewed_for_track_ids = {t.id for t in abstract.reviewed_for_tracks}
        existing_prop_track_cond = (Track.id.in_(
            t.id for t in self.proposed_tracks.object_data)
                                    if self.proposed_tracks.object_data else
                                    False)
        self.proposed_tracks.query = (Track.query.with_parent(
            self.event).filter(
                db.or_(Track.id.notin_(reviewed_for_track_ids),
                       existing_prop_track_cond)).order_by(Track.position))
        if not self.proposed_tracks.query.count():
            del self.proposed_tracks
            self.proposed_action.skip.add(AbstractAction.change_tracks)

    @property
    def split_data(self):
        data = self.data
        return {
            'questions_data':
            {k: v
             for k, v in data.iteritems() if k.startswith('question_')},
            'review_data': {
                k: v
                for k, v in data.iteritems() if not k.startswith('question_')
            }
        }
Ejemplo n.º 16
0
class RegistrationFormForm(fossirForm):
    _price_fields = ('currency', 'base_price')
    _registrant_notification_fields = ('notification_sender_address',
                                       'message_pending', 'message_unpaid',
                                       'message_complete')
    _manager_notification_fields = ('manager_notifications_enabled',
                                    'manager_notification_recipients')
    _special_fields = _price_fields + _registrant_notification_fields + _manager_notification_fields

    title = StringField(_("Title"), [DataRequired()],
                        description=_("The title of the registration form"))
    introduction = TextAreaField(
        _("Introduction"),
        description=
        _("Introduction to be displayed when filling out the registration form"
          ))
    contact_info = StringField(
        _("Contact info"),
        description=
        _("How registrants can get in touch with somebody for extra information"
          ))
    moderation_enabled = BooleanField(
        _("Moderated"),
        widget=SwitchWidget(),
        description=_("If enabled, registrations require manager approval"))
    require_login = BooleanField(
        _("Only logged-in users"),
        widget=SwitchWidget(),
        description=_("Users must be logged in to register"))
    require_user = BooleanField(
        _("Registrant must have account"),
        widget=SwitchWidget(),
        description=_(
            "Registrations emails must be associated with an fossir account"))
    limit_registrations = BooleanField(
        _("Limit registrations"),
        widget=SwitchWidget(),
        description=_("Whether there is a limit of registrations"))
    registration_limit = IntegerField(
        _("Capacity"), [
            HiddenUnless('limit_registrations'),
            DataRequired(),
            NumberRange(min=1)
        ],
        description=_("Maximum number of registrations"))
    modification_mode = fossirEnumSelectField(
        _("Modification allowed"),
        enum=ModificationMode,
        description=_("Will users be able to modify their data? When?"))
    publish_registrations_enabled = BooleanField(
        _('Publish registrations'),
        widget=SwitchWidget(),
        description=_("Registrations from this form will be displayed in the "
                      "event page"))
    publish_registration_count = BooleanField(
        _("Publish number of registrations"),
        widget=SwitchWidget(),
        description=_("Number of registered participants will be displayed in "
                      "the event page"))
    publish_checkin_enabled = BooleanField(
        _('Publish check-in status'),
        widget=SwitchWidget(),
        description=_(
            "Check-in status will be shown publicly on the event page"))
    base_price = DecimalField(
        _('Registration fee'),
        [NumberRange(min=0),
         Optional(), _check_if_payment_required],
        filters=[lambda x: x if x is not None else 0],
        widget=NumberInput(step='0.01'),
        description=_("A fixed fee all users have to pay when registering."))
    currency = SelectField(_('Currency'), [DataRequired()],
                           description=_('The currency for new registrations'))
    notification_sender_address = StringField(_('Notification sender address'),
                                              [fossirEmail()],
                                              filters=[lambda x: (x or None)])
    message_pending = TextAreaField(
        _("Message for pending registrations"),
        description=_("Text included in emails sent to pending registrations"))
    message_unpaid = TextAreaField(
        _("Message for unpaid registrations"),
        description=_("Text included in emails sent to unpaid registrations"))
    message_complete = TextAreaField(
        _("Message for complete registrations"),
        description=_(
            "Text included in emails sent to complete registrations"))
    manager_notifications_enabled = BooleanField(
        _('Enabled'),
        widget=SwitchWidget(),
        description=_("Enable notifications to managers about registrations"))
    manager_notification_recipients = EmailListField(
        _('List of recipients'), [
            HiddenUnless('manager_notifications_enabled', preserve_data=True),
            DataRequired()
        ],
        description=_("Email addresses that will receive notifications"))

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(fossirForm, self).__init__(*args, **kwargs)
        self._set_currencies()
        self.notification_sender_address.description = _(
            'Email address set as the sender of all '
            'notifications sent to users. If empty, '
            'then {0} is used.'.format(config.NO_REPLY_EMAIL))

    def _set_currencies(self):
        currencies = [(c['code'], '{0[code]} ({0[name]})'.format(c))
                      for c in payment_settings.get('currencies')]
        self.currency.choices = sorted(currencies, key=lambda x: x[1].lower())