Beispiel #1
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 #2
0
class CloneCategorySelectForm(CloneContentsForm):
    category = CategoryField(_('Category'), require_event_creation_rights=True, allow_subcats=False)

    def validate_category(self, field):
        if not field.data:
            raise ValidationError(_("You have to select a category"))
        elif not field.data.can_create_events(session.user):
            raise ValidationError(_("You can't create events in this category"))
Beispiel #3
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.'))