Commit 5db98d33 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Add a permission property so that it is easier to control which kind of portal...

Add a permission property so that it is easier to control which kind of portal types can be created in which context.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12064 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7627bbe0
...@@ -35,6 +35,7 @@ from Products.CMFCore.ActionProviderBase import ActionProviderBase ...@@ -35,6 +35,7 @@ from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.utils import SimpleItemWithProperties from Products.CMFCore.utils import SimpleItemWithProperties
from Products.CMFCore.Expression import createExprContext from Products.CMFCore.Expression import createExprContext
from Products.CMFCore.exceptions import AccessControl_Unauthorized from Products.CMFCore.exceptions import AccessControl_Unauthorized
from Products.CMFCore.utils import _checkPermission
from Products.ERP5Type import PropertySheet from Products.ERP5Type import PropertySheet
from Products.ERP5Type import _dtmldir from Products.ERP5Type import _dtmldir
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
...@@ -91,6 +92,8 @@ class ERP5TypeInformation( FactoryTypeInformation, ...@@ -91,6 +92,8 @@ class ERP5TypeInformation( FactoryTypeInformation,
_properties = (TypeInformation._basic_properties + ( _properties = (TypeInformation._basic_properties + (
{'id':'factory', 'type': 'string', 'mode':'w', {'id':'factory', 'type': 'string', 'mode':'w',
'label':'Product factory method'}, 'label':'Product factory method'},
{'id':'permission', 'type': 'string', 'mode':'w',
'label':'Add permission'},
{'id':'init_script', 'type': 'string', 'mode':'w', {'id':'init_script', 'type': 'string', 'mode':'w',
'label':'Init Script'}, 'label':'Init Script'},
{'id':'acquire_local_roles' {'id':'acquire_local_roles'
...@@ -141,6 +144,7 @@ class ERP5TypeInformation( FactoryTypeInformation, ...@@ -141,6 +144,7 @@ class ERP5TypeInformation( FactoryTypeInformation,
hidden_content_type_list = () hidden_content_type_list = ()
filter_actions = 0 filter_actions = 0
allowed_action_list = [] allowed_action_list = []
permission = ''
# Groups are used to classify portal types (e.g. resource). # Groups are used to classify portal types (e.g. resource).
defined_group_list = ( defined_group_list = (
...@@ -170,6 +174,17 @@ class ERP5TypeInformation( FactoryTypeInformation, ...@@ -170,6 +174,17 @@ class ERP5TypeInformation( FactoryTypeInformation,
# #
# Agent methods # Agent methods
# #
security.declarePublic('isConstructionAllowed')
def isConstructionAllowed( self, container ):
"""
Does the current user have the permission required in
order to construct an instance?
"""
permission = self.permission
if permission and not _checkPermission( permission, container ):
return 0
return FactoryTypeInformation.isConstructionAllowed(self, container)
def _getFactoryMethod(self, container, check_security=1): def _getFactoryMethod(self, container, check_security=1):
if not self.product or not self.factory: if not self.product or not self.factory:
raise ValueError, ('Product factory for %s was undefined' % raise ValueError, ('Product factory for %s was undefined' %
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment