Commit 5806f6ed authored by wenjie.zheng's avatar wenjie.zheng

BusinessTemplate: catch and display error on missing action reference for portal types properties

parent 6a8987fb
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>new_thread</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>Add portal content</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>New Thread</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/DiscussionModuleThread_viewAddThreadDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_list</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_list</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/DiscussionThreadModule_viewDiscussionThreadList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -117,6 +117,9 @@ catalog_method_filter_list = ('_filter_expression_archive',
INSTALLED_BT_FOR_DIFF = 'installed_bt_for_diff'
_MARKER = []
def _getCatalog(acquisition_context):
"""
Return the id of the SQLCatalog which correspond to the current BT.
......@@ -5817,6 +5820,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
bt_portal_types_id_list = list(self.getTemplatePortalTypeIdList())
bt_portal_type_roles_list = list(self.getTemplatePortalTypeRoleList())
bt_wf_chain_list = list(self.getTemplatePortalTypeWorkflowChainList())
Base_translateString = self.Base_translateString
for id in bt_portal_types_id_list:
portal_type = ttool.getTypeInfo(id)
......@@ -5863,6 +5867,8 @@ Business Template is a set of definitions, such as skins, portal types and categ
bt_base_category_list.append(base_cat_id)
for act_id in action_list:
if act_id is None:
return (1, Base_translateString("ERROR: An action has an empty id on portal_type ${id}",mapping=dict(id=id)))
action_id = id+' | '+act_id
if action_id not in bt_action_list:
bt_action_list.append(action_id)
......@@ -5887,6 +5893,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
self.setTemplatePortalTypePropertySheetList(bt_property_sheet_list)
self.setTemplatePortalTypeBaseCategoryList(bt_base_category_list)
self.setTemplateActionPathList(bt_action_list)
return (0, "")
def guessPortalTypes(self, **kw):
......
......@@ -50,13 +50,22 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>context.getPortalTypesProperties()\n
\n
<value> <string>Base_translateString = context.Base_translateString\n
REQUEST = context.REQUEST\n
\n
\n
result, message0 = context.getPortalTypesProperties()\n
\n
message1 = Base_translateString("Portal Type Properties Have Been Updated.")\n
\n
ret_url = context.absolute_url() + \'/\' + REQUEST.get(\'form_id\', \'view\')\n
\n
if REQUEST is not None:\n
ret_url = context.absolute_url() + \'/\' + REQUEST.get(\'form_id\', \'view\')\n
REQUEST.RESPONSE.redirect("%s?portal_status_message=Portal+Types+Properties+Updated"% ret_url)\n
if result:\n
REQUEST.RESPONSE.redirect("%s?portal_status_message= %s" % (ret_url,message0))\n
else:\n
REQUEST.RESPONSE.redirect("%s?portal_status_message=%s"% (ret_url,message1))\n
</string> </value>
</item>
<item>
......
......@@ -1494,6 +1494,15 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
float_index=2.0)
sequence.edit(first_action_id='become_geek')
def stepTestFirstAction(self, sequence=None,**kw):
pt = self.getTypeTool()
object_id = sequence.get('object_ptype_id')
object_pt = pt._getOb(object_id)
bt = sequence.get('current_bt', None)
self.assertTrue(bt is not None)
result, message = bt.getPortalTypesProperties()
self.assertEquals(result,0)
def stepCreateEmptyAction(self, sequence=None, **kw):
"""
Create an empty action
......@@ -1506,6 +1515,15 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
action_permission_list=(),
float_index=1.2)
def stepTestEmptyAction(self, sequence=None,**kw):
pt = self.getTypeTool()
object_id = sequence.get('object_ptype_id')
object_pt = pt._getOb(object_id)
bt = sequence.get('current_bt', None)
self.assertTrue(bt is not None)
result, message = bt.getPortalTypesProperties()
self.assertEquals(result,1)
def stepCreateSecondAction(self, sequence=None, **kw):
"""
Create a second action
......@@ -3938,9 +3956,11 @@ class TestBusinessTemplate(BusinessTemplateMixin):
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
TestFirstAction\
RemoveBusinessTemplate \
RemoveAllTrashBins \
CreateEmptyAction \
TestEmptyAction\
ImportBusinessTemplate \
UseImportBusinessTemplate \
CheckBuiltBuildingState \
......
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