本文整理汇总了Python中Products.CMFPlone.interfaces.ISelectableConstrainTypes.setImmediatelyAddableTypes方法的典型用法代码示例。如果您正苦于以下问题:Python ISelectableConstrainTypes.setImmediatelyAddableTypes方法的具体用法?Python ISelectableConstrainTypes.setImmediatelyAddableTypes怎么用?Python ISelectableConstrainTypes.setImmediatelyAddableTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.CMFPlone.interfaces.ISelectableConstrainTypes
的用法示例。
在下文中一共展示了ISelectableConstrainTypes.setImmediatelyAddableTypes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testMoreNotIncludedWhenNotNecessary
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setImmediatelyAddableTypes [as 别名]
def testMoreNotIncludedWhenNotNecessary(self):
constraints = ISelectableConstrainTypes(self.folder)
constraints.setConstrainTypesMode(1)
constraints.setLocallyAllowedTypes(('Document',))
constraints.setImmediatelyAddableTypes(('Document',))
actions = self.menu.getMenuItems(self.folder, self.request)
self.assertEqual(len(actions), 2)
self.assertEqual(actions[0]['extra']['id'], 'document')
self.assertEqual(actions[1]['extra']['id'], 'settings')
示例2: testNonStructualFolderShowsParent
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setImmediatelyAddableTypes [as 别名]
def testNonStructualFolderShowsParent(self):
self.folder.invokeFactory('Folder', 'folder1')
directlyProvides(self.folder.folder1, INonStructuralFolder)
constraints = ISelectableConstrainTypes(self.folder.folder1)
constraints.setConstrainTypesMode(1)
constraints.setLocallyAllowedTypes(('Document',))
constraints.setImmediatelyAddableTypes(('Document',))
actions = self.menu.getMenuItems(self.folder.folder1, self.request)
self.assertEqual(len(actions), 0)
示例3: testMoreIncluded
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setImmediatelyAddableTypes [as 别名]
def testMoreIncluded(self):
constraints = ISelectableConstrainTypes(self.folder)
constraints.setConstrainTypesMode(1)
constraints.setLocallyAllowedTypes(('Document', 'Image',))
constraints.setImmediatelyAddableTypes(('Document',))
actions = self.menu.getMenuItems(self.folder, self.request)
self.failIf('image' in [a['extra']['id'] for a in actions])
self.failUnless('document' in [a['extra']['id'] for a in actions])
self.failUnless('more' in [a['extra']['id'] for a in actions])
self.failUnless('settings' in [a['extra']['id'] for a in actions])
示例4: handleSave
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setImmediatelyAddableTypes [as 别名]
def handleSave(self, action):
data, errors = self.extractData()
if errors:
return
immediately_addable_types = [t for t in data['current_prefer']
if t not in data['current_allow']]
locally_allowed_types = data['current_prefer']
aspect = ISelectableConstrainTypes(self.context)
aspect.setConstrainTypesMode(data['constrain_types_mode'])
aspect.setLocallyAllowedTypes(locally_allowed_types)
aspect.setImmediatelyAddableTypes(immediately_addable_types)
示例5: testAddMenuWithNothingToAddButWithAvailableMorePage
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setImmediatelyAddableTypes [as 别名]
def testAddMenuWithNothingToAddButWithAvailableMorePage(self):
constraints = ISelectableConstrainTypes(self.folder)
constraints.setConstrainTypesMode(1)
constraints.setLocallyAllowedTypes(('Document',))
constraints.setImmediatelyAddableTypes(())
self.folder.manage_permission('Modify constrain types', ('Manager',))
setRoles(self.portal, TEST_USER_ID, ['Contributor'])
items = self.menu.getMenuItems(self.folder, self.request)
factoriesMenuItem = [i for i in items if
i['extra']['id'] == 'plone-contentmenu-factories'][0]
self.assertEqual(len(factoriesMenuItem['submenu']), 1)
self.assertEqual(factoriesMenuItem['submenu'][0]['extra']['id'],
'plone-contentmenu-more')
示例6: __call__
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setImmediatelyAddableTypes [as 别名]
def __call__(self):
if hasattr(self.context.aq_base, CAROUSEL_ID):
carousel = getattr(self.context, CAROUSEL_ID)
else:
pt = getToolByName(self.context, 'portal_types')
newid = pt.constructContent(
type_name='Folder',
container=self.context,
id='carousel',
title='Carousel Banners'
)
carousel = getattr(self.context, newid)
# exclude the (Archetypes or Dexterity) folder from navigation
if hasattr(aq_base(carousel), 'setExcludeFromNav'):
carousel.setExcludeFromNav(True)
elif hasattr(aq_base(carousel), 'exclude_from_nav'):
carousel.exclude_from_nav = True
# mark the new folder as a Carousel folder
alsoProvides(carousel, ICarouselFolder)
# make sure Carousel banners are addable within the new folder
addPermissionsForRole(carousel, 'Manager',
('Carousel: Add Carousel Banner',))
addPermissionsForRole(carousel, 'Site Administrator',
('Carousel: Add Carousel Banner',))
addPermissionsForRole(carousel, 'Owner',
('Carousel: Add Carousel Banner',))
addPermissionsForRole(carousel, 'Contributor',
('Carousel: Add Carousel Banner',))
addPermissionsForRole(carousel, 'Editor',
('Carousel: Add Carousel Banner',))
# make sure *only* Carousel banners are addable
aspect = ISelectableConstrainTypes(carousel)
aspect.setConstrainTypesMode(1)
aspect.setLocallyAllowedTypes(['Carousel Banner'])
aspect.setImmediatelyAddableTypes(['Carousel Banner'])
carousel.reindexObject()
self.request.RESPONSE.redirect(
carousel.absolute_url() + '/@@edit-carousel'
)
示例7: handleSave
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setImmediatelyAddableTypes [as 别名]
def handleSave(self, action):
data, errors = self.extractData()
if errors:
self.status = self.formErrorsMessage
return
allowed_types = data['allowed_types']
immediately_addable = [
t for t in allowed_types
if t not in data['secondary_types']]
aspect = ISelectableConstrainTypes(self.context)
aspect.setConstrainTypesMode(data['constrain_types_mode'])
aspect.setLocallyAllowedTypes(allowed_types)
aspect.setImmediatelyAddableTypes(immediately_addable)
contextURL = self.context.absolute_url()
self.request.response.redirect(contextURL)
示例8: migrate_typerestriction
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setImmediatelyAddableTypes [as 别名]
def migrate_typerestriction(self):
constraints = ISelectableConstrainTypes(self.new)
constraints.setConstrainTypesMode(ENABLED)
constraints.setImmediatelyAddableTypes(self.new_allowed)
constraints.setLocallyAllowedTypes(self.new_allowed)