From c4241fb7012b5ddf61c2bf5e1375b75b689e1901 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Wed, 3 Mar 2010 08:20:36 +0000
Subject: [PATCH] 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
---
 .../erp5_dms/Base_assembleSearchString.xml            |  6 ++++--
 .../erp5_dms/Base_getAdvancedSearchResultList.xml     | 11 +++++++----
 bt5/erp5_dms/bt/revision                              |  2 +-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_assembleSearchString.xml b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_assembleSearchString.xml
index b088367ecf..154a3c8bac 100644
--- a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_assembleSearchString.xml
+++ b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_assembleSearchString.xml
@@ -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>
diff --git a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getAdvancedSearchResultList.xml b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getAdvancedSearchResultList.xml
index 3805b4a4d5..05698cfb1f 100644
--- a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getAdvancedSearchResultList.xml
+++ b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getAdvancedSearchResultList.xml
@@ -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>
diff --git a/bt5/erp5_dms/bt/revision b/bt5/erp5_dms/bt/revision
index bf0a67dc5c..77bdd49b54 100644
--- a/bt5/erp5_dms/bt/revision
+++ b/bt5/erp5_dms/bt/revision
@@ -1 +1 @@
-1084
\ No newline at end of file
+1085
\ No newline at end of file
-- 
2.30.9