Commit 9f4af817 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: We need to create active process manager

Normal users can not call it directly
parent 51b5f4e1
"""
We need proy role as manager to create a new active process
and post active result
"""
portal = context.getPortalObject()
if REQUEST:
return RuntimeError("You cannot run this script in the url")
if active_process_url:
active_process = portal.restrictedTraverse(active_process_url)
else:
active_process = portal.portal_activities.newActiveProcess()
active_process.postActiveResult(detail=detail)
return active_process
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>active_process_url, detail, REQUEST=None, **kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_postDataToActiveResult</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -15,21 +15,18 @@ if not active_preference:
if active_preference and preferred_cropped_canvas_data:
active_preference.setPreferredCroppedCanvasData(preferred_cropped_canvas_data)
if active_process_url:
active_process = portal.restrictedTraverse(active_process_url)
if not image_str:
if batch_mode:
return active_process
return None
return context.Base_renderForm('Base_viewUploadDocumentFromCameraDialog',
message=translateString('Nothing to capture'))
if not active_process_url:
active_process = portal.portal_activities.newActiveProcess()
context.REQUEST.form["your_active_process_url"] = active_process.getRelativeUrl()
active_process = context.Base_postDataToActiveResult(
active_process_url,
image_str)
active_process.postActiveResult(detail=image_str)
context.REQUEST.form["your_active_process_url"] = active_process.getRelativeUrl()
context.REQUEST.form.pop("field_your_document_scanner_gadget")
context.REQUEST.form.pop('document_scanner_gadget')
......
......@@ -6,6 +6,9 @@ active_process = context.Base_storeDocumentFromCameraInActiveProcess(
batch_mode=True,
**kw)
if active_process is None and active_process_url:
active_process = portal.restrictedTraverse(active_process_url)
# Avoid to pass huge images to the activity
kw.pop("your_document_scanner_gadget", None)
......
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