From 2a4dac0640d2e00c79d849737cd4cad0b5d67183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Thu, 30 Sep 2010 13:43:50 +0000 Subject: [PATCH] support searching by category strict git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38808 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../portal_skins/erp5_core/Folder_search.xml | 19 ++++++++------- product/ERP5/bootstrap/erp5_core/bt/revision | 2 +- .../Extensions/Folder_viewSearchDialog.py | 23 ++++++++++++++++--- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_search.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_search.xml index 4aa1df3050..e780d3b2ed 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_search.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_search.xml @@ -65,12 +65,12 @@ def sorted(seq):\n # the entered value, and what was the usage.\n \n # Note that we don\'t use queries, because we want to let the catalog filter out\n -# ignored parameters by itself.\n +# ignored parameters by itself.\n \n -usage_map = dict(min=\'>=\',\n - max=\'<\',\n - ngt=\'<=\',\n - nlt=\'>\',)\n +usage_map = dict(min=\'>=\',\n + max=\'<\',\n + ngt=\'<=\',\n + nlt=\'>\',)\n \n new_mapping = dict(ignore_hide_rows=1)\n for key in sorted(request.form.keys()):\n @@ -78,10 +78,10 @@ for key in sorted(request.form.keys()):\n value = request.form[key]\n \n # to remove unnecessary None value\n - if value == None:\n + if value is None:\n request.form.pop(key)\n continue\n -\n + \n # workaround the bogus case where a value is passed ?value=None\n if value == \'None\':\n value = None\n @@ -106,7 +106,10 @@ for key in sorted(request.form.keys()):\n new_mapping[real_key] = \'%s %s\' % (usage_map[value], new_mapping[real_key])\n \n else:\n - new_mapping[key] = value\n + if request.form.get(\'%s_is_strict_\' % key):\n + new_mapping[\'strict_%s\' % key] = value\n + else:\n + new_mapping[key] = value\n \n # set selection parameters\n container.portal_selections.setSelectionParamsFor(selection_name, new_mapping)\n diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index a35fccb568..fe59cd29b5 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -1736 \ No newline at end of file +1737 \ No newline at end of file diff --git a/product/ERP5Form/Extensions/Folder_viewSearchDialog.py b/product/ERP5Form/Extensions/Folder_viewSearchDialog.py index 3ed548da17..cb6e74cc5a 100644 --- a/product/ERP5Form/Extensions/Folder_viewSearchDialog.py +++ b/product/ERP5Form/Extensions/Folder_viewSearchDialog.py @@ -69,8 +69,10 @@ def getSearchDialog(self, REQUEST=None): field._surcharged_tales( dict( default=TALESMethod( - 'here/portal_selections/%s/%s_relative_url | nothing' - % (selection_name, request_key)), + 'here/portal_selections/%s/%s_relative_url | ' + 'here/portal_selections/%s/strict_%s_relative_url | nothing' + % (selection_name, request_key, + selection_name, request_key)), items=TALESMethod('python: getattr(here.portal_categories["%s"],' 'here.portal_preferences.getPreference("' 'preferred_category_child_item_list_method_id",' @@ -80,6 +82,20 @@ def getSearchDialog(self, REQUEST=None): 'local_sort_id="int_index")' % request_key)), ['title', 'items', 'default']) + field_id = 'your_%s_relative_url_is_strict_' % request_key + temp_form.manage_addField(field_id, field_title, 'ProxyField') + field = temp_form._getOb(field_id) + field.manage_edit_xmlrpc(dict( + form_id='Base_viewFieldLibrary', + field_id='your_checkbox')) + field._surcharged_edit(dict(title='%s Strict' % field_title), ['title']) + field._surcharged_tales( + dict( + default=TALESMethod( + 'here/portal_selections/%s/strict_%s_relative_url | nothing' + % (selection_name, request_key,))), + ['title', 'default']) + def addFloatField(field_id, field_title): request_key = field_id @@ -333,7 +349,8 @@ def getSearchDialog(self, REQUEST=None): field_id = field.getId() if field_id.endswith('search_key') or field_id.endswith('_usage_'): temp_form.move_field_group([field_id], default_group, 'right') - elif field.get_value('field_id') == 'your_category_list' \ + elif field.get_value('field_id') in ('your_category_list', + 'your_checkbox') \ or field_id == 'your_SearchableText': temp_form.move_field_group([field_id], default_group, 'center') -- 2.30.9