Exemple #1
0
    def get_class_schema(cls, request=None):
        schema = Content.get_class_schema(request)
        #schema.add(colander.SchemaNode(colander_types.DateUS(), name='dateline', default=today_for_request_tz(request)))
        schema.add(colander.SchemaNode(colander_types.DateTimeUS(get_timezone_for_request(request)), name='dateline', default=utcnow()))
        schema.add(colander.SchemaNode(colander.String(), name='body', widget=widgets.get_html_widget()))
        # Single file upload:
        #schema.add(colander.SchemaNode(deform.FileData(), name='attachment', widget=widgets.get_fileupload_widget(request)))

        # Sequence of file uploads:
        schema.add(colander.SchemaNode(colander.Sequence(), colander.SchemaNode(deform.FileData(), widget=widgets.get_fileupload_widget(request)), name='attachments', missing=[], default=[]))
        schema.add(colander.SchemaNode(colander.Boolean(), name='list_attachments', title="List attachments after body?", default=False, missing=False))

        return schema
Exemple #2
0
    def get_class_schema(cls, request=None):
        schema = BaseFolder.get_class_schema(request)

        sort1_settings = colander.SchemaNode(colander.Mapping(), name='sort1_settings', title='Primary sort')

        sort1_settings.add(colander.SchemaNode(colander.String(), name='field', include_in_other_text=False, title="Primary sort field", default='', missing='', widget=deform.widget.SelectWidget(values=cls.SORT_CHOICES), description="When child ordering is disabled, the field specified here is used as the primary sort key when listing child objects."))
        sort1_settings.add(colander.SchemaNode(colander.String(), name='other', include_in_other_text=False, title="Primary sort field other", widget=widgets.get_wide_text_widget(), default='', missing='', description="The name of another field (when the primary sort field is set to \"other\")."))
        sort1_settings.add(colander.SchemaNode(colander.String(), name='dir', include_in_other_text=False, title="Primary sort direction", default='asc', missing='asc', widget=deform.widget.SelectWidget(values=cls.SORT_DIR_CHOICES)))
        sort1_settings.validator = sort_settings_validator
        schema.add(sort1_settings)

        sort2_settings = colander.SchemaNode(colander.Mapping(), name='sort2_settings', title='Secondary sort')

        sort2_settings.add(colander.SchemaNode(colander.String(), name='field', include_in_other_text=False, title="Secondary sort field", default='', missing='', widget=deform.widget.SelectWidget(values=cls.SORT_CHOICES), description="When child ordering is disabled, the field specified here is used as the secondary sort key when listing child objects."))
        sort2_settings.add(colander.SchemaNode(colander.String(), name='other', include_in_other_text=False, title="Secondary sort field other", widget=widgets.get_wide_text_widget(), default='', missing='', description="The name of another field (when the secondary sort field is set to \"other\")."))
        sort2_settings.add(colander.SchemaNode(colander.String(), name='dir', include_in_other_text=False, title="Secondary sort direction", default='asc', missing='asc', widget=deform.widget.SelectWidget(values=cls.SORT_DIR_CHOICES)))
        sort2_settings.validator = sort_settings_validator
        schema.add(sort2_settings)

        schema.add(colander.SchemaNode(colander.String(), name='view_style', include_in_other_text=False, title="Folder view style", default='list_children', widget=deform.widget.SelectWidget(values=cls.VIEW_STYLE_CHOICES), description="This field determines what will be displayed when a user views this folder.  Depending on the setting you select in this field, some of the other fields below may become required."))
        child_list_settings = colander.SchemaNode(colander.Mapping(), name='child_list_settings', title='Child listing settings')
        child_list_settings.add(colander.SchemaNode(colander.String(), name='list_item_style', include_in_other_text=False, title="List item style", default='title_only', missing='title_only', widget=deform.widget.SelectWidget(values=cls.LIST_ITEM_STYLE_CHOICES), description="This field determines what fields will be displayed for each child item listed."))
        child_list_settings.add(colander.SchemaNode(colander.String(), name='display_date', include_in_other_text=False, title="Date to display", default='_created', missing='_created', widget=deform.widget.SelectWidget(values=cls.DATE_CHOICES), description="This field determines which date will be displayed for each child (when list item style includes date)."))
        child_list_settings.add(colander.SchemaNode(colander.String(), name='other_display_date', include_in_other_text=False, title="Other display date", widget=widgets.get_wide_text_widget(), default='', missing='', description="The name of another date field (when the date to display is set to \"other\")."))
        child_list_settings.add(colander.SchemaNode(colander.String(), name='intro', widget=widgets.get_html_widget(), default='', missing='', description="Any content entered here will be displayed before the list of child objects."))
        child_list_settings.add(colander.SchemaNode(colander.String(), name='outro', widget=widgets.get_html_widget(), default='', missing='', description="Any content entered here will be displayed after the list of child objects."))
        child_list_settings.add(colander.SchemaNode(colander.Boolean(), name='intro_outro_first_page_only', title="Show intro and outro on first page only?", default=False, missing=False, description="For unordered folders, large numbers of children will be split across multiple pages.  In such a case, the intro and outro will be displayed on all pages unless you enable this option."))
        child_list_settings.validator = child_list_settings_validator
        schema.add(child_list_settings)
        schema.add(colander.SchemaNode(colander.String(), name='specific_child_name', include_in_other_text=False, title="Name of child to display", widget=widgets.get_wide_text_widget(), default='index', missing='', description="The name of a specific child to try to display (when the view style is \"display specific child\")."))
        schema.add(colander.SchemaNode(colander.String(), name='template_name', include_in_other_text=False, title="Name of template", widget=widgets.get_wide_text_widget(), default='', missing='', description="The name of a template to render on this folder (when the view style is \"use a template\")."))
        schema.add(colander.SchemaNode(colander.String(), name='view_name', include_in_other_text=False, title="Name of view", widget=widgets.get_wide_text_widget(), default='', missing='', description="The name of a view to render on this folder (when the view style is \"use a view\")."))
        schema.validator = schema_validator
        return schema