Commit 4fe139f5 authored by Ivan Tyagov's avatar Ivan Tyagov

Make it possible to be used as a gadget renderer in both synchronous and asynchronous mode.

Improve code styling.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22643 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3c06c51d
...@@ -95,56 +95,77 @@ http_parameters = http_parameters.replace(\'editable_mode\', \'dummy_editable_mo ...@@ -95,56 +95,77 @@ http_parameters = http_parameters.replace(\'editable_mode\', \'dummy_editable_mo
absolute_url = context.absolute_url()\n absolute_url = context.absolute_url()\n
editable_absolute_url = getattr(context, \'editable_absolute_url\', absolute_url)\n editable_absolute_url = getattr(context, \'editable_absolute_url\', absolute_url)\n
\n \n
# action title based on security\n
def getActionTitleForContext(context, portal_type):\n
if context.portal_membership.checkPermission(\'Modify portal content\', context):\n
edit_title = translateString("Edit ${portal_type}", \n
mapping=dict(portal_type=portal_type))\n
else:\n
edit_title = translateString("Access ${portal_type} details",\n
mapping=dict(portal_type=portal_type))\n
return edit_title\n
\n \n
# Append a button to edit the current document\n # Append a button to edit the current document\n
if not request.form.get(\'editable_mode\', 0):\n if not request.form.get(\'editable_mode\', 0):\n
# The title is called Edit only if the document can be edited\n # The title is called Edit only if the document can be edited\n
if context.portal_membership.checkPermission(\'Modify portal content\', context):\n \n
edit_title = translateString("Edit ${portal_type}", mapping=dict(portal_type=portal_type))\n if portal_type == \'Web Section\' and context.getDefaultDocumentValue() is not None:\n
# try to show link to default page\n
default_document = context.getDefaultDocumentValue()\n
# change portal_type, this will be taken into account when determining parent action (below)\n
portal_type = default_document.getPortalType() \n
edit_title = getActionTitleForContext(context, portal_type)\n
result.append(dict(\n
url = "%s/view?editable_mode:int=1&%s" \n
%(default_document.absolute_url(), http_parameters),\n
icon = default_document.getIcon() or \'file_icon.gif\',\n
title = edit_title,\n
label = "%s Icon" % portal_type,))\n
else:\n else:\n
edit_title = translateString("Access ${portal_type} details", mapping=dict(portal_type=portal_type))\n edit_title = getActionTitleForContext(context, portal_type)\n
result.append(dict(\n
url = "%s/view?editable_mode:int=1&%s" \n
%(editable_absolute_url, http_parameters),\n
icon = context.getIcon() or \'file_icon.gif\',\n
title = edit_title,\n
label = "%s Icon" % portal_type,))\n
\n
else: \n
result.append(dict(\n result.append(dict(\n
url = "%s/view?editable_mode:int=1&%s" % (editable_absolute_url, http_parameters),\n url = "%s/view?editable_mode:int=0&%s" % (absolute_url, http_parameters),\n
icon = context.getIcon() or \'file_icon.gif\',\n icon = context.getIcon() or \'file_icon.gif\',\n
title = edit_title,\n title = translateString("View ${portal_type}", \n
label = "%s Icon" % portal_type,\n mapping=dict(portal_type=portal_type)),\n
))\n label = "%s Icon" % portal_type,))\n
else: result.append(dict(\n
url = "%s/view?editable_mode:int=0&%s" % (absolute_url, http_parameters),\n
icon = context.getIcon() or \'file_icon.gif\',\n
title = translateString("View ${portal_type}", mapping=dict(portal_type=portal_type)),\n
label = "%s Icon" % portal_type,\n
))\n
\n \n
# Append a button to edit the parent section\n # Append a button to edit the parent section\n
if portal_type not in (\'Web Section\', \'Web Site\'): result.append(dict(\n if portal_type not in (\'Web Section\', \'Web Site\'): \n
url = "%s/view?editable_mode=1" % current_web_section.absolute_url(),\n result.append(dict(\n
icon = current_web_section.getIcon(),\n url = "%s/view?editable_mode=1" % current_web_section.absolute_url(),\n
title = translateString("Edit parent ${portal_type}", mapping=dict(portal_type=current_web_section_pt)),\n icon = current_web_section.getIcon(),\n
label = "%s Icon" % current_web_section_pt,\n title = translateString("Edit parent ${portal_type}",\n
))\n mapping=dict(portal_type=current_web_section_pt)),\n
label = "%s Icon" % current_web_section_pt,))\n
\n \n
# Append all icon buttons\n # Append all icon buttons\n
for action in button_action_list:\n for action in button_action_list:\n
if action[\'id\'] == \'webdav\':\n if action[\'id\'] == \'webdav\':\n
result.append(dict(\n result.append(dict(\n
url = action[\'url\'].replace(absolute_url, editable_absolute_url),\n url = action[\'url\'].replace(absolute_url, editable_absolute_url),\n
icon = action[\'icon\'],\n icon = action[\'icon\'],\n
title = translateString(action[\'title\']),\n title = translateString(action[\'title\']),\n
label = "WebDAV Icon",\n label = "WebDAV Icon",))\n
))\n
\n \n
# Append an exchange button\n # Append an exchange button\n
if len(exchange_action_list):\n if len(exchange_action_list):\n
action = exchange_action_list[0]\n action = exchange_action_list[0]\n
url = action[\'url\'].replace(absolute_url, editable_absolute_url)\n url = action[\'url\'].replace(absolute_url, editable_absolute_url)\n
url = \'%s?dialog_category=object_exchange&cancel_url=%s/view\' % (url, absolute_url)\n url = \'%s?dialog_category=object_exchange&cancel_url=%s/view\' % (url, absolute_url)\n
result.append(dict(\n result.append(dict(\n
url = url,\n url = url,\n
icon = \'%s/images/imp-exp.png\' % portal_url,\n icon = \'%s/images/imp-exp.png\' % portal_url,\n
title = translateString(\'Import / Export\'),\n title = translateString(\'Import / Export\'),\n
label = "Import / Export Icon",\n label = "Import / Export Icon",))\n
))\n
\n \n
return result\n return result\n
...@@ -163,6 +184,12 @@ return result\n ...@@ -163,6 +184,12 @@ return result\n
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -207,8 +234,11 @@ return result\n ...@@ -207,8 +234,11 @@ return result\n
<string>absolute_url</string> <string>absolute_url</string>
<string>getattr</string> <string>getattr</string>
<string>editable_absolute_url</string> <string>editable_absolute_url</string>
<string>dict</string> <string>getActionTitleForContext</string>
<string>None</string>
<string>default_document</string>
<string>edit_title</string> <string>edit_title</string>
<string>dict</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>action</string> <string>action</string>
<string>_getitem_</string> <string>_getitem_</string>
......
...@@ -41,6 +41,12 @@ ...@@ -41,6 +41,12 @@
</object> </object>
</value> </value>
</item> </item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
...@@ -54,16 +60,17 @@ ...@@ -54,16 +60,17 @@
TODO: Is this case should be handle by automaticcaly by erp5_xhtml_style ?\n TODO: Is this case should be handle by automaticcaly by erp5_xhtml_style ?\n
-->\n -->\n
\n \n
\n
<tal:block\n <tal:block\n
tal:define="is_web_mode python: True;\n tal:define="is_web_mode python: True;\n
portal_type python: here.getPortalType();\n portal_type python: here.getPortalType();\n
actions request/actions | python:\n actions request/actions | python:\n
here.Base_filterDuplicateActions(here.portal_actions.listFilteredActionsFor(here));\n here.Base_filterDuplicateActions(\n
here.portal_actions.listFilteredActionsFor(here));\n
dummy python:request.set(\'actions\', actions);">\n dummy python:request.set(\'actions\', actions);">\n
\n \n
<!-- XXX is this really useful - called how many times ?? - tried to removed but failed -->\n <!-- XXX is this really useful - called how many times ?? - tried to removed but failed -->\n
<!-- <tal:block metal:use-macro="here/global_definitions/macros/header_definitions"/> -->\n <!-- <tal:block metal:use-macro="here/global_definitions/macros/header_definitions"/> -->\n
\n
\n \n
<!-- Edit button menu -->\n <!-- Edit button menu -->\n
<div name="adminSection" class="adminSection">\n <div name="adminSection" class="adminSection">\n
......
690 681
\ 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