Commit 6247015c authored by Gabriel Monnerat's avatar Gabriel Monnerat

Refactor script and add new step to check if a normal user can use all UNG features correctly

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45144 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 077ac1e1
...@@ -58,7 +58,7 @@ portal_preferences = portal.portal_preferences\n ...@@ -58,7 +58,7 @@ portal_preferences = portal.portal_preferences\n
business_template = context.getSpecialiseValue()\n business_template = context.getSpecialiseValue()\n
isTransitionPossible = portal.portal_workflow.isTransitionPossible\n isTransitionPossible = portal.portal_workflow.isTransitionPossible\n
\n \n
# enable erp5 preference\n # enable ung preference\n
ung_preference = getattr(portal.portal_preferences, \'ung_preference\', None)\n ung_preference = getattr(portal.portal_preferences, \'ung_preference\', None)\n
if ung_preference is not None and isTransitionPossible(ung_preference, \'enable\'):\n if ung_preference is not None and isTransitionPossible(ung_preference, \'enable\'):\n
ung_preference.enable()\n ung_preference.enable()\n
...@@ -75,21 +75,17 @@ for web_section in ung_web_site.contentValues(portal_types=\'Web Section\'):\n ...@@ -75,21 +75,17 @@ for web_section in ung_web_site.contentValues(portal_types=\'Web Section\'):\n
if isTransitionPossible(web_section, \'publish\', None):\n if isTransitionPossible(web_section, \'publish\', None):\n
web_section.publish()\n web_section.publish()\n
\n \n
if business_template is not None:\n bt5 = portal.portal_catalog.getResultValue(portal_type="Business Template",\n
# update role settings for modules which exists already\n title="erp5_web_ung_role")\n
for portal_type in business_template.getTemplatePortalTypeRolesList():\n \n
module_list = portal.contentValues(\n if bt5 is not None:\n
filter=dict(portal_type=portal_type))\n for portal_type in bt5.getTemplatePortalTypeRolesList():\n
module_list = portal.contentValues(filter=dict(portal_type=portal_type))\n
for module in module_list:\n for module in module_list:\n
module.updateLocalRolesOnSecurityGroups()\n module.updateLocalRolesOnSecurityGroups()\n
context.log("Updated Role Mappings for: %s(%s) " % (module.getTitle(), module.getPortalType()))\n context.log("Updated Role Mappings for: %s(%s) " % (module.getTitle(), module.getPortalType()))\n
\n \n
for preference_to_enable in business_template.getTemplatePreferenceList():\n if business_template is not None:\n
preference = getattr(portal_preferences, preference_to_enable, None)\n
if preference is not None:\n
if isTransitionPossible(preference, \'enable\'):\n
preference.enable()\n
\n
# update path items. FIXME: local roles should be exported by business template instead\n # update path items. FIXME: local roles should be exported by business template instead\n
for path in business_template.getTemplatePathList():\n for path in business_template.getTemplatePathList():\n
obj = portal.restrictedTraverse(path, None)\n obj = portal.restrictedTraverse(path, None)\n
...@@ -115,36 +111,15 @@ if business_template is not None:\n ...@@ -115,36 +111,15 @@ if business_template is not None:\n
assignment.updateLocalRolesOnSecurityGroups()\n assignment.updateLocalRolesOnSecurityGroups()\n
context.log("\\tOpen (assignment): ", assignment.getRelativeUrl())\n context.log("\\tOpen (assignment): ", assignment.getRelativeUrl())\n
\n \n
for gadget in context.portal_gadgets.objectValues():\n for gadget in context.portal_gadgets.objectValues():\n
if gadget.getValidationState() == \'invisible\':\n if gadget.getValidationState() == \'invisible\':\n
gadget.visible()\n gadget.visible()\n
gadget.public()\n gadget.public()\n
\n \n
# update security settings for default preference # XXX why ???\n # XXX - check if is possible add this configuration in bt5\n
default_configurator_preference = getattr(portal_preferences,\n portal.knowledge_pad_module.manage_permission(\'Add portal content\',\n
\'default_configurator_preference\', None)\n roles=[\'Assignor\', "Manager", "Authenticated", "Author"],\n
if default_configurator_preference is not None:\n acquire=0)\n
default_configurator_preference.updateLocalRolesOnSecurityGroups()\n
\n
# set manually in \'Module Properties\' respective business_application category\n
# XXX This should be part of Configuration Item probably, but as access_tab is\n
# going to be deprecated, make sure it still requires set business application\n
# info modules.\n
module_business_application_map = {\'base\': (\'organisation_module\',\n
\'person_module\',),\n
\'crm\': (\'event_module\',),\n
\'dms\': (\'document_module\',\n
\'image_module\',\n
\'document_ingestion_module\',\n
\'web_page_module\',),\n
}\n
\n
for business_application_category_id, module_ids in module_business_application_map.items():\n
for module_id in module_ids:\n
module = getattr(portal, module_id, None)\n
if module is not None:\n
module.edit(business_application = business_application_category_id)\n
\n
context.log("Indexing translations")\n context.log("Indexing translations")\n
portal.ERP5Site_updateTranslationTable()\n portal.ERP5Site_updateTranslationTable()\n
\n \n
......
...@@ -97,7 +97,7 @@ class TestUNGConfiguratorWorkflowMixin(ERP5TypeTestCase): ...@@ -97,7 +97,7 @@ class TestUNGConfiguratorWorkflowMixin(ERP5TypeTestCase):
stepCheckUNGWebSiteAfterInstallation stepCheckUNGWebSiteAfterInstallation
stepCheckSystemPreferenceAfterInstallation stepCheckSystemPreferenceAfterInstallation
stepCheckUserPreferenceAfterInstallation stepCheckUserPreferenceAfterInstallation
stepTic stepCheckWebSiteRoles
""" """
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
...@@ -311,7 +311,7 @@ class TestUNGConfiguratorWorkflowMixin(ERP5TypeTestCase): ...@@ -311,7 +311,7 @@ class TestUNGConfiguratorWorkflowMixin(ERP5TypeTestCase):
""" Check System Preference""" """ Check System Preference"""
portal_catalog = self.portal.portal_catalog portal_catalog = self.portal.portal_catalog
preference = portal_catalog.getResultValue(portal_type="Preference", preference = portal_catalog.getResultValue(portal_type="Preference",
reference='Preference for Person Assignor') title='Preference for Person Assignor')
self.assertEquals(preference.getPreferenceState(), "enabled") self.assertEquals(preference.getPreferenceState(), "enabled")
preference = portal_catalog.getResultValue(portal_type="Preference", preference = portal_catalog.getResultValue(portal_type="Preference",
title='Preference for Person Assignee') title='Preference for Person Assignee')
...@@ -319,9 +319,36 @@ class TestUNGConfiguratorWorkflowMixin(ERP5TypeTestCase): ...@@ -319,9 +319,36 @@ class TestUNGConfiguratorWorkflowMixin(ERP5TypeTestCase):
preference = portal_catalog.getResultValue(portal_type="Preference", preference = portal_catalog.getResultValue(portal_type="Preference",
title='Preference for Person Creator') title='Preference for Person Creator')
self.assertEquals(preference.getPreferenceState(), "enabled") self.assertEquals(preference.getPreferenceState(), "enabled")
preference = portal_catalog.getResultValue(portal_type="Preference", ung_preference = self.portal.portal_preferences.ung_preference
id='ung_reference') self.assertEquals(ung_preference.getPreferenceState(), "global")
self.assertEquals(preference.getPreferenceState(), "enabled")
def _stepCheckWebSiteRoles(self):
""" Check permission of Web Site with normal user """
self.portal.web_page_module.ERP5Site_createNewWebDocument("web_page_template")
self.stepTic()
result_list = self.portal.web_site_module.ungWebSection_getWebPageObjectList()
self.assertEquals(len(result_list), 1)
self.assertEquals(result_list[0].getTitle(), "Web Page")
new_object = self.portal.web_page_module.newContent(portal_type="Web Page")
new_object.edit(title="New")
new_object = self.portal.web_page_module.newContent(portal_type="Web Table")
new_object.edit(title="New")
new_object = self.portal.web_page_module.newContent(portal_type="Web Illustration")
new_object.edit(title="New")
self.stepTic()
kw = {"portal_type": "Web Page", "title": "New"}
result_list = self.portal.web_site_module.ung.WebSection_getWebPageObjectList(**kw)
self.assertEquals(len(result_list), 1)
self.assertEquals(result_list[0].getPortalType(), "Web Page")
kw["portal_type"] = "Web Illustration"
result_list = self.portal.web_site_module.ung.WebSection_getWebPageObjectList(**kw)
self.assertEquals(len(result_list), 1)
self.assertEquals(result_list[0].getPortalType(), "Web Illustration")
kw["portal_type"] = "Web Table"
result_list = self.portal.web_site_module.ung.WebSection_getWebPageObjectList(**kw)
self.assertEquals(len(result_list), 1)
self.assertEquals(result_list[0].getPortalType(), "Web Table")
class TestUNGConfiguratorWorkflowFranceLanguage(TestUNGConfiguratorWorkflowMixin): class TestUNGConfiguratorWorkflowFranceLanguage(TestUNGConfiguratorWorkflowMixin):
""" """
...@@ -404,6 +431,11 @@ class TestUNGConfiguratorWorkflowFranceLanguage(TestUNGConfiguratorWorkflowMixin ...@@ -404,6 +431,11 @@ class TestUNGConfiguratorWorkflowFranceLanguage(TestUNGConfiguratorWorkflowMixin
self.assertEquals(assignment.getValidationState(), "open") self.assertEquals(assignment.getValidationState(), "open")
self.assertEquals(assignment.getFunction(), "function/ung_user") self.assertEquals(assignment.getFunction(), "function/ung_user")
def stepCheckWebSiteRoles(self, sequence=None, sequence_list=None, **kw):
""" Check permission of Web Site with normal user """
self.login("french_assignor")
self._stepCheckWebSiteRoles()
class TestUNGConfiguratorWorkflowBrazilLanguage(TestUNGConfiguratorWorkflowMixin): class TestUNGConfiguratorWorkflowBrazilLanguage(TestUNGConfiguratorWorkflowMixin):
""" """
...@@ -485,3 +517,9 @@ class TestUNGConfiguratorWorkflowBrazilLanguage(TestUNGConfiguratorWorkflowMixin ...@@ -485,3 +517,9 @@ class TestUNGConfiguratorWorkflowBrazilLanguage(TestUNGConfiguratorWorkflowMixin
assignment = person.contentValues(portal_type="Assignment")[0] assignment = person.contentValues(portal_type="Assignment")[0]
self.assertEquals(assignment.getValidationState(), "open") self.assertEquals(assignment.getValidationState(), "open")
self.assertEquals(assignment.getFunction(), "function/ung_user") self.assertEquals(assignment.getFunction(), "function/ung_user")
def stepCheckWebSiteRoles(self, sequence=None, sequence_list=None, **kw):
""" Check permission of Web Site with normal user """
self.login("person_assignor")
self._stepCheckWebSiteRoles(self)
36 37
\ No newline at end of file \ No newline at end of file
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