[FIX] website: enumarate page raise an exception if query_string is not null; Can't create a page with the modal link editor

This commit is contained in:
Christophe Matthieu 2014-07-10 14:30:15 +02:00
parent c2c0fdc916
commit 0effbe3ca6
2 changed files with 7 additions and 32 deletions

View File

@ -357,22 +357,24 @@ class website(osv.osv):
"""
router = request.httprequest.app.get_db_router(request.db)
# Force enumeration to be performed as public user
uid = request.website.user_id.id
url_list = []
for rule in router.iter_rules():
if not self.rule_is_enumerable(rule):
continue
converters = rule._converters or {}
if query_string and not converters and (query_string not in rule.build([{}], append_unknown=False)[1]):
continue
values = [{}]
convitems = converters.items()
# converters with a domain are processed after the other ones
gd = lambda x: hasattr(x[1], 'domain') and (x[1].domain <> '[]')
convitems.sort(lambda x, y: cmp(gd(x), gd(y)))
for (name, converter) in convitems:
for (i,(name, converter)) in enumerate(convitems):
newval = []
for val in values:
for v in converter.generate(request.cr, uid, query=query_string, args=val, context=context):
query = i==(len(convitems)-1) and query_string
for v in converter.generate(request.cr, uid, query=query, args=val, context=context):
newval.append( val.copy() )
v[name] = v['loc']
del v['loc']
@ -390,8 +392,7 @@ class website(osv.osv):
if url in url_list:
continue
url_list.append(url)
if query_string and not self.page_matches(cr, uid, page, query_string, context=context):
continue
yield page
def search_pages(self, cr, uid, ids, needle=None, limit=None, context=None):
@ -399,32 +400,6 @@ class website(osv.osv):
self.enumerate_pages(cr, uid, ids, query_string=needle, context=context),
limit))
def page_matches(self, cr, uid, page, needle, context=None):
""" Checks that a "page" matches a user-provide search string.
The default implementation attempts to perform a non-contiguous
substring match of the page's name.
:param page: {'name': str, 'url': str}
:param needle: str
:rtype: bool
"""
haystack = page['name'].lower()
needle = iter(needle.lower())
n = next(needle)
end = object()
for char in haystack:
if char != n: continue
n = next(needle, end)
# found all characters of needle in haystack in order
if n is end:
return True
return False
def kanban(self, cr, uid, ids, model, domain, column, template, step=None, scope=None, orderby=None, context=None):
step = step and int(step) or 10
scope = scope and int(scope) or 5

View File

@ -974,7 +974,7 @@
self.fetch_pages(q.term)
).then(function (exists, results) {
var rs = _.map(results, function (r) {
return { id: r.url, text: r.name, };
return { id: r.loc, text: r.loc, };
});
if (!exists) {
rs.push({