class SubContributionForm(IndicoForm): title = StringField(_('Title'), [DataRequired()]) description = TextAreaField(_('Description')) duration = IndicoDurationField( _('Duration'), [DataRequired(), MaxDuration(timedelta(hours=24))], default=timedelta(minutes=20)) speakers = SubContributionPersonLinkListField( _('Speakers'), allow_submitters=False, allow_authors=False, description=_('The speakers of the subcontribution')) references = ReferencesField( _('External IDs'), reference_class=SubContributionReference, description=_('Manage external resources for this sub-contribution')) code = StringField(_('Program code')) @generated_data def render_mode(self): return RenderMode.markdown def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') self.subcontrib = kwargs.pop('subcontrib', None) super().__init__(*args, **kwargs)
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_')])
class EventClassificationForm(IndicoForm): keywords = IndicoTagListField(_('Keywords')) references = ReferencesField(_('External IDs'), reference_class=EventReference) def __init__(self, *args, **kwargs): event = kwargs.pop('event') super(EventClassificationForm, self).__init__(*args, **kwargs) if event.type_ != EventType.meeting: del self.references
class EventClassificationForm(IndicoForm): keywords = IndicoTagListField(_('Keywords')) references = ReferencesField(_('External IDs'), reference_class=EventReference) label = QuerySelectField(_('Label'), allow_blank=True, get_label='title') label_message = TextAreaField(_('Label message'), description=_('You can optionally provide a message that is shown when hovering ' 'the selected label.')) def __init__(self, *args, **kwargs): event = kwargs.pop('event') super().__init__(*args, **kwargs) if event.type_ != EventType.meeting or not ReferenceType.query.has_rows(): del self.references self.label.query = EventLabel.query.order_by(db.func.lower(EventLabel.title)) if not self.label.query.has_rows(): del self.label del self.label_message
class SubContributionForm(IndicoForm): title = StringField(_('Title'), [DataRequired()]) description = TextAreaField(_('Description')) duration = TimeDeltaField( _('Duration'), [DataRequired(), MaxDuration(timedelta(hours=24))], default=timedelta(minutes=20), units=('minutes', 'hours')) speakers = SubContributionPersonLinkListField( _('Speakers'), allow_submitters=False, description=_('The speakers of the subcontribution')) references = ReferencesField( _("External IDs"), reference_class=SubContributionReference, description=_("Manage external resources for this sub-contribution")) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') self.subcontrib = kwargs.pop('subcontrib', None) super(SubContributionForm, self).__init__(*args, **kwargs)
class EventReferencesForm(IndicoForm): references = ReferencesField( _('External IDs'), reference_class=EventReference, description=_("Manage external resources for this event"))