Commit a0dfb228 authored by Jérome Perrin's avatar Jérome Perrin

Merge remote-tracking branch 'upstream/master' into zope4py2

parents f1216db4 164e4631
Pipeline #24625 failed with stage
in 0 seconds
......@@ -2,4 +2,4 @@
because only validated accounts are displayed in the cache.
"""
if sci['object'].getValidationState() == 'validated':
container.Account_flushAccountListCache(sci)
container.script_Account_flushAccountListCache(sci)
......@@ -13,7 +13,7 @@ section_portal_type_list = ['Person', 'Organisation']
invalid_state_list = ['invalidated', 'deleted']
# first of all, validate the transaction itself
container.validateTransaction(state_change)
container.script_validateTransaction(state_change)
# Check that all lines uses open accounts, and doesn't use invalid third
......
return sci.getPortal().portal_workflow.accounting_workflow.scripts[script.getId()](sci)
return sci.getPortal().portal_workflow.accounting_workflow[script.getId()](sci)
state_change['object'].AccountingTransaction_setDefaultMirrorAccountList()
return container.setReferences(state_change)
return container.script_setReferences(state_change)
return sci.getPortal().portal_workflow.accounting_workflow.scripts[script.getId()](sci)
return sci.getPortal().portal_workflow.accounting_workflow[script.getId()](sci)
return state_change.getPortal().portal_workflow.accounting_workflow.scripts[script.getId()](state_change)
return state_change.getPortal().portal_workflow.accounting_workflow[script.getId()](state_change)
return state_change.getPortal().portal_workflow.accounting_workflow.scripts[script.getId()](state_change)
return state_change.getPortal().portal_workflow.accounting_workflow[script.getId()](state_change)
......@@ -7,4 +7,4 @@ if old_state.getId() == 'draft':
if internal_invoice.InternalInvoiceTransaction_getAuthenticatedUserSection() == internal_invoice.getDestinationSection():
raise ValidationFailed(translateString("Your entity should not be destination."))
return state_change.getPortal().portal_workflow.accounting_workflow.scripts[script.getId()](state_change)
return state_change.getPortal().portal_workflow.accounting_workflow[script.getId()](state_change)
......@@ -29,7 +29,7 @@
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.ERP5Type.Base import WorkflowMethod
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
......@@ -64,7 +64,7 @@ class ApparelMeasurement(XMLObject, XMLMatrix, Image):
# Inheritance
_edit = Image._edit
security.declareProtected(Permissions.ModifyPortalContent, 'edit' )
edit = WorkflowAction( _edit )
edit = WorkflowMethod( _edit )
security.declareProtected(Permissions.View, 'index_html')
index_html = Image.index_html
......
......@@ -24,4 +24,4 @@ for simulation_movement in simulation_movement_list:
if simulation_movement.getOrder() == delivery_movement.getRelativeUrl():
simulation_movement.setOrder(None)
context.DeliveryMovement_updateSimulation(state_change)
container.script_DeliveryMovement_updateSimulation(state_change)
......@@ -31,7 +31,7 @@ import os
import random
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type.Core.Workflow import ValidationFailed
from AccessControl import Unauthorized
class TestCertificateAuthority(ERP5TypeTestCase):
......
......@@ -966,19 +966,23 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
# Add a non-existent workflow.
pw = self.getWorkflowTool()
dummy_simulation_worlflow_id = 'fake_simulation_workflow'
dummy_validation_worlflow_id = 'fake_validation_workflow'
dummy_simulation_workflow_id = 'fake_simulation_workflow'
dummy_validation_workflow_id = 'fake_validation_workflow'
#Assume that erp5_styles workflow Manage permissions with acquired Role by default
addWorkflowByType(pw, 'erp5_workflow', dummy_simulation_worlflow_id)
addWorkflowByType(pw, 'erp5_workflow', dummy_validation_worlflow_id)
dummy_simulation_worlflow = pw[dummy_simulation_worlflow_id]
dummy_validation_worlflow = pw[dummy_validation_worlflow_id]
dummy_validation_worlflow.variables.setStateVar('validation_state')
dummy_simulation_workflow = pw.newContent(
portal_type='Workflow',
reference=dummy_simulation_workflow_id,
)
dummy_validation_workflow = pw.newContent(
portal_type='Workflow',
reference=dummy_validation_workflow_id,
state_variable='validation_state',
)
organisation_type = portal.portal_types.getTypeInfo(portal_type)
organisation_initial_workflow_list = organisation_type.getTypeWorkflowList()
organisation_type.setTypeWorkflowList([dummy_validation_worlflow_id,
dummy_simulation_worlflow_id])
permission_list = list(dummy_simulation_worlflow.permissions)
organisation_type.setTypeWorkflowList([dummy_validation_workflow_id,
dummy_simulation_workflow_id])
permission_list = dummy_simulation_workflow.getWorkflowManagedPermissionList()
manager_has_permission = {}
for permission in permission_list:
manager_has_permission[permission] = ('Manager',)
......@@ -989,7 +993,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
user = getSecurityManager().getUser()
try:
self.assertTrue(permission_list)
self.assertFalse(dummy_simulation_worlflow.states.draft.permission_roles)
self.assertFalse(dummy_simulation_workflow['state_draft'].getStatePermissionRoleListDict())
#1
obj = module.newContent(portal_type=portal_type)
#No role is defined by default on workflow
......@@ -999,28 +1003,28 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
for permission in permission_list:
self.assertTrue(user.has_permission(permission, obj))
#2 Now configure both workflow with same configuration
dummy_simulation_worlflow.states.draft.permission_roles = manager_has_permission.copy()
dummy_validation_worlflow.states.draft.permission_roles = manager_has_permission.copy()
dummy_simulation_worlflow.updateRoleMappingsFor(obj)
dummy_validation_worlflow.updateRoleMappingsFor(obj)
dummy_simulation_workflow['state_draft'].setStatePermissionRoleListDict(manager_has_permission.copy())
dummy_validation_workflow['state_draft'].setStatePermissionRoleListDict(manager_has_permission.copy())
dummy_simulation_workflow.updateRoleMappingsFor(obj)
dummy_validation_workflow.updateRoleMappingsFor(obj)
for permission in permission_list:
self.assertTrue(user.has_permission(permission, obj))
#3 change only dummy_simulation_worlflow
dummy_simulation_worlflow.states.draft.permission_roles = manager_has_no_permission.copy()
dummy_simulation_worlflow.updateRoleMappingsFor(obj)
#3 change only dummy_simulation_workflow
dummy_simulation_workflow['state_draft'].setStatePermissionRoleListDict(manager_has_no_permission.copy())
dummy_simulation_workflow.updateRoleMappingsFor(obj)
for permission in permission_list:
self.assertFalse(user.has_permission(permission, obj))
#4 enable acquisition for dummy_simulation_worlflow
dummy_simulation_worlflow.states.draft.permission_roles = None
dummy_simulation_worlflow.updateRoleMappingsFor(obj)
#4 enable acquisition for dummy_simulation_workflow
dummy_simulation_workflow['state_draft'].setAcquirePermissionList(permission_list)
dummy_simulation_workflow.updateRoleMappingsFor(obj)
for permission in permission_list:
self.assertTrue(user.has_permission(permission, obj))
finally:
# Make sure that the artificial workflow is not referred to any longer.
organisation_type.setTypeWorkflowList(organisation_initial_workflow_list)
pw.manage_delObjects([dummy_simulation_worlflow_id, dummy_validation_worlflow_id])
pw.manage_delObjects([dummy_simulation_workflow_id, dummy_validation_workflow_id])
def test_getViewPermissionOwnerDefault(self):
"""Test getViewPermissionOwner method behaviour"""
......
......@@ -39,7 +39,6 @@ from urllib import pathname2url
from Products.ERP5Type.Globals import PersistentMapping
from Products.ERP5Type.dynamic.lazy_class import ERP5BaseBroken
from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.Workflow import addWorkflowByType
import shutil
import os
import random
......@@ -1315,8 +1314,11 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
"""
wf_id = 'geek_workflow'
pw = self.getWorkflowTool()
addWorkflowByType(pw, WORKFLOW_TYPE, wf_id)
workflow = pw._getOb(wf_id, None)
workflow = pw.newContent(
portal_type='Workflow',
reference=wf_id,
)
self.tic()
self.assertTrue(workflow is not None)
sequence.edit(workflow_id=workflow.getId())
......@@ -2886,8 +2888,11 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
"""
wf_id = 'custom_geek_workflow'
pw = self.getWorkflowTool()
addWorkflowByType(pw, WORKFLOW_TYPE, wf_id)
workflow = pw._getOb(wf_id, None)
workflow = pw.newContent(
portal_type='Workflow',
reference=wf_id,
)
self.tic()
self.assertTrue(workflow is not None)
sequence.edit(workflow_id=workflow.getId())
......
from Products.ERP5Type.Core.Workflow import ValidationFailed
from Products.ERP5Type.Message import translateString
container.Event_checkConsistency(sci)
container.script_Event_checkConsistency(sci)
portal = sci.getPortal()
portal_workflow = portal.portal_workflow
......
......@@ -10,9 +10,9 @@ portal = context.getPortalObject()
query_dict = {}
workflow = portal.portal_workflow.ticket_workflow
workflow_state_var = workflow.variables.getStateVar()
workflow_state_var = workflow.getStateVariable()
for worklist in workflow.worklists.objectValues():
for worklist in workflow.getWorklistValueList():
identity_criterion_dict = worklist.getIdentityCriterionDict()
if portal_type \
and 'portal_type' in worklist.getCriterionPropertyList() \
......
......@@ -15,4 +15,4 @@ if test_result.getPortalType() == 'Test Result Node':
edit_kw[key] = key_value
test_result.edit(**edit_kw)
else:
context.TestResult_complete(sci)
container.script_TestResult_complete(sci)
......@@ -3,14 +3,14 @@ portal = context.getPortalObject()
portal_type = ticket.getPortalType()
if portal_type in ("Leave Request", "Leave Request Period"):
context.Alarm_safeTrigger(
container.script_Alarm_safeTrigger(
portal.portal_alarms.create_representative_record_for_leave_request
)
elif portal_type in ("Expense Validation Request"):
context.Alarm_safeTrigger(
container.script_Alarm_safeTrigger(
portal.portal_alarms.create_representative_record_for_expense_validation_request
)
elif portal_type in ("Travel Request"):
context.Alarm_safeTrigger(
container.script_Alarm_safeTrigger(
portal.portal_alarms.create_representative_record_for_travel_request
)
......@@ -3534,7 +3534,11 @@ class Base(
# Use meta transition to jump from one state to another
# without existing transitions.
from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition
from Products.ERP5Type import WITH_LEGACY_WORKFLOW
if WITH_LEGACY_WORKFLOW:
from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition
else:
InteractionWorkflowDefinition = None.__class__
from Products.ERP5Type.Core.InteractionWorkflow import InteractionWorkflow
portal = self.getPortalObject()
workflow_tool = portal.portal_workflow
......
......@@ -98,7 +98,10 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
This is public method to allow passing meta transition (Jump form
any state to another in same workflow)
"""
from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition
if WITH_LEGACY_WORKFLOW:
from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition
else:
InteractionWorkflowDefinition = None.__class__
from Products.ERP5Type.Core.InteractionWorkflow import InteractionWorkflow
workflow_list = self.getWorkflowValueListFor(ob.getPortalType())
if wf_id is None:
......@@ -124,7 +127,10 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
"""Test if given state_id is available for ob
in at least one associated workflow
"""
from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition
if WITH_LEGACY_WORKFLOW:
from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition
else:
InteractionWorkflowDefinition = None.__class__
from Products.ERP5Type.Core.InteractionWorkflow import InteractionWorkflow
for workflow in (wf_id and (self[wf_id],) or self.getWorkflowValueListFor(ob.getPortalType())):
if not isinstance(workflow, (InteractionWorkflowDefinition,
......@@ -639,10 +645,10 @@ if WITH_LEGACY_WORKFLOW:
deprecated('getWorkflowIds() is deprecated; use objectIds()')\
(lambda self: self.objectIds())
WorkflowTool.security.declarePrivate('getWorkflowIds')
WorkflowTool.getWorkflowById = \
deprecated('getWorkflowById() is deprecated')\
(lambda self, wf_id: self._getOb(wf_id, None))
WorkflowTool.security.declarePrivate('getWorkflowById')
# XXX We still use portal_workflow.getInfoFor, that calls WorkflowTool.getWorkflowById
WorkflowTool.getWorkflowById = lambda self, wf_id: self._getOb(wf_id, None)
WorkflowTool.security.declarePrivate('getWorkflowById')
InitializeClass(WorkflowTool)
......
......@@ -37,8 +37,7 @@ if WITH_LEGACY_WORKFLOW:
from Products.ERP5Type.patches import DCWorkflow
from Products.ERP5Type.patches import Worklists
from Products.ERP5Type.patches import BTreeFolder2
if WITH_LEGACY_WORKFLOW:
from Products.ERP5Type.patches import WorkflowTool
from Products.ERP5Type.patches import WorkflowTool
from Products.ERP5Type.patches import DynamicType
from Products.ERP5Type.patches import Expression
from Products.ERP5Type.patches import sqltest
......@@ -63,8 +62,7 @@ from Products.ERP5Type.patches import DateTimePatch
from Products.ERP5Type.patches import PythonScript
from Products.ERP5Type.patches import MailHost
from Products.ERP5Type.patches import memcache_client
if WITH_LEGACY_WORKFLOW:
from Products.ERP5Type.patches import StateChangeInfoPatch
from Products.ERP5Type.patches import StateChangeInfoPatch
from Products.ERP5Type.patches import transforms
from Products.ERP5Type.patches import OFSPdata
from Products.ERP5Type.patches import DemoStorage
......
......@@ -27,7 +27,6 @@
##############################################################################
from Products.ERP5Type import WITH_LEGACY_WORKFLOW
assert WITH_LEGACY_WORKFLOW
from Products.DCWorkflow.Expression import StateChangeInfo
from Products.PythonScripts.Utility import allow_class
......
This diff is collapsed.
......@@ -38,7 +38,6 @@ from Products.DCWorkflow.Transitions import TRIGGER_USER_ACTION
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type import Permissions
from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition
from Products.ERP5Type.Base import Base
......
......@@ -28,6 +28,7 @@
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type import WITH_LEGACY_WORKFLOW
from Testing import ZopeTestCase
class TestNamingConvention(ERP5TypeTestCase):
......@@ -65,7 +66,7 @@ class TestNamingConvention(ERP5TypeTestCase):
'erp5_promise', 'erp5_software_pdm', 'erp5_sso_openam', 'erp5_jquery_plugin_hotkey',
'erp5_jquery_plugin_jgraduate', 'erp5_jquery_plugin_svgicon', 'erp5_jquery_plugin_jquerybbq',
'erp5_jquery_plugin_spinbtn', 'erp5_jquery_plugin_svg_editor', 'erp5_svg_editor', 'erp5_syncml',
'erp5_system_event', 'erp5_tiosafe_core', 'erp5_workflow_test',
'erp5_system_event', 'erp5_tiosafe_core',
'erp5_public_accounting_budget', 'erp5_publication',
'erp5_social_contracts', 'test_core', 'test_accounting', 'test_web', 'test_html_style',
'test_xhtml_style', 'cloudooo_data', 'cloudooo_web', 'erp5_configurator',
......@@ -79,7 +80,7 @@ class TestNamingConvention(ERP5TypeTestCase):
# 'erp5_accounting_l10n_pl',
# 'erp5_accounting_l10n_sn',
# 'erp5_accounting_l10n_in',
)
) + (('erp5_workflow_test',) if WITH_LEGACY_WORKFLOW else ())
def getTitle(self):
return "Naming Convention"
......
......@@ -26,7 +26,9 @@
#
##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type import WITH_LEGACY_WORKFLOW
import StringIO
import unittest
import urllib
import httplib
......@@ -149,3 +151,9 @@ class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
self.assertEquals(
error_list, [],
msg="The following Portal Type classes could not be loaded (see zLOG.log): %r" % error_list)
def test_suite():
suite = unittest.TestSuite()
if WITH_LEGACY_WORKFLOW:
suite.addTest(unittest.makeSuite(TestUpgradeInstanceWithOldDataFs))
return suite
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