Commit beca9c4a authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: Split dialog in two steps

parent b5af9fb2
import json
from base64 import decodestring
portal = context.getPortalObject()
gadget_data = json.loads(document_scanner_gadget)
image_str = decodestring(gadget_data["input_value"])
preferred_cropped_canvas_data = json.dumps(gadget_data["preferred_cropped_canvas_data"])
active_preference = portal.portal_preferences.getActiveUserPreference()
if not active_preference:
active_preference = portal.portal_preferences.getActivePreference()
if active_preference and preferred_cropped_canvas_data:
active_preference.setPreferredCroppedCanvasData(preferred_cropped_canvas_data)
if not document_scanner_gadget:
return context.Base_renderForm('Base_viewUploadDocumentFromCameraStep1Dialog',
message='Nothing to capture')
if not active_process_url:
active_process = portal.portal_activities.newActiveProcess()
context.REQUEST.form["your_active_process_url"] = active_process.getRelativeUrl()
else:
active_process = portal.restrictedTraverse(active_process_url)
active_process.postActiveResult(detail=image_str)
return context.Base_renderForm('Base_viewUploadDocumentFromCameraStep1Dialog',
message='Captured')
<?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>portal_type=None, classification=None, synchronous_metadata_discovery=None, cancel_url=None, batch_mode=False, editable_mode=1, group=None, publication_section=None, document_scanner_gadget=None, active_process_url=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_finishDocumentUploadFromCamera</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -15,7 +15,7 @@ if active_preference and preferred_cropped_canvas_data:
active_preference.setPreferredCroppedCanvasData(preferred_cropped_canvas_data)
if not document_scanner_gadget:
return context.Base_renderForm('Base_viewUploadDocumentFromCameraDialog',
return context.Base_renderForm('Base_viewUploadDocumentFromCameraStep1Dialog',
message='Nothing to capture')
if not active_process_url:
......@@ -25,5 +25,5 @@ else:
active_process = portal.restrictedTraverse(active_process_url)
active_process.postActiveResult(detail=image_str)
return context.Base_renderForm('Base_viewUploadDocumentFromCameraDialog',
return context.Base_renderForm('Base_viewUploadDocumentFromCameraStep1Dialog',
message='Captured')
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_storeDocumentFromCameraInActiveProcess</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>multipart/form-data</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list>
<string>your_document_scanner_gadget</string>
</list>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list>
<string>stringfield_validator</string>
</list>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_active_process_url</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_viewUploadDocumentFromCameraStep1Dialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Base_viewUploadDocumentFromCameraDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Capture</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string>Base_viewUploadDocumentFromCameraStep2Dialog</string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string>Finish</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -158,7 +158,9 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
......@@ -255,7 +257,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: field.restrictedTraverse(\'gadget_document_scanner.html\').absolute_url() + "?v=0.10"</string> </value>
<value> <string>python: field.restrictedTraverse(\'gadget_document_scanner.html\').absolute_url() + "?v=0.13"</string> </value>
</item>
</dictionary>
</pickle>
......@@ -273,4 +275,17 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>string:</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -74,9 +74,7 @@
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>your_document_scanner_gadget</string>
</list>
<list/>
</value>
</item>
<item>
......@@ -90,9 +88,7 @@
<item>
<key> <string>hidden</string> </key>
<value>
<list>
<string>stringfield_validator</string>
</list>
<list/>
</value>
</item>
<item>
......@@ -123,7 +119,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_viewUploadDocumentFromCameraDialog</string> </value>
<value> <string>Base_viewUploadDocumentFromCameraStep2Dialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
......@@ -155,11 +151,11 @@
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string>Base_storeDocumentFromCameraInActiveProcess</string> </value>
<value> <string>Base_viewUploadDocumentFromCameraStep1Dialog</string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string>Capture</string> </value>
<value> <string>Back</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_active_process_url</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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