Commit d1210945 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_panel: Only Accountant and Sales team can change Regularisation Request state

    Only [Accounting|Sale] Manager can validate the ticket (interrupting the process)
    [Accounting|Sale] [Agent|Manager] can suspend the ticket (continuing the process)
parent 483ec1bf
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>python: context.getSimulationState() == \'suspended\'</string> </value> <value> <string>python: context.Base_hasSlapOSAccountingUserGroup(manager=True) and context.getSimulationState() == \'suspended\'</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>python: context.getSimulationState() == \'validated\'</string> </value> <value> <string>python: context.Base_hasSlapOSAccountingUserGroup(manager=True, agent=True) and context.getSimulationState() == \'validated\'</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
portal = context.getPortalObject()
member = portal.portal_membership.getAuthenticatedMember()
getGroups = getattr(member, 'getGroups', None)
if getGroups is None:
return False
user_group_list = getGroups()
return (
((manager and agent) and ('F-ACCOUNTING*' in user_group_list)) or
((manager and agent) and ('F-SALE*' in user_group_list)) or
((manager) and ('F-SALEMAN' in user_group_list)) or
((manager) and ('F-ACCMAN' in user_group_list)) or
((agent) and ('F-ACCAGT' in user_group_list)) or
((agent) and ('F-SALEAGT' in user_group_list))
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>manager=False, agent=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_hasSlapOSAccountingUserGroup</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -244,3 +244,89 @@ class TestPerson_getCertificate(TestPanelSkinsMixin): ...@@ -244,3 +244,89 @@ class TestPerson_getCertificate(TestPanelSkinsMixin):
self.assertNotEqual(new_response_dict["certificate"], response_dict["certificate"]) self.assertNotEqual(new_response_dict["certificate"], response_dict["certificate"])
self.assertEqual(self.portal.REQUEST.RESPONSE.getStatus(), 200) self.assertEqual(self.portal.REQUEST.RESPONSE.getStatus(), 200)
class TestBase_hasSlapOSAccountingUserGroup(TestPanelSkinsMixin):
def _makePersonAndRegularisationRequest(self):
person = self.makePerson(self.project, user=1)
regularisation_request = self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
title='TESTREGREQ-%s' % self.generateNewId(),
destination_decision_value=person
)
regularisation_request.submit()
return person, regularisation_request
def test_Base_hasSlapOSAccountingUserGroup_no_user(self):
self.logout()
self.assertFalse(self.project.Base_hasSlapOSAccountingUserGroup())
self.login()
self.assertFalse(self.project.Base_hasSlapOSAccountingUserGroup())
def test_Base_hasSlapOSAccountingUserGroup_no_access(self):
person, regularisation_request = self._makePersonAndRegularisationRequest()
self.addProjectProductionManagerAssignment(person, self.project)
self.tic()
self.login(person.getUserId())
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup())
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup(
agent=True))
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup(
manager=True))
def test_Base_hasSlapOSAccountingUserGroup_sale_manager(self):
person, regularisation_request = self._makePersonAndRegularisationRequest()
self.addSaleManagerAssignment(person)
self.tic()
self.login(person.getUserId())
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup())
self.assertTrue(regularisation_request.Base_hasSlapOSAccountingUserGroup(
manager=True))
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup(
agent=True))
self.assertTrue(regularisation_request.Base_hasSlapOSAccountingUserGroup(
manager=True, agent=True))
def test_Base_hasSlapOSAccountingUserGroup_sale_agent(self):
person, regularisation_request = self._makePersonAndRegularisationRequest()
self.addSaleAgentAssignment(person)
self.tic()
self.login(person.getUserId())
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup())
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup(
manager=True))
self.assertTrue(regularisation_request.Base_hasSlapOSAccountingUserGroup(
agent=True))
self.assertTrue(regularisation_request.Base_hasSlapOSAccountingUserGroup(
manager=True, agent=True))
def test_Base_hasSlapOSAccountingUserGroup_accounting_manager(self):
person, regularisation_request = self._makePersonAndRegularisationRequest()
self.addAccountingManagerAssignment(person)
self.tic()
self.login(person.getUserId())
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup())
self.assertTrue(regularisation_request.Base_hasSlapOSAccountingUserGroup(
manager=True))
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup(
agent=True))
self.assertTrue(regularisation_request.Base_hasSlapOSAccountingUserGroup(
manager=True, agent=True))
def test_Base_hasSlapOSAccountingUserGroup_accounting_agent(self):
person, regularisation_request = self._makePersonAndRegularisationRequest()
self.addAccountingAgentAssignment(person)
self.tic()
self.login(person.getUserId())
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup())
self.assertFalse(regularisation_request.Base_hasSlapOSAccountingUserGroup(
manager=True))
self.assertTrue(regularisation_request.Base_hasSlapOSAccountingUserGroup(
agent=True))
self.assertTrue(regularisation_request.Base_hasSlapOSAccountingUserGroup(
manager=True, agent=True))
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