Commit dedb04c2 authored by Łukasz Nowak's avatar Łukasz Nowak

Use low level workflow migration.

parent 579d3c69
...@@ -179,25 +179,17 @@ def SlapDocument_migrateSlapState(self): ...@@ -179,25 +179,17 @@ def SlapDocument_migrateSlapState(self):
'stopped': 'stop_requested', 'stopped': 'stop_requested',
'destroyed': 'destroy_requested' 'destroyed': 'destroy_requested'
} }
required_state = state_map[state]
if slap_document.getSlapState() == 'draft': _jumpToStateFor = portal.portal_workflow._jumpToStateFor
if state == "started": if slap_document.getSlapState() != required_state:
slap_document.requestStart(comment='Migration.', **promise_kw) _jumpToStateFor(slap_document, required_state, 'instance_slap_interface_workflow')
elif state == "stopped": if not(slap_document.getSlapState() == required_state):
slap_document.requestStop(comment='Migration.', **promise_kw) raise ValueError('%s: %s != %s' % (state, slap_document.getSlapState(), required_state))
elif state == "destroyed":
raise NotImplementedError
slap_document.requestDestroy(comment='Migration.', **promise_kw)
else:
raise ValueError("Unknown state %s for %s" % (state, slap_document.getRelativeUrl()))
if not(slap_document.getSlapState() == state_map[state]):
raise ValueError('%s: %s != %s' % (state, slap_document.getSlapState(), state_map[state]))
# Migrate validation state # Migrate validation state
if portal_type == 'Hosting Subscription': if portal_type == 'Hosting Subscription':
if state == 'destroyed': if state == 'destroyed':
slap_document.validate() _jumpToStateFor(slap_document, 'archived', 'hosting_subscription_workflow')
slap_document.archive()
assert(slap_document.getValidationState() == 'archived') assert(slap_document.getValidationState() == 'archived')
else: else:
assert(slap_document.getValidationState() == 'validated') assert(slap_document.getValidationState() == 'validated')
...@@ -205,7 +197,7 @@ def SlapDocument_migrateSlapState(self): ...@@ -205,7 +197,7 @@ def SlapDocument_migrateSlapState(self):
if state == 'destroyed' and \ if state == 'destroyed' and \
(explanation_delivery_line.getPortalType() == 'Sale Order Line' or \ (explanation_delivery_line.getPortalType() == 'Sale Order Line' or \
explanation_delivery_line.getSimulationState() == 'delivered'): explanation_delivery_line.getSimulationState() == 'delivered'):
slap_document.invalidate() _jumpToStateFor(slap_document, 'invalidated', 'item_workflow')
else: else:
if not(slap_document.getValidationState() == 'validated'): if not(slap_document.getValidationState() == 'validated'):
raise ValueError('%s != %s' % (slap_document.getValidationState(), 'validated')) raise ValueError('%s != %s' % (slap_document.getValidationState(), 'validated'))
......
97 98
\ 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