Beispiel #1
0
class SessionForm(IndicoForm):
    title = StringField(_('Title'), [DataRequired()])
    code = StringField(
        _('Session code'),
        description=_('The code that will identify the session in the Book of '
                      'Abstracts.'))
    description = TextAreaField(_('Description'))
    default_contribution_duration = TimeDeltaField(
        _('Default contribution duration'),
        units=('minutes', 'hours'),
        description=_('Duration that a contribution created within this '
                      'session will have by default.'),
        default=timedelta(minutes=20))
    type = QuerySelectField(_("Type"),
                            get_label='name',
                            allow_blank=True,
                            blank_text=_("No type selected"))
    location_data = IndicoLocationField(
        _("Default location"),
        description=_("Default location for blocks inside the session."))
    colors = IndicoPalettePickerField(_('Colours'), color_list=get_colors())

    def __init__(self, *args, **kwargs):
        event = kwargs.pop('event')
        super(SessionForm, self).__init__(*args, **kwargs)
        if event.type != 'conference':
            del self.code
            del self.type
        else:
            self.type.query = SessionType.query.with_parent(event)
            if not self.type.query.has_rows():
                del self.type
Beispiel #2
0
class MeetingSessionBlockForm(IndicoForm):
    session_title = StringField(_('Title'), [DataRequired()],
                                description=_('Title of the session'))
    block_title = StringField(_('Block title'),
                              description=_('Title of the session block'))
    block_person_links = SessionBlockPersonLinkListField(_('Conveners'))
    block_location_data = IndicoLocationField(_('Location'))

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

    @property
    def session_fields(self):
        return [
            field_name for field_name in self._fields
            if field_name.startswith('session_')
        ]

    @property
    def block_fields(self):
        return [
            field_name for field_name in self._fields
            if field_name.startswith('block_')
        ]
Beispiel #3
0
class EventCreationFormBase(IndicoForm):
    listing = IndicoButtonsBooleanField(_('Listing'),
                                        default=True,
                                        true_caption=(_('List in a category'),
                                                      'eye'),
                                        false_caption=(_('Keep unlisted'),
                                                       'eye-blocked'))
    category = CategoryField(_('Category'), [
        UsedIf(lambda form, _: (form.listing.data or
                                not can_create_unlisted_events(session.user))),
        DataRequired()
    ],
                             require_event_creation_rights=True)
    title = StringField(_('Event title'), [DataRequired()])
    timezone = IndicoTimezoneSelectField(_('Timezone'), [DataRequired()])
    location_data = IndicoLocationField(_('Location'),
                                        allow_location_inheritance=False,
                                        edit_address=False)
    protection_mode = IndicoEnumRadioField(_('Protection mode'),
                                           enum=ProtectionMode)
    create_booking = JSONField()

    def validate_category(self, field):
        if ((self.listing.data or not can_create_unlisted_events(session.user))
                and not field.data.can_create_events(session.user)):
            raise ValidationError(
                _('You are not allowed to create events in this category.'))
Beispiel #4
0
class SessionForm(IndicoForm):
    title = StringField(_('Title'), [DataRequired()])
    code = StringField(
        _('Session code'),
        description=_('The code that will identify the session in the Book of '
                      'Abstracts.'))
    description = TextAreaField(_('Description'))
    default_contribution_duration = TimeDeltaField(
        _('Default contribution duration'),
        units=('minutes', 'hours'),
        description=_('Duration that a contribution created within this '
                      'session will have by default.'),
        default=timedelta(minutes=20))
    location_data = IndicoLocationField(
        _("Default location"),
        description=_("Default location for blocks inside the session."))
    colors = IndicoPalettePickerField(_('Colours'), color_list=get_colors())
    is_poster = BooleanField(
        _('Poster session'),
        widget=SwitchWidget(),
        description=
        _('Whether the session is a poster session or contains normal presentations.'
          ))

    def __init__(self, *args, **kwargs):
        event = kwargs.pop('event')
        super(SessionForm, self).__init__(*args, **kwargs)
        if event.type != 'conference':
            del self.is_poster
            del self.code
Beispiel #5
0
class SessionBlockForm(IndicoForm):
    title = StringField(_('Title'), description=_('Title of the session block'))
    person_links = SessionBlockPersonLinkListField(_('Conveners'))
    location_data = IndicoLocationField(_('Location'))

    def __init__(self, *args, **kwargs):
        self.session_block = kwargs.pop('session_block', None)
        super(SessionBlockForm, self).__init__(*args, **kwargs)
Beispiel #6
0
class BreakEntryForm(EntryFormMixin, IndicoForm):
    _entry_type = TimetableEntryType.BREAK
    _default_duration = timedelta(minutes=20)
    _display_fields = ('title', 'description', 'time', 'duration', 'location_data', 'colors')

    title = StringField(_("Title"), [DataRequired()])
    description = TextAreaField(_("Description"))
    location_data = IndicoLocationField(_("Location"))
    colors = IndicoPalettePickerField(_('Colours'), color_list=get_colors())
Beispiel #7
0
class ContributionForm(IndicoForm):
    title = StringField(_("Title"), [DataRequired()])
    description = TextAreaField(_("Description"))
    start_dt = IndicoDateTimeField(_("Start date"),
                                   [DataRequired(),
                                    DateTimeRange(earliest=lambda form, field: form._get_earliest_start_dt(),
                                                  latest=lambda form, field: form._get_latest_start_dt())],
                                   allow_clear=False,
                                   description=_("Start date of the contribution"))
    duration = TimeDeltaField(_("Duration"), [DataRequired(), MaxDuration(timedelta(hours=24))],
                              default=timedelta(minutes=20), units=('minutes', 'hours'))
    type = QuerySelectField(_("Type"), get_label='name', allow_blank=True, blank_text=_("No type selected"))
    person_link_data = ContributionPersonLinkListField(_("People"))
    location_data = IndicoLocationField(_("Location"))
    keywords = IndicoTagListField(_('Keywords'))
    references = ReferencesField(_("External IDs"), reference_class=ContributionReference,
                                 description=_("Manage external resources for this contribution"))
    board_number = StringField(_("Board Number"))
    code = StringField(_('Programme code'))

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

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        self.contrib = kwargs.pop('contrib', None)
        self.session_block = kwargs.get('session_block')
        self.timezone = self.event.timezone
        to_schedule = kwargs.pop('to_schedule', False)
        super(ContributionForm, self).__init__(*args, **kwargs)
        self.type.query = self.event.contribution_types
        if self.event.type != 'conference':
            self.person_link_data.label.text = _("Speakers")
        if not self.type.query.count():
            del self.type
        if not to_schedule and (self.contrib is None or not self.contrib.is_scheduled):
            del self.start_dt

    def _get_earliest_start_dt(self):
        return self.session_block.start_dt if self.session_block else self.event.start_dt

    def _get_latest_start_dt(self):
        return self.session_block.end_dt if self.session_block else self.event.end_dt

    def validate_duration(self, field):
        start_dt = self.start_dt.data if self.start_dt else None
        if start_dt:
            end_dt = start_dt + field.data
            if self.session_block and end_dt > self.session_block.end_dt:
                raise ValidationError(_("With the current duration the contribution exceeds the block end date"))
            if end_dt > self.event.end_dt:
                raise ValidationError(_('With the current duration the contribution exceeds the event end date'))

    @property
    def custom_field_names(self):
        return tuple([field_name for field_name in self._fields if field_name.startswith('custom_')])
Beispiel #8
0
class EventLocationForm(IndicoForm):
    location_data = IndicoLocationField(_('Location'), allow_location_inheritance=False)
    own_map_url = URLField(_('Map URL'), [Optional(), URL()])

    def __init__(self, *args, **kwargs):
        event = kwargs['event']
        super().__init__(*args, **kwargs)
        if event.room:
            self.own_map_url.render_kw = {'placeholder': event.room.map_url}
Beispiel #9
0
class EventCreationFormBase(IndicoForm):
    category = CategoryField(_('Category'), [DataRequired()], allow_subcats=False, require_event_creation_rights=True)
    title = StringField(_('Event title'), [DataRequired()])
    timezone = IndicoTimezoneSelectField(_('Timezone'), [DataRequired()])
    location_data = IndicoLocationField(_('Location'), allow_location_inheritance=False)
    protection_mode = IndicoEnumRadioField(_('Protection mode'), enum=ProtectionMode)

    def validate_category(self, field):
        if not field.data.can_create_events(session.user):
            raise ValidationError(_('You are not allowed to create events in this category.'))
Beispiel #10
0
class EventLocationForm(IndicoForm):
    location_data = IndicoLocationField(_('Location'),
                                        allow_location_inheritance=False)