def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] # TYPE 1 type1_fti = DexterityFTI('type1') type1_fti.klass = 'plone.dexterity.content.Container' type1_fti.filter_content_types = True type1_fti.allowed_content_types = [] type1_fti.behaviors = ('plone.app.dexterity.behaviors.metadata.IBasic') self.portal.portal_types._setObject('type1', type1_fti) self.type1_fti = type1_fti # TYPE 2 type2_fti = DexterityFTI('type1') type2_fti.klass = 'plone.dexterity.content.Item' type2_fti.filter_content_types = True type2_fti.allowed_content_types = [] type2_fti.behaviors = ('plone.app.dexterity.behaviors.metadata.IBasic') self.portal.portal_types._setObject('type2', type2_fti) self.type2_fti = type2_fti login(self.portal, TEST_USER_NAME) setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal.invokeFactory('type1', id='it1', title='Item 1') self.portal.invokeFactory('type2', id='it2', title='Item 2')
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] # TYPE 1 type1_fti = DexterityFTI('type1') type1_fti.klass = 'plone.dexterity.content.Container' type1_fti.filter_content_types = True type1_fti.allowed_content_types = [] type1_fti.behaviors = ( 'plone.app.dexterity.behaviors.metadata.IBasic', ) self.portal.portal_types._setObject('type1', type1_fti) self.type1_fti = type1_fti # TYPE 2 type2_fti = DexterityFTI('type1') type2_fti.klass = 'plone.dexterity.content.Item' type2_fti.filter_content_types = True type2_fti.allowed_content_types = [] type2_fti.behaviors = ( 'plone.app.dexterity.behaviors.metadata.IBasic', ) self.portal.portal_types._setObject('type2', type2_fti) self.type2_fti = type2_fti login(self.portal, TEST_USER_NAME) setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal.invokeFactory('type1', id='it1', title='Item 1') self.portal.invokeFactory('type2', id='it2', title='Item 2')
def setUpContentTypes(self, portal): from plone.dexterity.fti import DexterityFTI from plone.dexterity.fti import register from plone.app.content.interfaces import INameFromTitle from plone.app.dexterity.behaviors.metadata import IOwnership from collective.multilingual.interfaces import IMultilingual bs = ( dottedName(IMultilingual), dottedName(IOwnership), dottedName(INameFromTitle), ) content_types = [ ("Item", "Item", (), bs), ("Container", "Container", ("Item", "Container"), bs), ] # Set up Dexterity-based content types. for portal_type, klass, allowed_content_types, bs in content_types: fti = DexterityFTI(portal_type) fti.allowed_content_types = allowed_content_types fti.behaviors = bs fti.klass = "plone.dexterity.content." + klass register(fti) # There's got to be a better way :-) portal.portal_types._setOb(portal_type, fti)
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] # TYPE 1 type1_fti = DexterityFTI('type1') type1_fti.klass = 'plone.dexterity.content.Container' type1_fti.filter_content_types = True type1_fti.allowed_content_types = ['type1'] type1_fti.behaviors = ( 'Products.CMFPlone.interfaces.constrains.ISelectableConstrainTypes', # noqa 'plone.app.dexterity.behaviors.metadata.IBasic') self.portal.portal_types._setObject('type1', type1_fti) self.type1_fti = type1_fti login(self.portal, TEST_USER_NAME) setRoles(self.portal, TEST_USER_ID, ['Manager'])
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] # TYPE 1 type1_fti = DexterityFTI('type1') type1_fti.klass = 'plone.dexterity.content.Container' type1_fti.filter_content_types = True type1_fti.allowed_content_types = ['type1'] type1_fti.behaviors = ( 'Products.CMFPlone.interfaces.constrains.ISelectableConstrainTypes', # noqa 'plone.app.dexterity.behaviors.metadata.IBasic' ) self.portal.portal_types._setObject('type1', type1_fti) self.type1_fti = type1_fti login(self.portal, TEST_USER_NAME) setRoles(self.portal, TEST_USER_ID, ['Manager'])
def setUp(self): self.portal = self.layer.get('app').plone self.request = self.layer.get('request') #Create a dummy Dexterity container to work with fti = DexterityFTI('Container') self.portal.portal_types._setObject('Container', fti) fti.klass = 'plone.dexterity.content.Container' fti.behaviors = ('collective.behavior.localanalytics.behavior.ILocalAnalytics',) fti.allowed_content_types = ('Folder',) z2.login(self.portal['acl_users'], 'manager') #Default configuration for container id = self.portal.invokeFactory('Container', 'container') self.container = self.portal[id] self.container.analytics_type = \ 'collective.behavior.localanalytics.GoogleAnalyticsUniversal' self.container.analytics_id = 'UA-12345-XX'
def create1_0EventType(portal): """Recreate the old event type used in the 1.0 branch""" fti = DexterityFTI("Event") fti.title = "Event" fti.description = "Events can be shown in calendars." fti.factory = "Event" fti.add_view_expr = "string:${folder_url}/++add++Event" fti.link_target = "" fti.link_target = "" fti.immediate_view = "view" fti.global_allow = True fti.filter_content_types = True fti.allowed_content_types = [] fti.allow_discussion = False fti.default_view = "event_view" fti.view_methods = ("event_view",) fti.default_view_fallback = False fti.add_permission = "plone.app.contenttypes.addEvent" fti.klass = "plone.app.contenttypes.content.Event" fti.behaviors = ( "plone.app.contenttypes.interfaces.IEvent", "plone.app.dexterity.behaviors.metadata.IDublinCore", "plone.app.content.interfaces.INameFromTitle", "plone.app.dexterity.behaviors.discussion.IAllowDiscussion", "plone.app.dexterity.behaviors.exclfromnav.IExcludeFromNavigation", "plone.app.relationfield.behavior.IRelatedItems", "plone.app.versioningbehavior.behaviors.IVersionable", ) fti.schema = None fti.model_source = """ <model xmlns="http://namespaces.plone.org/supermodel/schema" xmlns:indexer="http://namespaces.plone.org/supermodel/indexer" xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:domain="plone"> <schema> <field name="location" type="zope.schema.TextLine" indexer:searchable="true"> <description /> <required>False</required> <title i18n:translate="label_event_location">Event Location</title> </field> <field name="start_date" type="zope.schema.Datetime"> <description /> <title i18n:translate="label_event_start">Event Starts</title> </field> <field name="end_date" type="zope.schema.Datetime"> <description /> <title i18n:translate="label_event_end">Event Ends</title> </field> <field name="text" type="plone.app.textfield.RichText" indexer:searchable="true"> <description /> <required>False</required> <title i18n:translate="">Text</title> </field> <field name="attendees" type="zope.schema.Text" indexer:searchable="true"> <description /> <required>False</required> <title i18n:translate="label_event_attendees">Attendees</title> </field> <field name="event_url" type="zope.schema.TextLine"> <description i18n:translate="help_url"> Web address with more info about the event. Add http:// for external links. </description> <required>False</required> <title i18n:translate="event_more_information">Event URL</title> </field> <field name="contact_name" type="zope.schema.TextLine" indexer:searchable="true"> <description /> <required>False</required> <title i18n:translate="label_contact_name">Contact Name</title> </field> <field name="contact_email" type="zope.schema.TextLine"> <description /> <required>False</required> <title i18n:translate="label_contact_email">Contact E-mail</title> </field> <field name="contact_phone" type="zope.schema.TextLine"> <description /> <required>False</required> <title i18n:translate="label_contact_phone">Contact Phone</title> </field> </schema> </model>""" fti.model_file = None # Was plone.app.contenttypes.schema:event.xml if "Event" in portal.portal_types: del portal.portal_types["Event"] portal.portal_types._setObject("Event", fti) return fti
def create1_0EventType(portal): """Recreate the old event type used in the 1.0 branch""" fti = DexterityFTI('Event') fti.title = 'Event' fti.description = 'Events can be shown in calendars.' fti.factory = 'Event' fti.add_view_expr = 'string:${folder_url}/++add++Event' fti.link_target = '' fti.link_target = '' fti.immediate_view = 'view' fti.global_allow = True fti.filter_content_types = True fti.allowed_content_types = [] fti.allow_discussion = False fti.default_view = 'event_view' fti.view_methods = ('event_view', ) fti.default_view_fallback = False fti.add_permission = 'plone.app.contenttypes.addEvent' fti.klass = 'plone.app.contenttypes.tests.oldtypes.Event' fti.behaviors = ( 'plone.app.contenttypes.interfaces.IEvent', 'plone.app.dexterity.behaviors.metadata.IDublinCore', 'plone.app.content.interfaces.INameFromTitle', 'plone.app.dexterity.behaviors.discussion.IAllowDiscussion', 'plone.app.dexterity.behaviors.exclfromnav.IExcludeFromNavigation', 'plone.app.relationfield.behavior.IRelatedItems', 'plone.app.versioningbehavior.behaviors.IVersionable', ) fti.schema = None fti.model_source = """ <model xmlns="http://namespaces.plone.org/supermodel/schema" xmlns:indexer="http://namespaces.plone.org/supermodel/indexer" xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:domain="plone"> <schema> <field name="location" type="zope.schema.TextLine" indexer:searchable="true"> <description /> <required>False</required> <title i18n:translate="label_event_location">Event Location</title> </field> <field name="start_date" type="zope.schema.Datetime"> <description /> <title i18n:translate="label_event_start">Event Starts</title> </field> <field name="end_date" type="zope.schema.Datetime"> <description /> <title i18n:translate="label_event_end">Event Ends</title> </field> <field name="text" type="plone.app.textfield.RichText" indexer:searchable="true"> <description /> <required>False</required> <title i18n:translate="">Text</title> </field> <field name="attendees" type="zope.schema.Text" indexer:searchable="true"> <description /> <required>False</required> <title i18n:translate="label_event_attendees">Attendees</title> </field> <field name="event_url" type="zope.schema.TextLine"> <description i18n:translate="help_url"> Web address with more info about the event. Add http:// for external links. </description> <required>False</required> <title i18n:translate="event_more_information">Event URL</title> </field> <field name="contact_name" type="zope.schema.TextLine" indexer:searchable="true"> <description /> <required>False</required> <title i18n:translate="label_contact_name">Contact Name</title> </field> <field name="contact_email" type="zope.schema.TextLine"> <description /> <required>False</required> <title i18n:translate="label_contact_email">Contact E-mail</title> </field> <field name="contact_phone" type="zope.schema.TextLine"> <description /> <required>False</required> <title i18n:translate="label_contact_phone">Contact Phone</title> </field> </schema> </model>""" fti.model_file = None # Was plone.app.contenttypes.schema:event.xml if 'Event' in portal.portal_types: del portal.portal_types['Event'] portal.portal_types._setObject('Event', fti) return fti