[gen] Minor updates.

This commit is contained in:
Gaetan Delannay 2013-04-09 10:57:21 +02:00
parent 2869d0382f
commit 1d2a19a1c6
2 changed files with 21 additions and 7 deletions

View file

@ -288,7 +288,14 @@ class ToolMixin(BaseMixin):
'''Gets, for the currently logged user, the value for index
"Allowed".'''
user = self.getUser()
res = ['user:%s' % user.getId(), 'Anonymous'] + user.getRoles()
# Get the user roles
res = user.getRoles()
# Add role "Anonymous"
if 'Anonymous' not in res: res.append('Anonymous')
# Add the user id if not anonymous
userId = user.getId()
if userId: res.append('user:%s' % userId)
# Add group ids
try:
res += ['user:%s' % g for g in user.groups.keys()]
except AttributeError, ae:
@ -602,9 +609,9 @@ class ToolMixin(BaseMixin):
transformMethods = {'uppercase': 'upper', 'lowercase': 'lower',
'capitalize': 'capitalize'}
def onSearchObjects(self):
'''This method is called when the user triggers a search from
search.pt.'''
def storeSearchCriteria(self):
'''Stores the search criteria coming from the request into the
session.'''
rq = self.REQUEST
# Store the search criteria in the session
criteria = self._getDefaultSearchCriteria()
@ -665,6 +672,12 @@ class ToolMixin(BaseMixin):
refInfo = rq.get('ref', None)
if refInfo: criteria['_ref'] = refInfo
rq.SESSION['searchCriteria'] = criteria
def onSearchObjects(self):
'''This method is called when the user triggers a search from
search.pt.'''
rq = self.REQUEST
self.storeSearchCriteria()
# Go to the screen that displays search results
backUrl = '%s/ui/query?className=%s&&search=customSearch' % \
(self.absolute_url(), rq['className'])

View file

@ -109,7 +109,8 @@
navBaseCall python: 'askQueryResult(\'%s\',\'%s\',\'%s\',\'%s\',**v**)' % (ajaxHookId, tool.absolute_url(), className, searchName);
newSearchUrl python: '%s/ui/search?className=%s%s' % (tool.absolute_url(), className, refUrlPart);
showSubTitles python: request.get('showSubTitles', 'true') == 'true';
resultMode python: tool.getResultMode(className)">
resultMode python: tool.getResultMode(className);
showNewSearch showNewSearch|python:True">
<tal:result condition="objs">
<tal:comment replace="nothing">Display here POD templates if required.</tal:comment>
@ -128,7 +129,7 @@
<p>
<span tal:replace="searchDescr/translated"/>
(<span tal:replace="totalNumber"/>)
<tal:newSearch condition="python: searchName == 'customSearch'">
<tal:newSearch condition="python: showNewSearch and (searchName == 'customSearch')">
&nbsp;&mdash;&nbsp;<i><a tal:attributes="href newSearchUrl"
tal:content="python: _('search_new')"></a></i>
</tal:newSearch>
@ -164,7 +165,7 @@
<tal:noResult condition="not: objs">
<span tal:replace="python: _('query_no_result')"/>
<tal:newSearch condition="python: searchName == 'customSearch'">
<tal:newSearch condition="python: showNewSearch and (searchName == 'customSearch')">
<br/><i class="discreet"><a tal:attributes="href newSearchUrl"
tal:content="python: _('search_new')"></a></i>
</tal:newSearch>