class StructureBaseSchema(VisualisableElementSchema): """Schema for Structure""" structure_name = colander.SchemaNode( colander.String(), title=_('Structure name'), ) domains = colander.SchemaNode( colander.String(), widget=LimitedTextAreaWidget(rows=5, cols=30, limit=350, alert_values={'limit': 350}, css_class="ce-field-description"), title=_("Cultural domains"), missing="", ) address = colander.SchemaNode( colander.Sequence(), omit(AddressSchema(name='address', widget=SimpleMappingWidget( css_class='address-well object-well default-well')), ['_csrf_token_']), widget=SequenceWidget( max_len=1, min_len=1, add_subitem_text_template=_('Add a new address')), title=_('Address'), ) contact = colander.SchemaNode( colander.Sequence(), omit(select(ContactSchema(name='contact', widget=SimpleMappingWidget( css_class='address-well object-well default-well')), ['person_to_contact', 'public_phone', 'professional_phone', 'fax', 'website']), ['_csrf_token_']), widget=SequenceWidget( max_len=1, min_len=1, add_subitem_text_template=_('Add a new contact')), title=_('Contact'), ) picture = colander.SchemaNode( ObjectData(Image), widget=get_file_widget(file_type=['image']), title=_('Logo'), required=False, missing=None, )
class CreationCulturelleApplicationSchema(VisualisableElementSchema): """Schema for application configuration.""" name = NameSchemaNode(editing=context_is_a_root, ) titles = colander.SchemaNode( colander.Sequence(), colander.SchemaNode(colander.String(), name=_("Title")), widget=SequenceWidget(), default=DEFAULT_TITLES, title=_('List of titles'), ) tree = colander.SchemaNode( typ=DictSchemaType(), validator=colander.All(keywords_validator), widget=keyword_widget, default=DEFAULT_TREE, title=_('Categories'), ) organizations = colander.SchemaNode( colander.Sequence(), omit( OrganizationSchema(factory=Organization, editable=True, name=_('Organization'), widget=SimpleMappingWidget( css_class='object-well default-well'), omit=['managers']), ['_csrf_token_']), widget=organizations_choice, title=_('Organizations'), )
class FilterConfigurationSchema(Schema): filters = colander.SchemaNode( colander.Sequence(), omit(select(FilterSchema(name='filter', title=_('Filter'), widget=SimpleMappingWidget( css_class="object-well default-well mail-template-well mail-template-block")), ['metadata_filter', 'geographic_filter', 'temporal_filter', 'contribution_filter', 'text_filter', 'other_filter']), ["_csrf_token_"]), title=_('Filters'), widget=SequenceWidget( min_len=1, add_subitem_text_template=_('Add a new filter'))) hold_filter = colander.SchemaNode( colander.Boolean(), widget=deform.widget.CheckboxWidget(), label=_('Keep the filter after sign in'), title='', default=True, missing=True )
def folder_seq_widget(node, kw): folders = node.bindings['folders'] len_f = len(folders) return SequenceWidget(item_css_class="ordered-folder-seq", orderable=True, max_len=len_f, min_len=len_f)
def organizations_choice(node, kw): context = node.bindings['context'] len_organizations = len(context.organizations) if len_organizations == 0: len_organizations = -1 return SequenceWidget(min_len=len_organizations, max_len=len_organizations)
class LabelsSchema(Schema): labels = colander.SchemaNode( colander.Set(), widget=labels_choices, title=_('Labels'), description=_('You can add labels to this object.'), default=[], missing=[] ) new_labels = colander.SchemaNode( colander.Sequence(), omit(select(LabelSchema( name='new_label', factory=Label, editable=True, widget=SimpleMappingWidget( css_class='label-well object-well default-well')), ['title', 'picture']), ['_csrf_token_']), widget=SequenceWidget( add_subitem_text_template=_('Add a new label')), title=_('New labels'), )
class EventsInterfaceConfigurationSchema(Schema): nb_event_maxi = colander.SchemaNode( colander.Integer(), title=_('Maximum number of events per Member'), default=7, ) event_descriptions = colander.SchemaNode( colander.Sequence(), omit( select( EventDescriptionTemplate( name='description', title=_('Description'), widget=SimpleMappingWidget( css_class= "object-well default-well mail-template-well mail-template-block" )), ['locale', 'template']), ['_csrf_token_']), widget=SequenceWidget( min_len=1, max_len=len(AVAILABLE_LANGUAGES), add_subitem_text_template=_('Add a new description')), title=_('Descriptions'), default=descriptions_default)
class MailSeqTemplate(Schema): mail_id = colander.SchemaNode( colander.String(), widget=deform.widget.HiddenWidget(), title=_('Mail id'), ) title = colander.SchemaNode( colander.String(), widget=deform.widget.TextInputWidget(template='readonly/textinput'), title=_('Title'), missing="" ) languages = colander.SchemaNode( colander.Sequence(), omit(select(MailTemplate(name='language', title=_('language'), widget=SimpleMappingWidget( css_class="object-well default-well mail-template-well mail-template-block")), ['locale', 'subject', 'template']), ['_csrf_token_']), widget=SequenceWidget( min_len=1, max_len=len(AVAILABLE_LANGUAGES), add_subitem_text_template=_('Add a new language')), title=_('Languages'), )
class InviteUsersSchema(Schema): invitations = colander.SchemaNode( colander.Sequence(), select(omit(InvitationSchema(factory=Invitation, editable=True, name='Invitation', widget=SimpleMappingWidget(css_class='object-well default-well')), ['_csrf_token_']), ['user_title', 'roles', 'first_name', 'last_name','email']), widget=SequenceWidget(min_len=1), title=_('The invitations') )
class CreatOrganizationsSchema(Schema): organizations = colander.SchemaNode( colander.Sequence(), select( omit( OrganizationSchema(factory=Organization, editable=True, name='Organization', widget=SimpleMappingWidget( css_class='object-well default-well')), ['_csrf_token_']), ['title', 'description', 'logo', 'cover_picture', 'contacts']), widget=SequenceWidget(min_len=1), title=_('Organizations to create'))
class KeywordsMappingSchema(Schema): mapping = colander.SchemaNode( colander.Sequence(), omit( select( KeywordMappingSchema( name='mapping', widget=SimpleMappingWidget( css_class='object-well default-well')), ['node_id', 'aliases', 'content_types']), ['_csrf_token_']), widget=SequenceWidget( add_subitem_text_template=_("Add a new keyword's mapping")), title=_("keywords's mapping"), missing=[])
class CinemaReviewSchema(BaseReviewSchema): """Schema for review""" name = NameSchemaNode(editing=context_is_a_cinema_review, ) nationality = colander.SchemaNode(colander.String(), widget=TextInputWidget(), title=_("Nationality")) directors_ids = colander.SchemaNode(colander.Set(), widget=directors_choice, title=_('Directors'), missing=[]) directors = colander.SchemaNode( colander.Sequence(), omit( select( ArtistInformationSheetSchema( editable=True, factory=ArtistInformationSheet, omit=('id', ), widget=SimpleMappingWidget( css_class='director-data object-well' ' default-well'), name=_('Director')), [ 'id', 'origin_oid', 'title', 'description', 'picture', 'biography' ]), ['_csrf_token_', '__objectoid__']), widget=SequenceWidget(css_class='directors-values', template='lac:views/' 'templates/sequence_modal.pt', item_template='lac:views/' 'templates/sequence_modal_item.pt'), title=_('Directors'), ) duration = colander.SchemaNode(colander.String(), widget=TextInputWidget(), title=_("Duration")) appreciation = colander.SchemaNode(colander.String(), widget=appreciation_choice, title=_("Appreciation")) opinion = colander.SchemaNode(colander.String(), widget=RichTextWidget(), title=_("Opinion"))
class OrganizationSchema(VisualisableElementSchema): """Schema for Organization""" name = NameSchemaNode(editing=context_is_a_organization, ) logo = colander.SchemaNode( ObjectData(Image), widget=get_file_widget(), required=False, missing=None, title=_('Logo'), ) cover_picture = colander.SchemaNode( ObjectData(File), widget=get_file_widget(file_extensions=['png', 'jpg', 'svg']), title=_('Cover picture'), missing=None, description=_("Only PNG and SVG files are supported."), ) contacts = colander.SchemaNode( colander.Sequence(), omit( select( ContactSchema( name='contact', widget=SimpleMappingWidget( css_class='contact-well object-well default-well')), [ 'title', 'address', 'phone', 'surtax', 'email', 'website', 'fax' ]), ['_csrf_token_']), widget=SequenceWidget( min_len=1, add_subitem_text_template=_('Add a new contact')), title='Contacts', oid='contacts') members = colander.SchemaNode(colander.Set(), widget=members_choice, title=_('Members'), missing=[]) managers = colander.SchemaNode(colander.Set(), widget=managers_choice, title=_('The managers'), missing=[])
class CinemagoerSchema(Schema): next_date = colander.SchemaNode( colander.Date(), title=_('End date of publication'), missing=None, ) venues = colander.SchemaNode( colander.Sequence(), omit( select( CinemaVenueSchema( name='venue', title=_('Venue'), widget=SimpleMappingWidget( css_class= "venue-block cinema-block object-well default-well")), ['id', 'title', 'schedules']), ['_csrf_token_']), widget=SequenceWidget(min_len=1, css_class="add-venues-mode"), title=_('Cinemas'), )
class OtherSchema(Schema): title = colander.SchemaNode( colander.String(), title=_('Title'), description=_("The title of the application"), missing="" ) locale = colander.SchemaNode( colander.String(), title=_('Locale'), widget=locale_widget, missing=locale_missing, validator=colander.OneOf(AVAILABLE_LANGUAGES), ) contacts = colander.SchemaNode( colander.Sequence(), omit(select(ContactSchema(name='contact', widget=SimpleMappingWidget( css_class='contact-well object-well default-well')), ['title', 'address', 'phone', 'surtax', 'email', 'website', 'fax']), ['_csrf_token_']), widget=SequenceWidget( add_subitem_text_template=_('Add a new contact')), title='Contacts', oid='contacts' ) analytics = colander.SchemaNode( colander.String(), widget=deform.widget.TextAreaWidget(rows=4, cols=60), title=_('Analytics'), missing='' )
def templates_widget(node, kw): len_templates = len(DEFAULT_SITE_MAILS) return SequenceWidget(min_len=len_templates, max_len=len_templates)
class SmartFolderSchema(VisualisableElementSchema): """Schema for keyword""" name = NameSchemaNode(editing=context_is_a_smartfolder, ) title = colander.SchemaNode( colander.String(), widget=TextInputWidget(css_class="smartfolder-title-field"), title=_('Title'), ) icon_data = colander.SchemaNode(DictSchemaType(), widget=BootstrapIconInputWidget(), title=_('Icon'), default={ 'icon': 'glyphicon-folder-open', 'icon_class': 'glyphicon' }, description=_('Select an icon.') # description="Sélectionner une icône." ) description = colander.SchemaNode( colander.String(), widget=deform.widget.TextAreaWidget(rows=4, cols=60), title=_("Description"), ) filters = colander.SchemaNode( colander.Sequence(), omit( select( FilterSchema(name='filter', title=_('Filter'), widget=SimpleMappingWidget( css_class='object-well default-well')), [ 'metadata_filter', 'geographic_filter', 'temporal_filter', 'contribution_filter', 'text_filter', 'other_filter' ]), ["_csrf_token_"]), widget=SequenceWidget(min_len=1, add_subitem_text_template=_('Add a new filter'))) classifications = colander.SchemaNode( colander.Sequence(), colander.SchemaNode(colander.String(), widget=classifications_widget, name=_("Classification")), widget=classifications_seq_widget, title=_('Classifications'), description=_('You can select one or more options of classification.'), missing=[]) add_as_a_block = colander.SchemaNode( colander.Boolean(), widget=deform.widget.CheckboxWidget(), label=_('Add as a block'), title='', description=_('You can add as a block to the home page.'), # description=('Vous pouvez ajouter en tant que bloc sur la page d\'accueil'), default=False, missing=False) style = omit(CssSchema(widget=SimpleMappingWidget()), ["_csrf_token_"]) view_type = colander.SchemaNode(colander.String(), widget=view_type_widget, title=_("View type"), default='default') @invariant def classification_invariant(self, appstruct): if appstruct.get('view_type', 'default') == 'bloc' and\ appstruct['classifications']: raise colander.Invalid( self, _('The bloc view is not classifiable! Please remove all classifications.' ))
def classifications_seq_widget(node, kw): return SequenceWidget( css_class="classifications-field", orderable=True, max_len=len(CLASSIFICATIONS), add_subitem_text_template=_('Add a new classification'))
class SiteFolderSchema(VisualisableElementSchema): """Schema for schedule""" typ_factory = ObjectData name = NameSchemaNode(editing=context_is_a_sitefolder, ) title = colander.SchemaNode( colander.String(), title=_('Title'), ) urls_ids = colander.SchemaNode( colander.Set(), widget=urls_ids_choise, title=_('URLs ids'), ) contacts = colander.SchemaNode( colander.Sequence(), omit( select( ContactSchema( name='contact', widget=SimpleMappingWidget( css_class='contact-well object-well default-well')), [ 'title', 'address', 'phone', 'surtax', 'email', 'website', 'fax' ]), ['_csrf_token_']), widget=SequenceWidget( min_len=1, add_subitem_text_template=_('Add a new contact')), title='Contacts', oid='contacts') filter_conf = omit( FilterConfigurationSchema(widget=SimpleMappingtWidget( mapping_css_class='controled-form' ' object-well default-well hide-bloc', ajax=True, activator_css_class="glyphicon glyphicon-filter", activator_title=_('Set up a filter'))), ["_csrf_token_"]) mail_conf = omit( MailTemplatesConfigurationSchema(widget=SimpleMappingtWidget( mapping_css_class='controled-form' ' object-well default-well hide-bloc', ajax=True, activator_css_class="glyphicon glyphicon-envelope", activator_title=_('Edit mail templates'))), ["_csrf_token_"]) ui_conf = omit( UserInterfaceConfigurationSchema(widget=SimpleMappingtWidget( mapping_css_class='controled-form' ' object-well default-well hide-bloc', ajax=True, activator_css_class="glyphicon glyphicon-eye-open", activator_title=_('Configure the ui'))), ["_csrf_token_"]) pub_conf = omit( PublicationConfigurationSchema(widget=SimpleMappingtWidget( mapping_css_class='controled-form' ' object-well default-well hide-bloc', ajax=True, activator_css_class="lac-icon icon-history", activator_title=_('Configure the publication settings'))), ["_csrf_token_"]) keywords_conf = omit( KeywordsConfSchema(widget=SimpleMappingtWidget( mapping_css_class='controled-form' ' object-well default-well hide-bloc', ajax=True, activator_css_class="glyphicon glyphicon-tags", activator_title=_('Configure the keywords tree'))), ["_csrf_token_"]) other_conf = omit( OtherSchema(widget=SimpleMappingtWidget( mapping_css_class='controled-form' ' object-well default-well hide-bloc', ajax=True, activator_css_class="glyphicon glyphicon-plus", activator_title=_('Other'))), ["_csrf_token_"])
class QuestionSchema(VisualisableElementSchema, SearchableEntitySchema): """Schema for question""" name = NameSchemaNode( editing=context_is_a_question, ) challenge = colander.SchemaNode( ObjectType(), widget=challenge_choice, missing=None, title=_("Challenge (optional)"), description=_("You can select and/or modify the challenge associated to this question. " "For an open question, do not select anything in the « Challenge » field.") ) title = colander.SchemaNode( colander.String(), title=_("Question") ) options = colander.SchemaNode( colander.Sequence(), colander.SchemaNode( colander.String(), name=_("Option") ), widget=SequenceWidget( add_subitem_text_template='', orderable=True), title=_('Options'), description=_("You can add options to your question. " "Users can only answer questions with options once. " "Statistics will be provided indicating the percentage " "of each option."), missing=[] ) text = colander.SchemaNode( colander.String(), widget=LimitedTextAreaWidget( rows=5, cols=30, limit=2000, alert_values={'limit': 2000}, item_css_class='content-preview-form', placeholder=_('I have a question!')), title=_("Details"), missing='' ) attached_files = colander.SchemaNode( colander.Sequence(), colander.SchemaNode( ObjectData(File), name=_("File"), widget=get_file_widget() ), widget=FilesWidget( add_subitem_text_template='', item_css_class='files-block'), missing=[], title=_('Attached files'), ) anonymous = colander.SchemaNode( colander.Boolean(), widget=anonymous_widget, label=_('Remain anonymous'), description=_('Check this box if you want to remain anonymous.'), title='', missing=False, default=False )
class BaseReviewSchema(VisualisableElementSchema, SearchableEntitySchema): """Schema for base review""" title = colander.SchemaNode(colander.String(), widget=TextInputWidget(), title=_('Title')) surtitle = colander.SchemaNode(colander.String(), widget=TextInputWidget(), title=_("Surtitle"), missing="") article = colander.SchemaNode(colander.String(), widget=article_widget, title=_("Article")) description = colander.SchemaNode(colander.String(), widget=deform.widget.TextAreaWidget( rows=4, cols=60), title=_("Description")) picture = colander.SchemaNode( ObjectData(Image), widget=picture_widget, title=_('Picture'), ) artists_ids = colander.SchemaNode(colander.Set(), widget=artists_choice, title=_('Artists'), missing=[]) artists = colander.SchemaNode( colander.Sequence(), omit( select( ArtistInformationSheetSchema( editable=True, factory=ArtistInformationSheet, omit=('id', ), widget=SimpleMappingWidget( css_class='artist-data object-well' ' default-well'), name=_('artist')), [ 'id', 'origin_oid', 'title', 'description', 'picture', 'biography', 'is_director' ]), ['_csrf_token_', '__objectoid__']), widget=SequenceWidget(css_class='artists-values', template='lac:views/' 'templates/sequence_modal.pt', item_template='lac:views/' 'templates/sequence_modal_item.pt'), title=_('Artists'), ) signature = colander.SchemaNode(colander.String(), widget=TextInputWidget(), title=_("Signature"), default=default_signature) informations = colander.SchemaNode(colander.String(), widget=RichTextWidget(), missing="", title=_("Informations")) showcase_review = colander.SchemaNode( colander.Boolean(), widget=deform.widget.CheckboxWidget(), label=_('Add to the carousel of the home page'), title='', default=False, missing=False)
class CulturalEventSchema(VisualisableElementSchema, SearchableEntitySchema): """Schema for cultural event""" name = NameSchemaNode(editing=context_is_a_cultural_event, ) title = colander.SchemaNode( colander.String(), title=_('Title'), description=_('Enter a title for your announcement.')) description = colander.SchemaNode( colander.String(), widget=LimitedTextAreaWidget(rows=5, cols=30, limit=350, alert_values={'limit': 350}, css_class="ce-field-description"), title=_("Brief description"), description=_('Describe succinctly the event.'), ) details = colander.SchemaNode( colander.String(), widget=RichTextWidget(css_class="ce-field-details"), missing="", description=_('You can describe in detail the event. (Recommended)'), title=_('Details'), oid='detailed_description') artists_ids = colander.SchemaNode( colander.Set(), widget=artists_choice, title=_('Artists'), description=_('You can enter the artists names.'), missing=[]) artists = colander.SchemaNode( colander.Sequence(), omit( select( ArtistInformationSheetSchema( editable=True, factory=ArtistInformationSheet, omit=('id', ), widget=SimpleMappingWidget( css_class='artist-data object-well' ' default-well'), name=_('artist')), [ 'id', 'origin_oid', 'title', 'description', 'picture', 'biography', 'is_director' ]), ['_csrf_token_', '__objectoid__']), widget=SequenceWidget(css_class='artists-values', template='lac:views/' 'templates/sequence_modal.pt', item_template='lac:views/' 'templates/sequence_modal_item.pt'), title=_('Artists'), ) tree = colander.SchemaNode( typ=DictSchemaType(), validator=colander.All(keywords_validator), widget=keyword_widget, default=DEFAULT_TREE, title=_('Categories'), description= _('Indicate the category of the event. Please specify a second keyword level for each category chosen.' )) contacts = colander.SchemaNode( colander.Sequence(), omit( select( ContactSchema( name='contact', widget=SimpleMappingWidget( css_class='contact-well object-well default-well')), ['phone', 'surtax', 'email', 'website', 'fax']), ['_csrf_token_']), widget=SimpleSequenceWidget( add_subitem_text_template=_('Add a new contact'), remove_subitem_text_template=_('Remove the contact')), title=_('Contacts'), description= _('Indicate contacts of the event. If none is specified, venues contacts will be assigned to the event.' ), oid='contacts') picture = colander.SchemaNode( ObjectData(Image), #Pontus widget=picture_widget, title=_('Picture'), description=_( 'You can choose a picture to illustrate your announcement.'), missing=None, ) schedules = colander.SchemaNode( colander.Sequence(), omit( select( ScheduleSchema( name='schedule', factory=Schedule, editable=True, widget=SimpleMappingWidget( css_class='schedule-well object-well default-well'), omit=('venue', )), ['dates', 'venue', 'ticket_type', 'price', 'ticketing_url']), ['_csrf_token_']), widget=SimpleSequenceWidget( min_len=1, add_subitem_text_template=_('Add a new schedule'), remove_subitem_text_template=_('Remove the schedule')), description= _('If the event takes place in several locations, add a session by clicking the plus sign on the bottom right of the block "sessions".' ), title=_('Schedules'), ) selling_tickets = colander.SchemaNode( colander.Boolean(), widget=deform.widget.CheckboxWidget(), label=_('Selling tickets'), title='', description= _('Check this box if you want to be accompanied or to receive information on selling tickets online.' ), default=False, missing=False) ticketing_url = colander.SchemaNode( colander.String(), title=_('Ticketing URL'), description=_('For the online ticket sales.'), missing=None) accept_conditions = colander.SchemaNode( colander.Boolean(), widget=conditions_widget, label=_('I have read and accept the terms and conditions'), title='', missing=False) @invariant def contacts_invariant(self, appstruct): if not appstruct['contacts'] and \ any(not s['venue']['other_conf']['contacts'] for s in appstruct['schedules']): raise colander.Invalid( self.get('contacts'), _("Event's contact or all venues's contacts must be defined."))
class SmartFolderSchema(VisualisableElementSchema): """Schema for keyword""" name = NameSchemaNode(editing=context_is_a_smartfolder, ) title = colander.SchemaNode( colander.String(), widget=TextInputWidget(css_class="smartfolder-title-field"), title=_('Title'), ) description = colander.SchemaNode( colander.String(), widget=deform.widget.TextAreaWidget(rows=4, cols=60), title=_("Description"), ) locale = colander.SchemaNode( colander.String(), title=_('Locale'), description=_('The language for which the folder will be displayed'), widget=locale_widget, missing='') cover_picture = colander.SchemaNode( ObjectData(File), widget=get_file_widget(file_extensions=['png', 'jpg', 'svg']), title=_('Cover picture'), missing=None, description=_("Only PNG and SVG files are supported."), ) filters = colander.SchemaNode( colander.Sequence(), omit( select( FilterSchema(name='filter', title=_('Filter'), widget=SimpleMappingWidget( css_class='object-well default-well')), [ 'metadata_filter', 'temporal_filter', 'contribution_filter', 'text_filter', 'other_filter' ]), ["_csrf_token_"]), widget=SequenceWidget(add_subitem_text_template=_('Add a new filter')), title=_('Filters'), description=_('Applied filters'), missing=[]) contents = colander.SchemaNode( colander.Set(), widget=relatedcontents_choice, title=_('Associated contents'), description=_('Choose the contents to be associated'), missing=[], default=[], ) view_type = colander.SchemaNode(colander.String(), widget=view_type_widget, title=_("View type"), description=_('How to display contents'), default='default') icon_data = colander.SchemaNode(DictSchemaType(), widget=BootstrapIconInputWidget(), title=_('Icon'), default={ 'icon': 'glyphicon-folder-open', 'icon_class': 'glyphicon' }, description=_('Select an icon.')) style = omit(CssSchema(widget=SimpleMappingWidget()), ["_csrf_token_"]) @invariant def contact_invariant(self, appstruct): contents = appstruct.get('contents', []) filters = appstruct.get('filters', []) if not contents and not filters: raise colander.Invalid( self, _('Filters or associated contents must be specified.'))