[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:
parent
c2c0fdc916
commit
0effbe3ca6
|
@ -357,22 +357,24 @@ class website(osv.osv):
|
||||||
"""
|
"""
|
||||||
router = request.httprequest.app.get_db_router(request.db)
|
router = request.httprequest.app.get_db_router(request.db)
|
||||||
# Force enumeration to be performed as public user
|
# Force enumeration to be performed as public user
|
||||||
uid = request.website.user_id.id
|
|
||||||
url_list = []
|
url_list = []
|
||||||
for rule in router.iter_rules():
|
for rule in router.iter_rules():
|
||||||
if not self.rule_is_enumerable(rule):
|
if not self.rule_is_enumerable(rule):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
converters = rule._converters or {}
|
converters = rule._converters or {}
|
||||||
|
if query_string and not converters and (query_string not in rule.build([{}], append_unknown=False)[1]):
|
||||||
|
continue
|
||||||
values = [{}]
|
values = [{}]
|
||||||
convitems = converters.items()
|
convitems = converters.items()
|
||||||
# converters with a domain are processed after the other ones
|
# converters with a domain are processed after the other ones
|
||||||
gd = lambda x: hasattr(x[1], 'domain') and (x[1].domain <> '[]')
|
gd = lambda x: hasattr(x[1], 'domain') and (x[1].domain <> '[]')
|
||||||
convitems.sort(lambda x, y: cmp(gd(x), gd(y)))
|
convitems.sort(lambda x, y: cmp(gd(x), gd(y)))
|
||||||
for (name, converter) in convitems:
|
for (i,(name, converter)) in enumerate(convitems):
|
||||||
newval = []
|
newval = []
|
||||||
for val in values:
|
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() )
|
newval.append( val.copy() )
|
||||||
v[name] = v['loc']
|
v[name] = v['loc']
|
||||||
del v['loc']
|
del v['loc']
|
||||||
|
@ -390,8 +392,7 @@ class website(osv.osv):
|
||||||
if url in url_list:
|
if url in url_list:
|
||||||
continue
|
continue
|
||||||
url_list.append(url)
|
url_list.append(url)
|
||||||
if query_string and not self.page_matches(cr, uid, page, query_string, context=context):
|
|
||||||
continue
|
|
||||||
yield page
|
yield page
|
||||||
|
|
||||||
def search_pages(self, cr, uid, ids, needle=None, limit=None, context=None):
|
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),
|
self.enumerate_pages(cr, uid, ids, query_string=needle, context=context),
|
||||||
limit))
|
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):
|
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
|
step = step and int(step) or 10
|
||||||
scope = scope and int(scope) or 5
|
scope = scope and int(scope) or 5
|
||||||
|
|
|
@ -974,7 +974,7 @@
|
||||||
self.fetch_pages(q.term)
|
self.fetch_pages(q.term)
|
||||||
).then(function (exists, results) {
|
).then(function (exists, results) {
|
||||||
var rs = _.map(results, function (r) {
|
var rs = _.map(results, function (r) {
|
||||||
return { id: r.url, text: r.name, };
|
return { id: r.loc, text: r.loc, };
|
||||||
});
|
});
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
rs.push({
|
rs.push({
|
||||||
|
|
Loading…
Reference in New Issue