Commit 2a4dac06 authored by Jérome Perrin's avatar Jérome Perrin

support searching by category strict


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38808 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3e8fc8b0
...@@ -65,12 +65,12 @@ def sorted(seq):\n ...@@ -65,12 +65,12 @@ def sorted(seq):\n
# the entered value, and what was the usage.\n # the entered value, and what was the usage.\n
\n \n
# Note that we don\'t use queries, because we want to let the catalog filter out\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 \n
usage_map = dict(min=\'>=\',\n usage_map = dict(min=\'>=\',\n
max=\'<\',\n max=\'<\',\n
ngt=\'<=\',\n ngt=\'<=\',\n
nlt=\'>\',)\n nlt=\'>\',)\n
\n \n
new_mapping = dict(ignore_hide_rows=1)\n new_mapping = dict(ignore_hide_rows=1)\n
for key in sorted(request.form.keys()):\n for key in sorted(request.form.keys()):\n
...@@ -78,10 +78,10 @@ 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 value = request.form[key]\n
\n \n
# to remove unnecessary None value\n # to remove unnecessary None value\n
if value == None:\n if value is None:\n
request.form.pop(key)\n request.form.pop(key)\n
continue\n continue\n
\n \n
# workaround the bogus case where a value is passed ?value=None\n # workaround the bogus case where a value is passed ?value=None\n
if value == \'None\':\n if value == \'None\':\n
value = None\n value = None\n
...@@ -106,7 +106,10 @@ for key in sorted(request.form.keys()):\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 new_mapping[real_key] = \'%s %s\' % (usage_map[value], new_mapping[real_key])\n
\n \n
else:\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 \n
# set selection parameters\n # set selection parameters\n
container.portal_selections.setSelectionParamsFor(selection_name, new_mapping)\n container.portal_selections.setSelectionParamsFor(selection_name, new_mapping)\n
......
1736 1737
\ No newline at end of file \ No newline at end of file
...@@ -69,8 +69,10 @@ def getSearchDialog(self, REQUEST=None): ...@@ -69,8 +69,10 @@ def getSearchDialog(self, REQUEST=None):
field._surcharged_tales( field._surcharged_tales(
dict( dict(
default=TALESMethod( default=TALESMethod(
'here/portal_selections/%s/%s_relative_url | nothing' 'here/portal_selections/%s/%s_relative_url | '
% (selection_name, request_key)), '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"],' items=TALESMethod('python: getattr(here.portal_categories["%s"],'
'here.portal_preferences.getPreference("' 'here.portal_preferences.getPreference("'
'preferred_category_child_item_list_method_id",' 'preferred_category_child_item_list_method_id",'
...@@ -80,6 +82,20 @@ def getSearchDialog(self, REQUEST=None): ...@@ -80,6 +82,20 @@ def getSearchDialog(self, REQUEST=None):
'local_sort_id="int_index")' % request_key)), 'local_sort_id="int_index")' % request_key)),
['title', 'items', 'default']) ['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): def addFloatField(field_id, field_title):
request_key = field_id request_key = field_id
...@@ -333,7 +349,8 @@ def getSearchDialog(self, REQUEST=None): ...@@ -333,7 +349,8 @@ def getSearchDialog(self, REQUEST=None):
field_id = field.getId() field_id = field.getId()
if field_id.endswith('search_key') or field_id.endswith('_usage_'): if field_id.endswith('search_key') or field_id.endswith('_usage_'):
temp_form.move_field_group([field_id], default_group, 'right') 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': or field_id == 'your_SearchableText':
temp_form.move_field_group([field_id], default_group, 'center') temp_form.move_field_group([field_id], default_group, 'center')
......
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