def test_finalize_schema_do_not_hide(self): schema = ATContentTypeSchema.copy() finalize(schema, show=['subject']) self.assertNotEqual(ManagePortal, schema['subject'].write_permission) self.assertNotEquals({'view': 'invisible', 'edit': 'invisible'}, schema['subject'].widget.visible)
def test_finalize_schema_additional_hide(self): schema = ATContentTypeSchema.copy() finalize(schema, hide=['title']) self.assertEquals(ManagePortal, schema['title'].write_permission) self.assertEquals({'view': 'invisible', 'edit': 'invisible'}, schema['title'].widget.visible)
def test_finalize_schema(self): schema = ATContentTypeSchema.copy() finalize(schema) for name in DEFAULT_TO_HIDE: if name in schema: self.assertEquals(ManagePortal, schema[name].write_permission) self.assertEquals({'view': 'invisible', 'edit': 'invisible'}, schema[name].widget.visible) self.assertTrue(schema['excludeFromNav'].default)
from ftw.book.config import PROJECTNAME from ftw.book.interfaces import IRemark from ftw.contentpage.content import textblock from ftw.contentpage.content.schema import finalize from zope.interface import implements try: from Products.LinguaPlone import public as atapi except ImportError: from Products.Archetypes import atapi remark_schema = ATContentTypeSchema.copy() + \ textblock.default_schema.copy() remark_schema['title'].required = False remark_schema['title'].searchable = 0 finalize(remark_schema, hide=['description', 'showTitle']) class Remark(textblock.TextBlock): """A simplelayout block used for comments """ security = ClassSecurityInfo() implements(IRemark) schema = remark_schema atapi.registerType(Remark, PROJECTNAME)
htmlblock_schema = ATContentTypeSchema.copy() + \ textblock.default_schema.copy() htmlblock_schema['title'].required = False htmlblock_schema['description'].widget.visible = {'view': 'invisible', 'edit': 'invisible'} htmlblock_schema['text'].validators = () htmlblock_schema['text'].default_output_type = 'text/html' htmlblock_schema['text'].widget = atapi.TextAreaWidget( label=_(u'label_html', default=u'HTML'), description='', rows=32, cols=70) finalize(htmlblock_schema) class HTMLBlock(textblock.TextBlock): """HTML block for books. """ security = ClassSecurityInfo() implements(IHTMLBlock) schema = htmlblock_schema atapi.registerType(HTMLBlock, PROJECTNAME)
from Products.ATContentTypes.content import folder from ftw.book.config import PROJECTNAME from ftw.book.interfaces import IChapter from ftw.contentpage.content.schema import finalize from simplelayout.base.interfaces import ISimpleLayoutBlock from simplelayout.base.interfaces import ISimpleLayoutCapable from zope.interface import implements try: from Products.LinguaPlone.public import registerType except ImportError: # No multilingual support from Products.Archetypes.atapi import registerType chapter_schema = folder.ATFolder.schema.copy() finalize(chapter_schema, hide=['description']) chapter_schema['excludeFromNav'].default = False class Chapter(folder.ATFolder): implements(IChapter, ISimpleLayoutCapable, ISimpleLayoutBlock) security = ClassSecurityInfo() schema = chapter_schema security.declarePublic('canSetDefaultPage') def canSetDefaultPage(self): return False
def test_finalize_schema_show_inextisting_field(self): schema = ATContentTypeSchema.copy() # I'm not realy sure what to test self.assertNotIn('dummy', schema) finalize(schema, show=['dummy']) self.assertNotIn('dummy', schema)
widget=atapi.TextAreaWidget( label=_(u'label_directions', default=u'Directions'), description=_(u'help_directions', default=u''))), )) addressblock_schema = ATContentTypeSchema.copy() + schema.copy() addressblock_schema['title'].required = False addressblock_schema['title'].default_method = 'getDefaultTitle' # Finalize schema finalize(addressblock_schema, hide=['description']) class AddressBlock(ATCTContent, HistoryAwareMixin): security = ClassSecurityInfo() implements(IAddressBlock, ISimpleLayoutBlock, IGeocodableLocation) schema = addressblock_schema security.declarePrivate('getDefaultCountry') def getDefaultCountry(self): """ Returns the default country defined in registry. """ registry = getUtility(IRegistry) return translate( registry.get('ftw.contentpage.addressblock.defaultcountry',
default=u'Image'), description=_(u'description_image_alt_text', default=u'Enter an alternative text ' u'for the image'))), )) textblock_schema = ATContentTypeSchema.copy() + \ default_schema.copy() + image_schema.copy() textblock_schema['title'].required = False textblock_schema['description'].widget.visible = {'view': 'invisible', 'edit': 'invisible'} textblock_schema['text'].widget.filter_buttons = ('image', ) finalize(textblock_schema) class TextBlock(ATCTContent, HistoryAwareMixin): """Textblock for Contentpage """ security = ClassSecurityInfo() implements(ITextBlock, ISimpleLayoutBlock) schema = textblock_schema #Special workarround for empty titles, otherwise we have "[...]" #results in the search function def setTitle(self, value): portal_transforms = getToolByName(self, 'portal_transforms') field = self.schema['title'] if not value:
)) listing_block_schema = folder.ATFolderSchema.copy() + schema.copy() schemata.finalizeATCTSchema( listing_block_schema, folderish=True, moveDiscussion=False, ) listing_block_schema['title'].required = False listing_block_schema['title'].default_method = 'getDefaultTitle' finalize(listing_block_schema) class ListingBlock(folder.ATFolder): """A listing block for simplelayout""" implements(IListingBlock, ISimpleLayoutBlock,) meta_type = "ListingBlock" schema = listing_block_schema security = ClassSecurityInfo() security.declarePublic('showAddMenu') def showAddMenu(self): return False security.declarePublic('canSetDefaultPage')
htmlblock_schema = ATContentTypeSchema.copy() + \ textblock.default_schema.copy() htmlblock_schema['title'].required = False htmlblock_schema['description'].widget.visible = { 'view': 'invisible', 'edit': 'invisible' } htmlblock_schema['text'].validators = () htmlblock_schema['text'].default_output_type = 'text/html' htmlblock_schema['text'].widget = atapi.TextAreaWidget(label=_( u'label_html', default=u'HTML'), description='', rows=32, cols=70) finalize(htmlblock_schema) class HTMLBlock(textblock.TextBlock): """HTML block for books. """ security = ClassSecurityInfo() implements(IHTMLBlock) schema = htmlblock_schema atapi.registerType(HTMLBlock, PROJECTNAME)
from ftw.book.interfaces import IChapter from ftw.contentpage.content.schema import finalize from simplelayout.base.interfaces import ISimpleLayoutBlock from simplelayout.base.interfaces import ISimpleLayoutCapable from zope.interface import implements try: from Products.LinguaPlone.public import registerType except ImportError: # No multilingual support from Products.Archetypes.atapi import registerType chapter_schema = folder.ATFolder.schema.copy() finalize(chapter_schema, hide=['description']) chapter_schema['excludeFromNav'].default = False class Chapter(folder.ATFolder): implements(IChapter, ISimpleLayoutCapable, ISimpleLayoutBlock) security = ClassSecurityInfo() schema = chapter_schema security.declarePublic('canSetDefaultPage') def canSetDefaultPage(self): return False registerType(Chapter, PROJECTNAME)
)) listing_block_schema = folder.ATFolderSchema.copy() + schema.copy() schemata.finalizeATCTSchema( listing_block_schema, folderish=True, moveDiscussion=False, ) listing_block_schema['title'].required = False listing_block_schema['title'].default_method = 'getDefaultTitle' finalize(listing_block_schema, hide=['description']) class ListingBlock(folder.ATFolder): """A listing block for simplelayout""" implements(IListingBlock, ISimpleLayoutBlock,) meta_type = "ListingBlock" schema = listing_block_schema security = ClassSecurityInfo() security.declarePublic('showAddMenu') def showAddMenu(self): return False security.declarePublic('canSetDefaultPage')
relationship="teasesContent", schemata="teaser", multiValued=False, widget=ReferenceBrowserWidget( force_close_on_insert=True, label=_(u"teaser_internal_reference", default=u"Internal Reference") ), ), ) ) textblock_schema = ATContentTypeSchema.copy() + default_schema.copy() + image_schema.copy() + teaser_schema.copy() textblock_schema["title"].required = False textblock_schema["text"].widget.filter_buttons = ("image",) finalize(textblock_schema, hide=["description"]) # Protect the teaser schema with a specific permission permission = "ftw.contentpage: Add teaser link" for name in teaser_schema.keys(): textblock_schema[name].write_permission = permission class TextBlock(ATCTContent, HistoryAwareMixin): """Textblock for Contentpage """ security = ClassSecurityInfo() implements(ITextBlock, ISimpleLayoutBlock) schema = textblock_schema