Commit 904b2c55 authored by Nicolas Delaby's avatar Nicolas Delaby

Small refactoring

* rename variables
* access tools from portal itself
* take also into account reference to querying resource (like title, which is already supported)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40250 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 39867d0e
...@@ -55,18 +55,27 @@ This script returns only the quantity unit of the resource \n ...@@ -55,18 +55,27 @@ This script returns only the quantity unit of the resource \n
entered on the fast input\n entered on the fast input\n
"""\n """\n
request = context.REQUEST\n request = context.REQUEST\n
result = getattr(context.portal_categories[\'quantity_unit\'], \n portal = context.getPortalObject()\n
context.portal_preferences.getPreference(\n
\'preferred_category_child_item_list_method_id\', \'getCategoryChildCompactLogicalPathItemList\'))(\n
base=0, local_sort_id=(\'int_index\', \'translated_title\'), checked_permission=\'View\')\n
\n \n
base_category = portal.portal_categories.quantity_unit\n
list_method_id = portal.portal_preferences.\\\n
getPreferredCategoryChildItemListMethodId(\n
\'getCategoryChildCompactLogicalPathItemList\')\n
method = getattr(base_category, list_method_id)\n
item_list = method(base=0, local_sort_id=(\'int_index\', \'translated_title\'),\n
checked_permission=\'View\')\n
\n
\n
resource_title = request.form.get("field_listbox_title_%s" % context.getUid())\n
resource_reference = request.form.get("field_listbox_reference_%s" % context.getUid())\n
resource_value = context.getResourceValue()\n
result = [(\'\', \'\')]\n
if (resource_title or resource_reference) and resource_value is not None:\n
quantity_unit_list = [(x.getLogicalPath(), x.getCategoryRelativeUrl(base=0))\n
for x in resource_value.getQuantityUnitValueList()]\n
# return the first quantity_unit item of resource\n
result = quantity_unit_list and [quantity_unit_list[0]] or result\n
\n \n
pr_title= request.form.get("field_listbox_title_%s"%context.getUid())\n
if pr_title not in (\'\',None) and context.getResourceValue() is not None:\n
q_list = [(x.getLogicalPath(), x.getCategoryRelativeUrl(base=0)) \n
for x in context.getResourceValue().getQuantityUnitValueList()]\n
result=[]\n
result = [q_list[0]]\n
return result\n return result\n
</string> </value> </string> </value>
</item> </item>
...@@ -107,16 +116,23 @@ return result\n ...@@ -107,16 +116,23 @@ return result\n
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>request</string> <string>request</string>
<string>portal</string>
<string>base_category</string>
<string>list_method_id</string>
<string>getattr</string> <string>getattr</string>
<string>_getitem_</string> <string>method</string>
<string>item_list</string>
<string>resource_title</string>
<string>resource_reference</string>
<string>resource_value</string>
<string>result</string> <string>result</string>
<string>pr_title</string>
<string>None</string> <string>None</string>
<string>append</string> <string>append</string>
<string>$append0</string> <string>$append0</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>x</string> <string>x</string>
<string>q_list</string> <string>quantity_unit_list</string>
<string>_getitem_</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
1028 1032
\ 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