[gen] Bugfixes.

This commit is contained in:
Gaetan Delannay 2012-12-12 17:26:01 +01:00
parent ba5bc76548
commit 4db5e9d995
3 changed files with 17 additions and 13 deletions

View file

@ -295,9 +295,10 @@ class ToolMixin(BaseMixin):
If p_searchName is specified, it corresponds to: If p_searchName is specified, it corresponds to:
1) a search defined on p_className: additional search criteria 1) a search defined on p_className: additional search criteria
will be added to the query, or; will be added to the query, or;
2) "_advanced": in this case, additional search criteria will also 2) "customSearch": in this case, additional search criteria will
be added to the query, but those criteria come from the session also be added to the query, but those criteria come from the
(in key "searchCriteria") and were created from search.pt. session (in key "searchCriteria") and were created from
search.pt.
We will retrieve objects from p_startNumber. If p_search is defined, We will retrieve objects from p_startNumber. If p_search is defined,
it corresponds to a custom Search instance (instead of a predefined it corresponds to a custom Search instance (instead of a predefined
@ -386,8 +387,10 @@ class ToolMixin(BaseMixin):
# time a page for an element is consulted. # time a page for an element is consulted.
if remember: if remember:
if not searchName: if not searchName:
# It is the global search for all objects pf p_className if not search or (search.name == 'allSearch'):
searchName = className searchName = className
else:
searchName = search.name
uids = {} uids = {}
i = -1 i = -1
for obj in res.objects: for obj in res.objects:
@ -649,7 +652,7 @@ class ToolMixin(BaseMixin):
if refInfo: criteria['_ref'] = refInfo if refInfo: criteria['_ref'] = refInfo
rq.SESSION['searchCriteria'] = criteria rq.SESSION['searchCriteria'] = criteria
# Go to the screen that displays search results # Go to the screen that displays search results
backUrl = '%s/ui/query?className=%s&&search=_advanced' % \ backUrl = '%s/ui/query?className=%s&&search=customSearch' % \
(self.absolute_url(), rq['className']) (self.absolute_url(), rq['className'])
return self.goto(backUrl) return self.goto(backUrl)
@ -666,7 +669,7 @@ class ToolMixin(BaseMixin):
field, this method returns information about this reference: the field, this method returns information about this reference: the
source content type and the Ref field (Appy type). If p_refInfo is source content type and the Ref field (Appy type). If p_refInfo is
not given, we search it among search criteria in the session.''' not given, we search it among search criteria in the session.'''
if not refInfo and (self.REQUEST.get('search', None) == '_advanced'): if not refInfo and (self.REQUEST.get('search', None) == 'customSearch'):
criteria = self.REQUEST.SESSION.get('searchCriteria', None) criteria = self.REQUEST.SESSION.get('searchCriteria', None)
if criteria and criteria.has_key('_ref'): refInfo = criteria['_ref'] if criteria and criteria.has_key('_ref'): refInfo = criteria['_ref']
if not refInfo: return (None, None) if not refInfo: return (None, None)
@ -708,8 +711,8 @@ class ToolMixin(BaseMixin):
'''Gets the Search instance (or a SearchDescr instance if p_descr is '''Gets the Search instance (or a SearchDescr instance if p_descr is
True) corresponding to the search named p_name, on class True) corresponding to the search named p_name, on class
p_className.''' p_className.'''
if name == '_advanced': if name == 'customSearch':
# It is an advanced search whose parameters are in the session. # It is a custom search whose parameters are in the session.
fields = self.REQUEST.SESSION['searchCriteria'] fields = self.REQUEST.SESSION['searchCriteria']
res = Search('customSearch', **fields) res = Search('customSearch', **fields)
elif name: elif name:
@ -773,7 +776,7 @@ class ToolMixin(BaseMixin):
if not searchName: if not searchName:
# We search all objects of a given type. # We search all objects of a given type.
label = '%s_plural' % d1.split(':')[0] label = '%s_plural' % d1.split(':')[0]
elif searchName == '_advanced': elif searchName == 'customSearch':
# This is an advanced, custom search. # This is an advanced, custom search.
label = 'search_results' label = 'search_results'
else: else:

View file

@ -39,7 +39,7 @@
<p> <p>
<span tal:replace="searchDescr/translated"/> <span tal:replace="searchDescr/translated"/>
(<span tal:replace="totalNumber"/>) (<span tal:replace="totalNumber"/>)
<tal:newSearch condition="python: searchName == '_advanced'"> <tal:newSearch condition="python: searchName == 'customSearch'">
&nbsp;&mdash;&nbsp;<i><a tal:attributes="href newSearchUrl" &nbsp;&mdash;&nbsp;<i><a tal:attributes="href newSearchUrl"
tal:content="python: _('search_new')"></a></i> tal:content="python: _('search_new')"></a></i>
</tal:newSearch> </tal:newSearch>
@ -125,7 +125,7 @@
<tal:noResult condition="not: objs"> <tal:noResult condition="not: objs">
<span tal:replace="python: _('query_no_result')"/> <span tal:replace="python: _('query_no_result')"/>
<tal:newSearch condition="python: searchName == '_advanced'"> <tal:newSearch condition="python: searchName == 'customSearch'">
<br/><i class="discreet"><a tal:attributes="href newSearchUrl" <br/><i class="discreet"><a tal:attributes="href newSearchUrl"
tal:content="python: _('search_new')"></a></i> tal:content="python: _('search_new')"></a></i>
</tal:newSearch> </tal:newSearch>

View file

@ -38,5 +38,6 @@
<label tal:attributes="for widgetName" tal:content="python: _(widget['labelId'])"></label><br>&nbsp;&nbsp; <label tal:attributes="for widgetName" tal:content="python: _(widget['labelId'])"></label><br>&nbsp;&nbsp;
<input type="text" tal:define="maxChars python: test(widget['maxChars'], widget['maxChars'], '')" <input type="text" tal:define="maxChars python: test(widget['maxChars'], widget['maxChars'], '')"
tal:attributes="name python: '%s*string' % widgetName; tal:attributes="name python: '%s*string' % widgetName;
maxlength maxChars"/> maxlength maxChars;
value widget/defaultForSearch"/>
</metal:search> </metal:search>