Commit c4241fb7 authored by Ivan Tyagov's avatar Ivan Tyagov

Handle better boolean values which may have been passed by advanced search form.

Filter by contributor title (if passed).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33307 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e2eaf75b
......@@ -60,6 +60,7 @@
It is the reverse of Base_parseSearchString script.\n
"""\n
MARKER = [\'\', None]\n
BOOLEAN_MARKER = MARKER + [0]\n
request = context.REQUEST\n
\n
# one can specify a direct search string, \n
......@@ -140,12 +141,12 @@ for category in (\'contributor_title\',):\n
\n
# only my docs\n
mine = kw.get(\'mine\', request.get(\'mine\', None))\n
if mine not in MARKER:\n
if mine not in BOOLEAN_MARKER:\n
search_string += \' mine:yes\'\n
\n
# only newest versions\n
newest = kw.get(\'newest\', request.get(\'newest\', None))\n
if newest not in MARKER:\n
if newest not in BOOLEAN_MARKER:\n
search_string += \' newest:yes\'\n
\n
# search mode\n
......@@ -195,6 +196,7 @@ return search_string\n
<string>kw</string>
<string>None</string>
<string>MARKER</string>
<string>BOOLEAN_MARKER</string>
<string>_getattr_</string>
<string>context</string>
<string>request</string>
......
......@@ -125,13 +125,16 @@ if modification_to:\n
if len(where_expression_list):\n
query_kw[\'where_expression\'] = \' AND \'.join(where_expression_list)\n
\n
if parsed_search_string.get(\'mine\'):\n
if parsed_search_string.get(\'mine\', None) is not None:\n
# user wants only his documents\n
query_kw[\'owner\'] = str(portal.portal_membership.getAuthenticatedMember())\n
\n
# XXX: add contributor title\n
# add contributor title\n
contributor_title = parsed_search_string.get(\'contributor_title\', None)\n
if contributor_title is not None:\n
query_kw[\'contributor_title\'] = contributor_title\n
\n
if parsed_search_string.get(\'newest\'):\n
if parsed_search_string.get(\'newest\', None) is not None:\n
#...and now we check for only the newest versions\n
# but we need to preserve order\n
query_kw[\'group_by\'] = (\'reference\',)\n
......@@ -140,7 +143,6 @@ if parsed_search_string.get(\'newest\'):\n
else:\n
result = portal.portal_catalog(**query_kw)\n
\n
context.log(portal.portal_catalog(src__=1, **query_kw))\n
return result\n
......@@ -205,6 +207,7 @@ return result\n
<string>modification_from</string>
<string>modification_to</string>
<string>str</string>
<string>contributor_title</string>
<string>append</string>
<string>$append0</string>
<string>_apply_</string>
......
1084
\ No newline at end of file
1085
\ 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