Commit 0cb802dc authored by Romain Courteaud's avatar Romain Courteaud

[erp5_hal_json_style] Propagate default parameters for all non standard search methods.

parent 7ce5c139
......@@ -70,13 +70,14 @@ return context.ERP5Document_getHateoas(\n
form=form,\n
relative_url=relative_url,\n
list_method=list_method,\n
default_param_json=default_param_json,\n
restricted=1\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, form=None, relative_url=None, list_method=None</string> </value>
<value> <string>REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, form=None, relative_url=None, list_method=None, default_param_json=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -60,6 +60,7 @@
from ZTUtils import make_query\n
import json\n
from base64 import urlsafe_b64encode, urlsafe_b64decode\n
from DateTime import DateTime\n
if REQUEST is None:\n
REQUEST = context.REQUEST\n
......@@ -78,6 +79,7 @@ url_template_dict = {\n
"custom_search_template": "%(root_url)s/%(script_id)s?mode=search" + \\\n
"&relative_url=%(relative_url)s" \\\n
"&list_method=%(list_method)s" \\\n
"&default_param_json=%(default_param_json)s" \\\n
"{&query,select_list*,limit*}",\n
"new_content_action": "%(root_url)s/%(script_id)s?mode=newContent",\n
# XXX View is set by default to empty\n
......@@ -277,16 +279,17 @@ def renderField(field, meta_type=None):\n
\n
if (list_method_name == "portal_catalog"):\n
pass\n
elif (list_method_name in ("searchFolder", "objectValues")):\n
elif (list_method_name == "searchFolder"):\n
list_method_query_dict["parent_uid"] = traversed_document.getUid()\n
else:\n
list_method_custom = url_template_dict["custom_search_template"] % {\n
"root_url": site_root.absolute_url(),\n
"script_id": script.id,\n
"relative_url": traversed_document.getRelativeUrl().replace("/", "%2F"),\n
"list_method": list_method_name\n
"list_method": list_method_name,\n
"default_param_json": urlsafe_b64encode(json.dumps(list_method_query_dict))\n
}\n
\n
list_method_query_dict = {}\n
\n
# row_list = list_method(limit=lines, portal_type=portal_types,\n
# **default_params)\n
......@@ -797,14 +800,17 @@ elif mode == \'search\':\n
# length = len(\'/%s/\' % portal.getId())\n
# # context.log(portal.portal_catalog(full_text=query, limit=limit, src__=1))\n
# context.log(query)\n
catalog_kw = {}\n
if (default_param_json is not None):\n
catalog_kw = json.loads(urlsafe_b64decode(default_param_json))\n
if (list_method is None):\n
callable_list_method = portal.portal_catalog\n
else:\n
callable_list_method = getattr(traversed_document, list_method)\n
if query:\n
sql_list = callable_list_method(full_text=query, limit=limit)\n
sql_list = callable_list_method(full_text=query, limit=limit, **catalog_kw)\n
else:\n
sql_list = callable_list_method(limit=limit)\n
sql_list = callable_list_method(limit=limit, **catalog_kw)\n
\n
result_list = []\n
\n
......@@ -908,7 +914,7 @@ return json.dumps(result_dict, indent=2)\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, form=None, relative_url=None, restricted=0, list_method=None</string> </value>
<value> <string>REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, form=None, relative_url=None, restricted=0, list_method=None, default_param_json=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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