class VCRoomLinkFormBase(IndicoForm): conditional_fields = {'contribution', 'block'} linking = IndicoRadioField(_("Link to"), [DataRequired()], choices=[('event', _("Event")), ('contribution', _("Contribution")), ('block', _("Session"))], widget=LinkingWidget()) contribution = SelectField(_("Contribution"), [ UsedIf(lambda form, field: form.linking.data == 'contribution'), DataRequired() ]) block = SelectField(_("Session block"), [ UsedIf(lambda form, field: form.linking.data == 'block'), DataRequired() ]) show = BooleanField(_('Show room'), widget=SwitchWidget(), description=_('Display this room on the event page')) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') super(VCRoomLinkFormBase, self).__init__(*args, **kwargs) contrib_choices = [(contrib.id, contrib.title) for contrib in sorted( self.event.getContributionList(), key=attrgetter('title'))] block_choices = [(full_block_id(block), block.getFullTitle()) for block in sorted(self.event.getSessionSlotList(), key=methodcaller('getFullTitle'))] self.contribution.choices = [('', _("Please select a contribution")) ] + contrib_choices self.block.choices = [('', _("Please select a session block")) ] + block_choices
class _DateTimePair(IndicoForm): class Meta: csrf = False start_date = IndicoDateField( _(u'from'), [UsedIf(lambda form, field: form.end_date.data)]) start_time = TimeField(None, [Optional()]) end_date = IndicoDateField( _(u'to'), [UsedIf(lambda form, field: form.start_date.data)]) end_time = TimeField(None, [Optional()]) @property def start_dt(self): if self.start_date.data: return datetime.combine(self.start_date.data, self.start_time.data) else: return None @property def end_dt(self): if self.end_date.data: return datetime.combine(self.end_date.data, self.end_time.data) else: return None def validate_start(self, field): if self.start_dt and self.end_dt and self.start_dt >= self.end_dt: raise ValidationError( 'The start date must be earlier than the end date.') validate_end = validate_start
class VCRoomLinkFormBase(IndicoForm): conditional_fields = {'contribution', 'block'} linking = IndicoRadioField(_("Link to"), [DataRequired()], choices=[('event', _("Event")), ('contribution', _("Contribution")), ('block', _("Session"))], widget=LinkingWidget()) contribution = SelectField(_("Contribution"), [UsedIf(lambda form, field: form.linking.data == 'contribution'), DataRequired()], coerce=lambda x: int(x) if x else None) block = SelectField(_("Session block"), [UsedIf(lambda form, field: form.linking.data == 'block'), DataRequired()], coerce=lambda x: int(x) if x else None) show = BooleanField(_('Show room'), widget=SwitchWidget(), description=_('Display this room on the event page')) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') super().__init__(*args, **kwargs) contrib_choices = [(contrib.id, contrib.title) for contrib in sorted(self.event.contributions, key=attrgetter('title'))] blocks = SessionBlock.find(SessionBlock.session.has((Session.event == self.event) & ~Session.is_deleted)) block_choices = [(block.id, block.full_title) for block in sorted(blocks, key=attrgetter('full_title'))] self.contribution.choices = [('', _("Please select a contribution"))] + contrib_choices self.block.choices = [('', _("Please select a session block"))] + block_choices
class PaperReviewingSettingsForm(IndicoForm): """Settings form for paper reviewing""" RATING_FIELDS = ('scale_lower', 'scale_upper') announcement = IndicoMarkdownField(_('Announcement'), editor=True) scale_lower = IntegerField(_("Scale (from)"), [UsedIf(lambda form, field: not form.has_ratings), InputRequired()]) scale_upper = IntegerField(_("Scale (to)"), [UsedIf(lambda form, field: not form.has_ratings), InputRequired()]) email_settings = PaperEmailSettingsField(_("Email notifications")) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') self.has_ratings = kwargs.pop('has_ratings', False) super(PaperReviewingSettingsForm, self).__init__(*args, **kwargs) if self.has_ratings: self.scale_upper.warning = _("Some reviewers have already submitted ratings so the scale cannot be changed " "anymore.") def validate_scale_upper(self, field): lower = self.scale_lower.data upper = self.scale_upper.data if lower is None or upper is None: return if lower >= upper: raise ValidationError(_("The scale's 'to' value must be greater than the 'from' value.")) if upper - lower > 20: raise ValidationError(_("The difference between 'to' and' from' may not be greater than 20.")) @property def data(self): data = super(PaperReviewingSettingsForm, self).data if self.has_ratings: for key in self.RATING_FIELDS: del data[key] return data
class AttachmentPackageForm(IndicoForm): added_since = IndicoDateField( _('Added Since'), [Optional()], description=_('Include only attachments uploaded after this date')) filter_type = IndicoRadioField(_('Include'), [DataRequired()]) sessions = IndicoSelectMultipleCheckboxField( _('Sessions'), [ UsedIf(lambda form, _: form.filter_type.data == 'sessions'), DataRequired() ], description=_('Include materials from selected sessions'), coerce=int) contributions = IndicoSelectMultipleCheckboxField( _('Contributions'), [ UsedIf(lambda form, _: form.filter_type.data == 'contributions'), DataRequired() ], description=_('Include materials from selected contributions'), coerce=int) dates = IndicoSelectMultipleCheckboxField( _('Events scheduled on'), [ UsedIf(lambda form, _: form.filter_type.data == 'dates'), DataRequired() ], description=_( 'Include materials from sessions/contributions scheduled ' 'on the selected dates'))
class _TimePair(Form): start = TimeField(_(u'from'), [UsedIf(lambda form, field: form.end.data)]) end = TimeField(_(u'to'), [UsedIf(lambda form, field: form.start.data)]) def validate_start(self, field): if self.start.data and self.end.data and self.start.data >= self.end.data: raise ValidationError('The start time must be earlier than the end time.') validate_end = validate_start
class AgreementAnswerSubmissionForm(IndicoForm): answer = IndicoRadioField(_("Answer"), [InputRequired()], coerce=lambda x: bool(int(x)), choices=[(1, _("Agreement")), (0, _("Disagreement"))]) document = FileField(_("Document"), [UsedIf(lambda form, field: form.answer.data), DataRequired()]) upload_confirm = BooleanField(_("I confirm that I'm uploading a document that clearly shows this person's answer"), [UsedIf(lambda form, field: form.answer.data), DataRequired()]) understand = BooleanField(_("I understand that I'm answering the agreement on behalf of this person"), [DataRequired()], description=_("This answer is legally binding and can't be changed " "afterwards."))
class NewBookingSimpleForm(NewBookingConfirmForm): submit_check = SubmitField(_('Check conflicts')) booking_reason = TextAreaField(_('Reason'), [UsedIf(lambda form, field: not form.submit_check.data), DataRequired()]) room_usage = RadioField(validators=[UsedIf(lambda form, field: not form.submit_check.data), DataRequired()], choices=[('current_user', _("I'll be using the room myself")), ('other_user', _("I'm booking the room for someone else"))]) booked_for_user = PrincipalField(_('User'), [UsedIf(lambda form, field: not form.submit_check.data), HiddenUnless('room_usage', 'other_user'), DataRequired()], allow_external=True)
class _DateTimePair(Form): start = DateTimeField(_(u'from'), [UsedIf(lambda form, field: form.end.data)], display_format='%d/%m/%Y %H:%M', parse_kwargs={'dayfirst': True}) end = DateTimeField(_(u'to'), [UsedIf(lambda form, field: form.start.data)], display_format='%d/%m/%Y %H:%M', parse_kwargs={'dayfirst': True}) def validate_start(self, field): if self.start.data and self.end.data and self.start.data >= self.end.data: raise ValidationError('The start date must be earlier than the end date.') validate_end = validate_start
class EventSettingsForm(PaymentEventSettingsFormBase): use_event_api_keys = BooleanField( _('Use event API keys'), [Optional()], default=False, description=_( 'Override the organization Stripe API keys.' ), widget=SwitchWidget(), ) pub_key = StringField( _('Publishable key'), [ HiddenUnless('use_event_api_keys'), UsedIf(lambda form, _: form.use_event_api_keys.data), DataRequired(), ], description=_('Publishable API key for the stripe.com account') ) sec_key = StringField( _('Secret key'), [ HiddenUnless('use_event_api_keys'), UsedIf(lambda form, _: form.use_event_api_keys.data), DataRequired(), ], description=_('Secret API key for the stripe.com account') ) org_name = StringField( _('Organizer name'), [Optional()], default='Organization', description=_('Name of the event organizer') ) description = StringField( _('Description'), [Optional()], default='Payment for conference', description=_('A description of the product or service being purchased') ) require_postal_code = BooleanField( _('Require postal code input'), [Optional()], default=False, description=_( 'Require registrants to input their postal code when filling the' ' payment form. Enabling this will decrease the chance of the' ' payment being marked as fraudulent.' ), widget=SwitchWidget(), )
class AbstractReviewingSettingsForm(IndicoForm): """Settings form for abstract reviewing""" RATING_FIELDS = ('scale_lower', 'scale_upper') scale_lower = IntegerField(_("Scale (from)"), [UsedIf(lambda form, field: not form.has_ratings), InputRequired()]) scale_upper = IntegerField(_("Scale (to)"), [UsedIf(lambda form, field: not form.has_ratings), InputRequired()]) allow_convener_judgment = BooleanField(_("Allow track conveners to judge"), widget=SwitchWidget(), description=_("Enabling this allows track conveners to make a judgment " "such as accepting or rejecting an abstract.")) allow_comments = BooleanField(_("Allow comments"), widget=SwitchWidget(), description=_("Enabling this allows judges, conveners and reviewers to leave " "comments on abstracts.")) allow_contributors_in_comments = BooleanField(_("Allow contributors in comments"), [HiddenUnless('allow_comments', preserve_data=True)], widget=SwitchWidget(), description=_("Enabling this allows submitters, authors, and " "speakers to also participate in the comments.")) reviewing_instructions = IndicoMarkdownField(_('Reviewing Instructions'), editor=True, description=_("These instructions will be displayed right before the " "reviewing form.")) judgment_instructions = IndicoMarkdownField(_('Judgment Instructions'), editor=True, description=_("These instructions will be displayed right before the " "decision box.")) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') self.has_ratings = kwargs.pop('has_ratings', False) super(AbstractReviewingSettingsForm, self).__init__(*args, **kwargs) if self.has_ratings: self.scale_upper.warning = _("Some reviewers have already submitted ratings so the scale cannot be changed " "anymore.") def validate_scale_upper(self, field): lower = self.scale_lower.data upper = self.scale_upper.data if lower is None or upper is None: return if lower >= upper: raise ValidationError(_("The scale's 'to' value must be greater than the 'from' value.")) if upper - lower > 20: raise ValidationError(_("The difference between 'to' and' from' may not be greater than 20.")) @property def data(self): data = super(AbstractReviewingSettingsForm, self).data if self.has_ratings: for key in self.RATING_FIELDS: del data[key] return data
class EventSettingsForm(PaymentEventSettingsFormBase): details = TextAreaField(_('Payment details'), [UsedIf(lambda form, _: form.enabled.data), DataRequired()]) def __init__(self, *args, **kwargs): super(EventSettingsForm, self).__init__(*args, **kwargs) self.details.description = DETAILS_DESC + '\n' + render_placeholder_info('manual-payment-details', regform=None, registration=None)
class ContributionProtectionForm(IndicoForm): protection_mode = IndicoProtectionField( _('Protection mode'), protected_object=lambda form: form.protected_object, acl_message_url=lambda form: url_for('contributions.acl_message', form. protected_object)) acl = AccessControlListField( _('Access control list'), [UsedIf(lambda form, field: form.protected_object.is_protected)], groups=True, allow_emails=True, default_text=_('Restrict access to this contribution'), description=_('List of users allowed to access the contribution')) managers = PrincipalListField( _('Managers'), groups=True, allow_emails=True, description=_('List of users allowed to modify the contribution')) submitters = PrincipalListField( _('Submitters'), groups=True, allow_emails=True, description=_( 'List of users allowed to submit materials for this contribution')) def __init__(self, *args, **kwargs): self.protected_object = kwargs.pop('contrib') super(ContributionProtectionForm, self).__init__(*args, **kwargs)
def _add_fields_hidden_unless(cls): for field_name in ('birth_date', 'nationality', 'birth_place'): inject_validators( RegistrationFormPersonalDataForm, field_name, [UsedIf(lambda form, field: form.request_cern_access.data)], early=True)
class AttachmentFormBase(IndicoForm): protected = BooleanField(_("Protected"), widget=SwitchWidget()) folder = QuerySelectField( _("Folder"), allow_blank=True, blank_text=_("No folder selected"), get_label='title', description=_( "Adding materials to folders allow grouping and easier permission " "management.")) acl = AccessControlListField( _("Access control list"), [UsedIf(lambda form, field: form.protected.data)], groups=True, allow_external=True, default_text=_('Restrict access to this material'), description=_( "The list of users and groups allowed to access the material")) def __init__(self, *args, **kwargs): linked_object = kwargs.pop('linked_object') super(AttachmentFormBase, self).__init__(*args, **kwargs) self.folder.query = (AttachmentFolder.find( object=linked_object, is_default=False, is_deleted=False).order_by(db.func.lower(AttachmentFolder.title))) @generated_data def protection_mode(self): return ProtectionMode.protected if self.protected.data else ProtectionMode.inheriting
class AddChatroomForm(EditChatroomForm): use_custom_server = BooleanField(_('Use custom server')) custom_server = StringField(_('Custom server'), [UsedIf(lambda form, field: form.use_custom_server.data), DataRequired()], filters=[lambda x: x.lower() if x else x], description=_('External Jabber server.')) def __init__(self, *args, **kwargs): self._date = kwargs.pop('date') super(AddChatroomForm, self).__init__(*args, **kwargs) self.use_custom_server.description = _('Check in case you want to use an external Jabber server and not the ' 'default one ({0}).').format(current_plugin.settings.get('muc_server')) def validate_name(self, field): jid = generate_jid(field.data, self._date) if not jid: # This error is not very helpful to a user, but it is extremely unlikely - only if he uses a name # which does not contain a single char usable in a JID raise ValidationError(_('Could not convert name to a jabber ID')) if Chatroom.find_first(jid_node=jid, custom_server=self.custom_server.data): raise ValidationError(_('A room with this name already exists')) if not self.custom_server.data: tmp_room = Chatroom(jid_node=jid) if room_exists(tmp_room.jid): raise ValidationError(_('A room with this name/JID already exists on the Jabber server ({0})').format( tmp_room.jid )) @generated_data def jid_node(self): return generate_jid(self.name.data, self._date)
class AttachmentFormBase(IndicoForm): protected = BooleanField(_('Protected'), widget=SwitchWidget()) folder = QuerySelectField( _('Folder'), allow_blank=True, blank_text=_('No folder selected'), get_label='title', description=_( 'Adding materials to folders allow grouping and easier permission ' 'management.')) acl = AccessControlListField( _('Access control list'), [UsedIf(lambda form, field: form.protected.data)], allow_groups=True, allow_external_users=True, allow_event_roles=True, allow_category_roles=True, allow_registration_forms=True, event=lambda form: form.event, description=_( 'The list of users and groups allowed to access the material')) def __init__(self, *args, **kwargs): linked_object = kwargs.pop('linked_object') self.event = getattr(linked_object, 'event', None) # not present in categories super().__init__(*args, **kwargs) self.folder.query = (AttachmentFolder.query.filter_by( object=linked_object, is_default=False, is_deleted=False).order_by(db.func.lower(AttachmentFolder.title))) @generated_data def protection_mode(self): return ProtectionMode.protected if self.protected.data else ProtectionMode.inheriting
class AttachmentFolderForm(IndicoForm): title = HiddenField(_('Name'), [DataRequired()], widget=TypeaheadWidget(), description=_('The name of the folder.')) description = TextAreaField( _('Description'), description=_('Description of the folder and its content')) protected = BooleanField(_('Protected'), widget=SwitchWidget()) acl = AccessControlListField( _('Access control list'), [UsedIf(lambda form, field: form.protected.data)], allow_groups=True, allow_external_users=True, allow_event_roles=True, allow_category_roles=True, allow_registration_forms=True, event=lambda form: form.event, description=_( 'The list of users and groups allowed to access the folder')) is_always_visible = BooleanField( _('Always Visible'), [HiddenUnless('is_hidden', value=False)], widget=SwitchWidget(), description=_( 'By default, folders are always visible, even if a user cannot ' 'access them. You can disable this behavior here, hiding the folder ' 'for anyone who does not have permission to access it.')) is_hidden = BooleanField( _('Always hidden'), [HiddenUnless('is_always_visible', value=False)], widget=SwitchWidget(), description= _('Always hide the folder and its contents from public display areas of ' 'the event. You can use this for folders to store non-image files used ' 'e.g. in download links. The access permissions still apply.')) def __init__(self, *args, **kwargs): self.linked_object = kwargs.pop('linked_object') self.event = getattr(self.linked_object, 'event', None) # not present in categories super().__init__(*args, **kwargs) self.title.choices = self._get_title_suggestions() def _get_title_suggestions(self): query = db.session.query(AttachmentFolder.title).filter_by( is_deleted=False, is_default=False, object=self.linked_object) existing = {x[0] for x in query} suggestions = set(get_default_folder_names()) - existing if self.title.data: suggestions.add(self.title.data) return sorted(suggestions) def validate_is_always_visible(self, field): if self.is_always_visible.data and self.is_hidden.data: raise ValidationError( 'These two options cannot be used at the same time') validate_is_hidden = validate_is_always_visible @generated_data def protection_mode(self): return ProtectionMode.protected if self.protected.data else ProtectionMode.inheriting
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.'))
class ScheduleSurveyForm(IndicoForm): start_dt = IndicoDateTimeField( _("Start"), [ UsedIf(lambda form, field: form.allow_reschedule_start), Optional(), DateTimeRange(earliest='now') ], default_time=time(0, 0), description=_("Moment when the survey will open for submissions")) end_dt = IndicoDateTimeField( _("End"), [Optional(), LinkedDateTime('start_dt')], default_time=time(23, 59), description=_("Moment when the survey will close")) resend_start_notification = BooleanField( _('Resend start notification'), widget=SwitchWidget(), description=_("Resend the survey start notification.")) def __init__(self, *args, **kwargs): survey = kwargs.pop('survey') self.allow_reschedule_start = kwargs.pop('allow_reschedule_start') self.timezone = survey.event_new.timezone super(IndicoForm, self).__init__(*args, **kwargs) if not survey.start_notification_sent or not self.allow_reschedule_start: del self.resend_start_notification
class AttachmentFolderForm(IndicoForm): title = HiddenField(_("Name"), [DataRequired()], widget=TypeaheadWidget(), description=_("The name of the folder.")) description = TextAreaField(_("Description"), description=_("Description of the folder and its content")) protected = BooleanField(_("Protected"), widget=SwitchWidget()) acl = PrincipalListField(_("Grant Access To"), [UsedIf(lambda form, field: form.protected.data)], groups=True, serializable=False, allow_external=True, description=_("The list of users and groups with access to the folder")) is_always_visible = BooleanField(_("Always Visible"), widget=SwitchWidget(), description=_("By default, folders are always visible, even if a user cannot " "access them. You can disable this behavior here, hiding the folder " "for anyone who does not have permission to access it.")) def __init__(self, *args, **kwargs): self.linked_object = kwargs.pop('linked_object') super(AttachmentFolderForm, self).__init__(*args, **kwargs) self.title.choices = self._get_title_suggestions() def _get_title_suggestions(self): query = db.session.query(AttachmentFolder.title).filter_by(is_deleted=False, is_default=False, linked_object=self.linked_object) existing = set(x[0] for x in query) suggestions = set(get_default_folder_names()) - existing if self.title.data: suggestions.add(self.title.data) return sorted(suggestions) @generated_data def protection_mode(self): return ProtectionMode.protected if self.protected.data else ProtectionMode.inheriting
class VCRoomLinkFormBase(IndicoForm): conditional_fields = {'contribution', 'block'} linking = IndicoRadioField(_("Link to"), [DataRequired()], choices=[('event', _("Event")), ('contribution', _("Contribution")), ('block', _("Session"))], widget=LinkingWidget()) contribution = SelectField(_("Contribution"), [ UsedIf(lambda form, field: form.linking.data == 'contribution'), DataRequired() ], coerce=lambda x: int(x) if x else None) block = SelectField(_("Session block"), [ UsedIf(lambda form, field: form.linking.data == 'block'), DataRequired() ], coerce=lambda x: int(x) if x else None) show = BooleanField(_('Show room'), widget=SwitchWidget(), description=_('Display this room on the event page')) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') super().__init__(*args, **kwargs) contrib_choices = [ (contrib.id, '{} (#{}, {})'.format( contrib.title, contrib.friendly_id, format_datetime(contrib.start_dt, timezone=self.event.tzinfo))) for contrib in sorted(self.event.contributions, key=lambda c: (c.title, c.start_dt or as_utc( datetime(1970, 1, 1)))) if contrib.start_dt is not None ] blocks = (SessionBlock.query.filter( SessionBlock.session.has((Session.event == self.event) & ~Session.is_deleted)).all()) block_choices = [(block.id, '{} ({})'.format( block.full_title, format_datetime(block.start_dt, timezone=self.event.tzinfo))) for block in sorted( blocks, key=attrgetter('full_title', 'start_dt'))] self.contribution.choices = [('', _("Please select a contribution")) ] + contrib_choices self.block.choices = [('', _("Please select a session block")) ] + block_choices
class EventSettingsForm(PaymentEventSettingsFormBase): business = StringField( _('Business'), [ UsedIf(lambda form, _: form.enabled.data), DataRequired(), validate_business ], description=_( 'The PayPal ID or email address associated with a PayPal account.') )
class AVRequestForm(RequestFormBase): services = IndicoSelectMultipleCheckboxField(_('Services'), [DataRequired()], choices=SERVICES.items(), widget=JinjaWidget('service_type_widget.html', 'audiovisual'), description=_("Please choose whether you want a webcast, recording or " "both.")) all_contributions = BooleanField(_('All contributions'), description=_('Uncheck this if you want to select only certain contributions.')) contributions = IndicoSelectMultipleCheckboxField(_('Contributions'), [UsedIf(lambda form, field: not form.all_contributions.data), DataRequired()], widget=JinjaWidget('contribution_list_widget.html', 'audiovisual', SubContribution=SubContribution)) webcast_audience = SelectField(_('Webcast Audience'), description=_("Select the audience to which the webcast will be restricted")) comments = TextAreaField(_('Comments'), description=_('If you have any additional comments or instructions, please write them ' 'down here.')) def __init__(self, *args, **kwargs): super(AVRequestForm, self).__init__(*args, **kwargs) self._update_audiences() self._update_contribution_fields() def _update_audiences(self): audiences = [('', _("No restriction - everyone can watch the public webcast"))] audiences += sorted((x['audience'], x['audience']) for x in current_plugin.settings.get('webcast_audiences')) self.webcast_audience.choices = audiences def _update_contribution_fields(self): if self.event.type == 'lecture': # lectures don't have contributions del self.all_contributions del self.contributions else: choices = self.contributions.choices = [] disabled_contribs = self.contributions._disabled_contributions = [] contributions = self.contributions._contributions = {} is_manager = is_av_manager(session.user) selected = set(self.request.data.get('contributions', [])) if self.request else set() for contrib, capable, custom_room in get_contributions(self.event): is_subcontrib = isinstance(contrib, SubContribution) id_ = contribution_id(contrib) contributions[id_] = contrib line = Markup(render_template('audiovisual:contribution_list_entry.html', contrib=contrib, is_subcontrib=is_subcontrib, capable=capable, custom_room=custom_room)) if not capable and not is_manager and contrib.id not in selected: disabled_contribs.append((contrib, line)) else: choices.append((id_, line))
class ConferenceLayoutForm(LoggedLayoutForm): is_searchable = BooleanField(_("Enable search"), widget=SwitchWidget(), description=_("Enable search within the event")) show_nav_bar = BooleanField(_("Show navigation bar"), widget=SwitchWidget(), description=_("Show the navigation bar at the top")) show_banner = BooleanField(_("\"Now happening\""), widget=SwitchWidget(on_label=_("ON"), off_label=_("OFF")), description=_("Show a banner with the current entries from the timetable")) show_social_badges = BooleanField(_("Show social badges"), widget=SwitchWidget()) name_format = IndicoEnumSelectField(_('Name format'), enum=NameFormat, none=_('Inherit from user preferences'), description=_('Format in which names are displayed')) # Style header_text_color = StringField(_("Text colour"), widget=ColorPickerWidget()) header_background_color = StringField(_("Background colour"), widget=ColorPickerWidget()) # Announcement announcement = StringField(_("Announcement"), [UsedIf(lambda form, field: form.show_announcement.data)], description=_("Short message shown below the title")) show_announcement = BooleanField(_("Show announcement"), widget=SwitchWidget(), description=_("Show the announcement message")) # Timetable timetable_by_room = BooleanField(_("Group by room"), widget=SwitchWidget(), description=_("Group the entries of the timetable by room by default")) timetable_detailed = BooleanField(_("Show detailed view"), widget=SwitchWidget(), description=_("Show the detailed view of the timetable by default.")) timetable_theme = SelectField(_('Theme'), [Optional()], coerce=lambda x: x or None) # Themes use_custom_css = BooleanField(_("Use custom CSS"), widget=SwitchWidget(), description=_("Use a custom CSS file as a theme for the conference page. Deactivate " "this option to reveal the available Indico themes.")) theme = SelectField(_("Theme"), [Optional(), HiddenUnless('use_custom_css', False)], coerce=lambda x: (x or None), description=_("Currently selected theme of the conference page. Click on the Preview button to " "preview and select a different one.")) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') super(ConferenceLayoutForm, self).__init__(*args, **kwargs) self.timetable_theme.choices = [('', _('Default'))] + _get_timetable_theme_choices(self.event) self.theme.choices = _get_conference_theme_choices() def validate_use_custom_css(self, field): if field.data and not self.event.has_stylesheet: raise ValidationError(_('Cannot enable custom stylesheet unless there is one.'))
class SessionProtectionForm(IndicoForm): protection_mode = IndicoProtectionField( _('Protection mode'), protected_object=lambda form: form.protected_object, acl_message_url=lambda form: url_for('sessions.acl_message', form. protected_object)) acl = AccessControlListField( _('Access control list'), [UsedIf(lambda form, field: form.protected_object.is_protected)], groups=True, allow_emails=True, description=_('List of users allowed to access the session.')) managers = PrincipalListField( _('Managers'), groups=True, allow_emails=True, description=_('List of users allowed to modify the session')) coordinators = PrincipalListField(_('Coordinators'), groups=True, allow_emails=True) def __init__(self, *args, **kwargs): self.protected_object = kwargs.pop('session') super(SessionProtectionForm, self).__init__(*args, **kwargs)
class EventSettingsForm(PaymentEventSettingsFormBase): details = TextAreaField( _('Payment details'), [UsedIf(lambda form, _: form.enabled.data), DataRequired()], description=DETAILS_DESC)
class AnnouncementForm(IndicoForm): enabled = BooleanField(_('Enabled'), widget=SwitchWidget()) message = TextAreaField( _('Message'), [UsedIf(lambda form, _: form.enabled.data), DataRequired()])
class NewBookingSimpleForm(NewBookingConfirmForm): submit_check = SubmitField(_(u'Check conflicts')) booking_reason = TextAreaField(_(u'Reason'), [ UsedIf(lambda form, field: not form.submit_check.data), DataRequired() ])