class ICMSBehavior(Interface): index_field('hidden_navigation', type='boolean') fieldset('hidden_navigation', 'settings') hidden_navigation = schema.Bool(title='Should be hidden on navigation', required=False, default=False) index_field('language', type='keyword') fieldset('language', 'categorization') language = schema.Choice(title='Language', required=False, source='languages') index_field('content_layout', type='keyword') fieldset('content_layout', 'settings') content_layout = schema.Choice(title='Content Layout', required=False, source='content_layouts', default='default') index_field('position_in_parent', type='int') position = schema.Int(title='Position in parent', required=False) index_field('review_state', type='keyword') review_state = schema.Choice(readonly=True, title='Workflow review state', required=False, source='worklow_states') history = schema.List(title='History list', readonly=True, required=False, value_type=schema.JSONField(title='History element', schema=HISTORY_SCHEMA))
class ICMSBehavior(Interface): index_field("is_folderish", store=True, type="boolean") is_folderish = schema.Bool(title="Is a folderish object", readonly=True) index_field("hidden_navigation", store=True, type="boolean") fieldset("hidden_navigation", "settings") hidden_navigation = schema.Bool(title="Should be hidden on navigation", required=False, default=False) index_field("language", store=True, type="keyword") fieldset("language", "categorization") language = schema.Choice(title="Language", required=False, source="languages") index_field("content_layout", store=True, type="keyword") fieldset("content_layout", "settings") content_layout = schema.Choice(title="Content Layout", required=False, source="content_layouts", default="default") fieldset("allow_discussion", "settings") allow_discussion = schema.Bool(title="Allow discussion", required=False, default=False) # not absolute positioning, just a relative positioning # based on ordered numbers. It won't be numbers like 1,2,3,4,5,etc index_field("position_in_parent", type="int") position_in_parent = schema.Int(title="Position in parent", default=-1, required=False) index_field("review_state", store=True, type="keyword") review_state = schema.Choice(readonly=True, title="Workflow review state", required=False, source="worklow_states") history = schema.List( title="History list", readonly=True, required=False, value_type=schema.JSONField(title="History element", schema=HISTORY_SCHEMA), ) comments = schema.Dict( title="Comments list field", required=False, key_type=schema.TextLine(title="CommentID"), value_type=schema.JSONField(title="Comment", schema=DISCUSSION_SCHEMA), )
class ISyndicationSettings(Interface): max_items = schema.Int( title='Maximum items', description='Maximum number of items that will be syndicated.', default=15) sort_on = schema.Choice( title='Sort on', default='creation_date', source=AppSettingSource( 'syndication.sort_on', missing=[ ['creation_date', 'Publication Date'], ['effective_date', 'Publication Date'], ['modification_date', 'Modification Date'] ] ) ) sort_reverse = schema.Bool( title='Reverse sort', description='Order items in reverse order', default=True) categories = schema.List( title='Categories', description='(not used with all feed types)', value_type=schema.TextLine(), default=[], required=False, missing_value=[] )
def test_all(dummy_request): mapping = [ (schema.Object(schema=IResource), serialize_schema_field.DefaultSchemaFieldSerializer), (schema.Text(), serialize_schema_field.DefaultTextSchemaFieldSerializer), (schema.TextLine(), serialize_schema_field.DefaultTextLineSchemaFieldSerializer), (schema.Float(), serialize_schema_field.DefaultFloatSchemaFieldSerializer), (schema.Int(), serialize_schema_field.DefaultIntSchemaFieldSerializer), (schema.Bool(), serialize_schema_field.DefaultBoolSchemaFieldSerializer), (schema.List(), serialize_schema_field.DefaultCollectionSchemaFieldSerializer), (schema.Choice(values=('one', 'two')), serialize_schema_field.DefaultChoiceSchemaFieldSerializer), (schema.Object(schema=IResource), serialize_schema_field.DefaultObjectSchemaFieldSerializer), (RichText(), serialize_schema_field.DefaultRichTextSchemaFieldSerializer), (schema.Date(), serialize_schema_field.DefaultDateSchemaFieldSerializer), (schema.Time(), serialize_schema_field.DefaultTimeSchemaFieldSerializer), (schema.Dict(), serialize_schema_field.DefaultDictSchemaFieldSerializer), (schema.Datetime(), serialize_schema_field.DefaultDateTimeSchemaFieldSerializer), ] container = Container() for field, klass in mapping: adapter = getMultiAdapter((field, container, dummy_request), interface=ISchemaFieldSerializeToJson) assert isinstance(adapter, klass)
class ISyndicationSettings(Interface): max_items = schema.Int( title="Maximum items", description="Maximum number of items that will be syndicated.", default=15, ) sort_on = schema.Choice( title="Sort on", default="creation_date", source=AppSettingSource( "syndication.sort_on", missing=[ ["creation_date", "Publication Date"], ["effective_date", "Publication Date"], ["modification_date", "Modification Date"], ], ), ) sort_reverse = schema.Bool(title="Reverse sort", description="Order items in reverse order", default=True) categories = schema.List( title="Categories", description="(not used with all feed types)", value_type=schema.TextLine(), default=[], required=False, missing_value=[], )
class IFieldType(Interface): title = schema.Text() description = schema.Text() type = schema.Choice( values=["date", "integer", "text", "float", "keyword", "boolean"], required=True) required = schema.Bool(default=False) meta = schema.JSONField(title="Additional information on field", required=False, schema={ "type": "object", "properties": {} })
class IWorkflowBehavior(Interface): index_field("review_state", store=True, type="keyword") review_state = schema.Choice( readonly=True, title="Workflow review state", required=False, defaultFactory=DefaultReviewState(), source="worklow_states", ) history = schema.List( title="History list", readonly=True, required=False, defaultFactory=list, value_type=schema.JSONField(title="History element", schema=HISTORY_SCHEMA), )
class IFieldType(Interface): title = schema.Text(required=False) description = schema.Text(required=False) type = schema.Choice( values=['date', 'integer', 'text', 'float', 'keyword', 'boolean'] ) required = schema.Bool( default=False, required=False ) meta = schema.JSONField( title="Additional information on field", required=False, schema=json.dumps({ 'type': 'object', 'properties': {} }) )
class IFieldType(Interface): title = schema.Text() type = schema.Choice( values=['date', 'integer', 'text', 'float', 'keyword', 'boolean'])