Commit 41063b6e authored by Jérome Perrin's avatar Jérome Perrin

Add an implicit print dialog for print action that doesn't use a dialog.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18022 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8fcd7465
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>_body</string> </key>
<value> <string>"""This script fix dialog actions to add an empty dialog for object_print\n
actions that does not provide one.\n
"""\n
from Products.PythonScripts.standard import url_quote\n
\n
if dialog_category != \'object_print\':\n
return actions.get(dialog_category, [])\n
\n
def addDialogIfNeeded(url):\n
\'\'\'If the action url is not a dialog, we add a generic print dialog.\n
\'\'\'\n
parts = url.split(\'/\')\n
absolute_url = \'/\'.join(parts[:-1])\n
action = parts[-1]\n
action_id = action.split(\'?\')[0]\n
form = getattr(context, action_id, None)\n
if form is not None and getattr(form, \'pt\', None) != \'form_dialog\':\n
url = \'%s/Base_viewIntermediatePrintDialog?dialog_action_url=%s\' % (\n
context.absolute_url(), url_quote(\'%s/%s\' % (absolute_url, action)))\n
return url\n
\n
print_action_list = actions[\'object_print\']\n
new_print_action_list = []\n
for ai in print_action_list:\n
ai_copy = ai.copy()\n
# this is quite low level. It may require to be done from file system code in\n
# the future.\n
ai_copy.data[\'original_url\'] = ai_copy[\'url\']\n
ai_copy.data[\'url\'] = addDialogIfNeeded(ai_copy[\'url\'])\n
new_print_action_list.append( ai_copy )\n
\n
return new_print_action_list\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>actions, dialog_category</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>actions</string>
<string>dialog_category</string>
<string>Products.PythonScripts.standard</string>
<string>url_quote</string>
<string>_getattr_</string>
<string>addDialogIfNeeded</string>
<string>_getitem_</string>
<string>print_action_list</string>
<string>new_print_action_list</string>
<string>_getiter_</string>
<string>ai</string>
<string>ai_copy</string>
<string>_write_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_fixDialogActions</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>_body</string> </key>
<value> <string>return container.REQUEST.RESPONSE.redirect(dialog_action_url)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>dialog_action_url</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>dialog_action_url</string>
<string>_getattr_</string>
<string>container</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_redirectToDialogAction</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="ERP5Form" module="Products.ERP5Form.Form"/>
<string>Products.ERP5Form.Form</string> <tuple/>
<string>ERP5Form</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -39,6 +36,12 @@ ...@@ -39,6 +36,12 @@
</object> </object>
</value> </value>
</item> </item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>_owner</string> </key> <key> <string>_owner</string> </key>
<value> <value>
...@@ -47,7 +50,11 @@ ...@@ -47,7 +50,11 @@
</item> </item>
<item> <item>
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>Base_printPdf</string> </value> <value> <string>Base_redirectToDialogAction</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>encoding</string> </key> <key> <string>encoding</string> </key>
...@@ -55,13 +62,17 @@ ...@@ -55,13 +62,17 @@
</item> </item>
<item> <item>
<key> <string>enctype</string> </key> <key> <string>enctype</string> </key>
<value> <string>multipart/form-data</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>group_list</string> </key> <key> <string>group_list</string> </key>
<value> <value>
<list> <list>
<string>Default</string> <string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -70,7 +81,33 @@ ...@@ -70,7 +81,33 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>Default</string> </key> <key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_dialog_action_url</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value> <value>
<list/> <list/>
</value> </value>
...@@ -80,7 +117,7 @@ ...@@ -80,7 +117,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Base_print</string> </value> <value> <string>Base_viewIntermediatePrintDialog</string> </value>
</item> </item>
<item> <item>
<key> <string>method</string> </key> <key> <string>method</string> </key>
...@@ -88,7 +125,7 @@ ...@@ -88,7 +125,7 @@
</item> </item>
<item> <item>
<key> <string>name</string> </key> <key> <string>name</string> </key>
<value> <string>Base_print</string> </value> <value> <string>Folder_viewPrintDialog</string> </value>
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>_body</string> </key>
<value> <string>request = container.REQUEST\n
if \'dialog_action_url\' in request:\n
current_url = request[\'dialog_action_url\']\n
for action in dialog_actions:\n
if current_url == action[\'original_url\']:\n
return action\n
else:\n
for action in dialog_actions:\n
if current_url == action[\'url\'].split(\'?\')[0]:\n
return action\n
return None\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>current_url, dialog_actions</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>current_url</string>
<string>dialog_actions</string>
<string>_getattr_</string>
<string>container</string>
<string>request</string>
<string>_getitem_</string>
<string>_getiter_</string>
<string>action</string>
<string>None</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_getCurrentDialogAction</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<string>Products.PythonScripts.PythonScript</string> <tuple/>
<string>PythonScript</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -68,17 +65,18 @@ ...@@ -68,17 +65,18 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>kw.update(context.REQUEST.form)\n <value> <string>request = container.REQUEST\n
kw.update(request.form)\n
context.ERP5Site_prepareAction(**kw)\n context.ERP5Site_prepareAction(**kw)\n
\n \n
print_action_list = context.Base_filterDuplicateActions(\n new_print_action_list = context.Base_fixDialogActions(\n
context.portal_actions.listFilteredActionsFor(context))[\'object_print\']\n context.Base_filterDuplicateActions(\n
if len(print_action_list) == 0:\n context.portal_actions.listFilteredActionsFor(context)), \'object_print\')\n
return\n \n
if len(print_action_list) == 1:\n return context.ERP5Site_redirect(new_print_action_list[0][\'url\'],\n
return context.ERP5Site_redirect(print_action_list[0][\'url\'], keep_items={\'form_id\': form_id}, **kw)\n keep_items={\'form_id\': form_id,\n
else:\n \'cancel_url\': cancel_url,\n
return context.ERP5Site_redirect(\'%s/Base_print\' % (context.absolute_url(), ), keep_items={\'dialog_category\': \'object_print\', \'form_id\': form_id, \'cancel_url\': cancel_url}, **kw)\n \'dialog_category\': \'object_print\'}, **kw)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -131,11 +129,12 @@ else:\n ...@@ -131,11 +129,12 @@ else:\n
<string>cancel_url</string> <string>cancel_url</string>
<string>kw</string> <string>kw</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>container</string>
<string>request</string>
<string>_apply_</string> <string>_apply_</string>
<string>context</string>
<string>new_print_action_list</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>print_action_list</string>
<string>len</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -65,7 +65,8 @@ ...@@ -65,7 +65,8 @@
left_group python: form.get_fields_in_group(\'left\');\n left_group python: form.get_fields_in_group(\'left\');\n
right_group python: form.get_fields_in_group(\'right\');\n right_group python: form.get_fields_in_group(\'right\');\n
center_group python: form.get_fields_in_group(\'center\');\n center_group python: form.get_fields_in_group(\'center\');\n
dialog_actions python: actions.get(dialog_category, []);\n dialog_actions python: here.Base_fixDialogActions(actions, dialog_category);\n
current_action python: here.ERP5Site_getCurrentDialogAction(current_url, dialog_actions);\n
field_render here/field_render/macros/field_render;">\n field_render here/field_render/macros/field_render;">\n
<tal:block tal:condition="preferred_html_style_developper_mode">\n <tal:block tal:condition="preferred_html_style_developper_mode">\n
<tal:block metal:use-macro="developper_shortcut_render/macros/form" />\n <tal:block metal:use-macro="developper_shortcut_render/macros/form" />\n
...@@ -83,6 +84,7 @@ ...@@ -83,6 +84,7 @@
i18n:translate="" i18n:domain="ui"></label>\n i18n:translate="" i18n:domain="ui"></label>\n
<select name="select_dialog" id="dialog_selector"\n <select name="select_dialog" id="dialog_selector"\n
tal:attributes="onChange string:submitAction(this.form,\'Base_doDialog\')">\n tal:attributes="onChange string:submitAction(this.form,\'Base_doDialog\')">\n
\n
<tal:block tal:repeat="action dialog_actions">\n <tal:block tal:repeat="action dialog_actions">\n
<option tal:attributes="value action/url;\n <option tal:attributes="value action/url;\n
selected python: action == current_action and \'selected\' or None"\n selected python: action == current_action and \'selected\' or None"\n
......
453 454
\ 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