class ServiceDefinitionSchema(VisualisableElementSchema): """Schema for service""" description = colander.SchemaNode( colander.String(), widget=LimitedTextAreaWidget(rows=5, cols=30, limit=350, alert_values={'limit': 350}, css_class="ce-field-description"), description=_('Thank you to enter a description for your service.'), title=_("Description of the service"), ) details = colander.SchemaNode( colander.String(), widget=RichTextWidget(), missing="", description=_('Other information about the service.'), title=_('Details'), ) subscription = omit( SubscriptionSchema(widget=SimpleMappingWidget( css_class='object-well default-well')), ['_csrf_token_'])
class GameSchema(VisualisableElementSchema, SearchableEntitySchema): """Schema for Web advertising""" name = NameSchemaNode(editing=context_is_a_game, ) description = colander.SchemaNode(colander.String(), widget=RichTextWidget(), title=_("Description"), missing="") winners = colander.SchemaNode(colander.Set(), widget=winners_widget, title=_('Winners')) winner_number = colander.SchemaNode(colander.Int(), title=_('Winner number')) participants = colander.SchemaNode(colander.Set(), widget=participants_widget, title=_('Participants')) start_date = colander.SchemaNode(colander.DateTime(), title=_('Start date')) end_date = colander.SchemaNode(colander.DateTime(), title=_('End date')) announcement = colander.SchemaNode(ObjectType(), widget=announcement_choice, missing=None, title=_("Cultural event")) picture = colander.SchemaNode(ObjectData(Image), widget=picture_widget, title=_('Picture'), missing=None)
class WebAdvertisingSchema(AdvertisingSchema): """Schema for Web advertising""" name = NameSchemaNode(editing=context_is_a_webadvertising, ) tree = colander.SchemaNode( typ=DictSchemaType(), widget=keyword_widget, default=DEFAULT_TREE, missing=None, title=_('Categories'), ) home_page = colander.SchemaNode( colander.Boolean(), default=False, missing=False, label=_('Not'), title=None, description=_('Home page'), ) picture = colander.SchemaNode( ObjectData(File), widget=get_file_widget(item_css_class="advertising-file-content", css_class="file-content", file_type=['image', 'flash']), title=_('Advertisement file'), description=_("Only image and flash files are supported."), missing=None) html_content = colander.SchemaNode( colander.String(), widget=RichTextWidget(item_css_class="advertising-html-content", css_class="html-content-text"), title=_("Or HTML content"), missing="") advertisting_url = colander.SchemaNode(colander.String(), title=_('URL'), missing="#") positions = colander.SchemaNode(colander.Set(), widget=advertisting_widget, title=_('Positions')) @invariant def content_invariant(self, appstruct): if not (appstruct['html_content'] or appstruct['picture']): raise colander.Invalid(self, _('Content will be defined.')) @invariant def banner_invariant(self, appstruct): positions = appstruct['positions'] if positions: for position in positions: ADVERTISING_CONTAINERS[position]['validator']( self.get('picture'), appstruct)
class ProposalSchema(VisualisableElementSchema, SearchableEntitySchema): """Schema for Proposal""" name = NameSchemaNode( editing=context_is_a_proposal, ) challenge = colander.SchemaNode( ObjectType(), widget=challenge_choice, missing=None, title=_("Challenge (optional)"), description=_("You can select and/or modify the challenge associated to this proposal. " "For an open proposal, do not select anything in the « Challenge » field.") ) description = colander.SchemaNode( colander.String(), validator=colander.Length(max=600), widget=LimitedTextAreaWidget(rows=5, cols=30, limit=600), title=_("Abstract") ) text = colander.SchemaNode( colander.String(), widget=RichTextWidget(), title=_("Text") ) related_ideas = colander.SchemaNode( colander.Set(), widget=ideas_choice, title=_('Related ideas'), validator=Length(_, min=1), default=[], ) add_files = omit(AddFilesSchemaSchema( widget=SimpleMappingtWidget( mapping_css_class='controled-form' ' object-well default-well hide-bloc', ajax=True, activator_icon="glyphicon glyphicon-file", activator_title=_('Add files'))), ["_csrf_token_"]) 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 CandidacySchema(VisualisableElementSchema): """Schema for Candidacy""" name = NameSchemaNode(editing=context_is_a_candidacy, ) body = colander.SchemaNode( colander.String(), widget=RichTextWidget(), title=_('Application'), )
class HomepageConfigurationSchema(Schema): homepage_picture = colander.SchemaNode( ObjectData(File), widget=get_file_widget(file_extensions=['png', 'jpg', 'svg']), title=_('Picture of the homepage'), missing=None, description=_("Only PNG and SVG files are supported."), ) homepage_text = colander.SchemaNode(colander.String(), widget=RichTextWidget(), title=_("Text"), missing='')
class NewsletterSchema(VisualisableElementSchema): """Schema for newsletter""" name = NameSchemaNode(editing=context_is_a_newsletter, ) subject = colander.SchemaNode( colander.String(), title=_('Subject'), default=default_subject, description=_('The subject of the newsletter.')) description = colander.SchemaNode(colander.String(), widget=deform.widget.TextAreaWidget( rows=4, cols=60), title=_("Description")) content_template = colander.SchemaNode( ObjectData(File), widget=get_file_widget(file_extensions=['html']), title=_('Content template'), missing=None, description=_("Only HTML files are supported."), ) content = colander.SchemaNode( colander.String(), widget=RichTextWidget(), default=default_content, missing='', title=_("Content"), description=_("The content to send."), ) recurrence = colander.SchemaNode(colander.Boolean(), widget=deform.widget.CheckboxWidget(), label=_('Sends automatic'), title='', missing=False) sending_date = colander.SchemaNode(colander.Date(), title=_('Sending date')) recurrence_nb = colander.SchemaNode(colander.Int(), title=_('Frequency/days'), default=7)
class NewsletterSchema(VisualisableElementSchema): """Schema for newsletter""" typ_factory = ObjectData name = NameSchemaNode(editing=context_is_a_newsletter, ) subject = colander.SchemaNode( colander.String(), title=_('Subject'), default=default_subject, description=_('The subject of the newsletter.')) description = colander.SchemaNode(colander.String(), widget=deform.widget.TextAreaWidget( rows=4, cols=60), title=_("Description")) content = colander.SchemaNode( colander.String(), validator=colander.All(content_validator, ), widget=RichTextWidget(), default=default_content, missing='', title=_("Content"), description=_("The content to be sent."), ) working_params_conf = omit( NewsletterWorkingParamConf(widget=SimpleMappingtWidget( mapping_css_class='controled-form' ' object-well default-well', ajax=True, activator_icon="glyphicon glyphicon-cog", activator_title=_('Configure the working parameters'))), ["_csrf_token_"]) rec_conf = omit( NewsletterRecConf(widget=SimpleMappingtWidget( mapping_css_class='controled-form' ' object-well default-well', ajax=True, activator_icon="glyphicon glyphicon-repeat", activator_title=_('Configure the recurrence'))), ["_csrf_token_"])
class CorrectionSchema(VisualisableElementSchema): """Schema for correction of a proposal""" name = NameSchemaNode( editing=context_is_a_correction, ) description = colander.SchemaNode( colander.String(), validator=colander.Length(max=600), widget=LimitedTextAreaWidget(rows=5, cols=30, limit=600), title=_("Abstract") ) text = colander.SchemaNode( colander.String(), widget=RichTextWidget(), title=_("Text") )
class AmendmentSchema(VisualisableElementSchema, SearchableEntitySchema): """Schema for Amendment""" name = NameSchemaNode(editing=context_is_a_amendment, ) description = colander.SchemaNode(colander.String(), validator=colander.Length(max=300), widget=LimitedTextAreaWidget(rows=5, cols=30, limit=300), title=_("Abstract")) text = colander.SchemaNode(colander.String(), widget=RichTextWidget(), title=_("Text")) add_files = omit( AddFilesSchemaSchema(widget=SimpleMappingtWidget( mapping_css_class='controled-form' ' object-well default-well hide-bloc', ajax=True, activator_icon="glyphicon glyphicon-file", activator_title=_('Add files'))), ["_csrf_token_"])
class ChallengeSchema(VisualisableElementSchema, SearchableEntitySchema): """Schema for challenge""" name = NameSchemaNode(editing=context_is_a_challenge, ) description = colander.SchemaNode( colander.String(), validator=colander.Length(max=300), widget=LimitedTextAreaWidget(rows=5, cols=30, limit=300), title=_("Abstract"), description=_("Describe in a few words the challenge.")) text = colander.SchemaNode( colander.String(), widget=RichTextWidget(), title=_("Text"), description=_("You can describe in detail the challenge.")) image = colander.SchemaNode( ObjectData(Image), widget=image_widget, title=_('Image'), description= _('You see a square on the top left of the image if it exceeds the maximum' ' size allowed. Move and enlarge it if necessary, to determine an area of' ' interest. Several images will be generated from this area.'), ) 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'), ) is_restricted = colander.SchemaNode( colander.Boolean(), widget=deform.widget.CheckboxWidget( item_css_class='is-restricted-input'), label=_('Is restricted'), title='', description= _('Check this box if the challenge is restricted to a set of members. ' 'Only concerned members can add and see the contents created in this challenge.' ), missing=False) invited_users = colander.SchemaNode( colander.Set(), widget=users_to_invite, title=_('Concerned users'), description=_( 'Find and select the concerned members or organizations. ' 'If you want to see the members or organizations... already ' 'registered on the platform, enter a *'), missing=[], ) deadline = colander.SchemaNode( colander.Date(), title=_('Deadline'), description= _("If your challenge is punctual, you can add a deadline for participation." ), missing=None) 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 FileSchema(VisualisableElementSchema, SearchableEntitySchema): text = colander.SchemaNode(colander.String(), widget=RichTextWidget(), title=_("Text"))