Commit f860a113 authored by Aurel's avatar Aurel

search dialog : implement exclusion of selected category in dialog

parent 0275ae43
......@@ -195,6 +195,178 @@ commands from selenium 0.8\n
<td>0 records</td>\n
</tr>\n
\n
<!-- test selection and exclusion of category -->\n
<tr>\n
\t<td>clickAndWait</td>\n
\t<td>name=Folder_show:method</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>//a[@title=\'Find\']</td>\n
<td></td>\n
</tr>\n
<tr>\n
\t<td>addSelection</td>\n
\t<td>name=field_your_foo_category_relative_url</td>\n
\t<td>label=a</td>\n
</tr>\n
<tr>\n
\t<td>clickAndWait</td>\n
\t<td>id=dialog_submit_button</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
<td>verifyText</td>\n
<td>//span[@class="listbox-current-page-total-number"]</td>\n
<td>0 records</td>\n
</tr>\n
\n
\n
<tr>\n
<td>clickAndWait</td>\n
<td>//a[@title=\'Find\']</td>\n
<td></td>\n
</tr>\n
<tr>\n
\t<td>click</td>\n
\t<td>name=field_your_foo_category_relative_url_is_excluded_</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
\t<td>clickAndWait</td>\n
\t<td>id=dialog_submit_button</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
<td>verifyText</td>\n
<td>//span[@class="listbox-current-page-total-number"]</td>\n
<td>2 records</td>\n
</tr>\n
\n
\n
<tr>\n
<td>clickAndWait</td>\n
<td>//a[@title=\'Find\']</td>\n
<td></td>\n
</tr>\n
<tr>\n
\t<td>removeSelection</td>\n
\t<td>name=field_your_foo_category_relative_url</td>\n
\t<td>label=a</td>\n
</tr>\n
<tr>\n
\t<td>addSelection</td>\n
\t<td>name=field_your_foo_category_relative_url</td>\n
\t<td>label=b</td>\n
</tr>\n
<tr>\n
\t<td>clickAndWait</td>\n
\t<td>id=dialog_submit_button</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
<td>verifyText</td>\n
<td>//span[@class="listbox-current-page-total-number"]</td>\n
<td>1 records</td>\n
</tr>\n
\n
\n
\n
<tr>\n
<td>clickAndWait</td>\n
<td>//a[@title=\'Find\']</td>\n
<td></td>\n
</tr>\n
<tr>\n
\t<td>click</td>\n
\t<td>name=field_your_foo_category_relative_url_is_excluded_</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
\t<td>clickAndWait</td>\n
\t<td>id=dialog_submit_button</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
<td>verifyText</td>\n
<td>//span[@class="listbox-current-page-total-number"]</td>\n
<td>1 records</td>\n
</tr>\n
\n
\n
<tr>\n
<td>clickAndWait</td>\n
<td>//a[@title=\'Find\']</td>\n
<td></td>\n
</tr>\n
<tr>\n
\t<td>addSelection</td>\n
\t<td>name=field_your_foo_category_relative_url</td>\n
\t<td>label=a</td>\n
</tr>\n
<tr>\n
\t<td>removeSelection</td>\n
\t<td>name=field_your_foo_category_relative_url</td>\n
\t<td>label=b</td>\n
</tr>\n
<tr>\n
\t<td>addSelection</td>\n
\t<td>name=field_your_foo_category_relative_url</td>\n
\t<td>label=b</td>\n
</tr>\n
<tr>\n
\t<td>click</td>\n
\t<td>name=field_your_foo_category_relative_url_is_excluded_</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
\t<td>clickAndWait</td>\n
\t<td>id=dialog_submit_button</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
<td>verifyText</td>\n
<td>//span[@class="listbox-current-page-total-number"]</td>\n
<td>1 records</td>\n
</tr>\n
<tr>\n
\t<td>clickAndWait</td>\n
\t<td>name=Folder_show:method</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>//a[@title=\'Find\']</td>\n
<td></td>\n
</tr>\n
<tr>\n
\t<td>addSelection</td>\n
\t<td>name=field_your_foo_category_relative_url</td>\n
\t<td>label=a</td>\n
</tr>\n
<tr>\n
\t<td>type</td>\n
\t<td>name=field_your_title</td>\n
\t<td>Title 1</td>\n
</tr>\n
<tr>\n
\t<td>click</td>\n
\t<td>name=field_your_foo_category_relative_url_is_excluded_</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
\t<td>clickAndWait</td>\n
\t<td>id=dialog_submit_button</td>\n
\t<td></td>\n
</tr>\n
<tr>\n
<td>verifyText</td>\n
<td>//span[@class="listbox-current-page-total-number"]</td>\n
<td>1 records</td>\n
</tr>\n
\n
\n
</body>\n
</html>
......
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
......
......@@ -327,6 +327,10 @@
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>anchor</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>columns</string> </key>
<value>
......@@ -343,6 +347,10 @@
<string>quantity</string>
<string>Quantity</string>
</tuple>
<tuple>
<string>foo_category_title</string>
<string>Foo</string>
</tuple>
</list>
</value>
</item>
......@@ -360,6 +368,10 @@
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default_display_style</string> </key>
<value> <string>table</string> </value>
</item>
<item>
<key> <string>default_params</string> </key>
<value>
......@@ -370,6 +382,12 @@
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_style_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>domain_root_list</string> </key>
<value>
......@@ -404,10 +422,18 @@
<list/>
</value>
</item>
<item>
<key> <string>global_search_column</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>hide_rows_on_no_search_criterion</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>lines</string> </key>
<value> <int>3</int> </value>
......@@ -428,6 +454,14 @@
<list/>
</value>
</item>
<item>
<key> <string>page_navigation_template</string> </key>
<value> <string>ListBox_viewSliderPageNavigationRenderer</string> </value>
</item>
<item>
<key> <string>page_template</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>portal_types</string> </key>
<value>
......@@ -453,6 +487,10 @@
<key> <string>report_tree</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>row_css_method</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>search</string> </key>
<value> <int>1</int> </value>
......@@ -498,10 +536,22 @@
<key> <string>stat_method</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>style_columns</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Foos and Bars</string> </value>
</item>
<item>
<key> <string>untranslatable_columns</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>url_columns</string> </key>
<value>
......@@ -516,13 +566,7 @@
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.MethodField</string>
<string>Method</string>
</tuple>
<none/>
</tuple>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
<pickle>
<dictionary>
......@@ -535,13 +579,7 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.MethodField</string>
<string>Method</string>
</tuple>
<none/>
</tuple>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
<pickle>
<dictionary>
......
......@@ -54,6 +54,8 @@
request = container.REQUEST\n
\n
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery, ComplexQuery\n
\n
def sorted(seq):\n
seq = [x for x in seq]\n
seq.sort()\n
......@@ -73,10 +75,11 @@ usage_map = dict(min=\'>=\',\n
nlt=\'>\',)\n
\n
new_mapping = dict(ignore_hide_rows=1)\n
query_list = []\n
left_join_list = []\n
for key in sorted(request.form.keys()):\n
# we use sorted to make sure x_search_key appears before x\n
value = request.form[key]\n
\n
# to remove unnecessary None value\n
if value is None:\n
request.form.pop(key)\n
......@@ -105,11 +108,28 @@ for key in sorted(request.form.keys()):\n
# we\'ll simply keep the query.\n
new_mapping[real_key] = \'%s %s\' % (usage_map[value], new_mapping[real_key])\n
\n
else:\n
if request.form.get(\'%s_is_excluded_\' % key):\n
# Build a negated query\n
nq_kw = {\'strict_%s\' % key : value}\n
q_kw = {key : None}\n
left_join_list.append(key) \n
left_join_list.append(\'strict_%s\' % key)\n
query_list.append(ComplexQuery(NegatedQuery(Query(**nq_kw)), Query(**q_kw), operator="OR"))\n
new_mapping[key] = ""\n
new_mapping["dialog_%s" %(key,)] = value\n
new_mapping["dialog_excluded_%s" %(key,)] = True\n
else:\n
if request.form.get(\'%s_is_strict_\' % key):\n
new_mapping[\'strict_%s\' % key] = value\n
new_mapping[\'dialog_strict_%s\' % key] = value\n
else:\n
new_mapping[key] = value\n
new_mapping[\'dialog_%s\' % key] = value\n
\n
\n
new_mapping["query"] = ComplexQuery(query_list)\n
new_mapping[\'left_join_list\'] = left_join_list\n
\n
# set selection parameters\n
container.portal_selections.setSelectionParamsFor(selection_name, new_mapping)\n
......
#############################################################################
############################################################################
#
# Copyright (c) 2007 Nexedi SA and Contributors. All Rights Reserved.
# Jerome Perrin <jerome@nexedi.com>
......@@ -70,8 +70,8 @@ def getSearchDialog(self, REQUEST=None):
field._surcharged_tales(
dict(
default=TALESMethod(
'here/portal_selections/%s/%s_relative_url | '
'here/portal_selections/%s/strict_%s_relative_url | nothing'
'here/portal_selections/%s/dialog_%s_relative_url | '
'here/portal_selections/%s/dialog_strict_%s_relative_url | nothing'
% (selection_name, request_key,
selection_name, request_key)),
items=TALESMethod('python: getattr(here.portal_categories["%s"],'
......@@ -94,10 +94,28 @@ def getSearchDialog(self, REQUEST=None):
field._surcharged_tales(
dict(
default=TALESMethod(
'here/portal_selections/%s/strict_%s_relative_url | nothing'
'here/portal_selections/%s/dialog_strict_%s_relative_url | nothing'
% (selection_name, request_key,))),
['title', 'default'])
field_id = 'your_%s_relative_url_is_excluded_' % request_key
if field_id not in temp_form.objectIds():
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 Excluded' % field_title), ['title'])
from zLOG import LOG
LOG("selection_name %r, request_key %r" %(selection_name, request_key), 300, field_id)
field._surcharged_tales(
dict(
default=TALESMethod(
'here/portal_selections/%s/dialog_excluded_%s_relative_url | nothing'
% (selection_name, request_key,))),
['title', 'default'])
def addFloatField(field_id, field_title):
request_key = field_id
......
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