more logic in author autocomplete (#1012)

This commit is contained in:
Frédéric Péters 2011-11-28 15:09:58 +01:00
parent b3b959b7f5
commit b4b792781c
2 changed files with 9 additions and 4 deletions

View File

@ -78,9 +78,14 @@ class ListAuthorsView(BrowserView):
for object in self.deputies_folder.objectValues():
if object.portal_type != 'themis.datatypes.deputy':
continue
if q in normalizer.normalize(object.Title()).lower():
s.append(object)
s.sort()
re.split(r'[-\s]', 'hello-pol to')
for name_part in re.split(r'[-\s]', normalizer.normalize(object.Title()).lower()):
if name_part.startswith(q):
s.append(object)
def cmp_deputy(x, y):
return cmp(normalizer.normalize(x.Title()).lower(),
normalizer.normalize(y.Title()).lower())
s.sort(cmp_deputy)
return '\n'.join(['%s|%s' % (x.Title(), x.id) for x in s])
class ListPolgroupsView(BrowserView):

View File

@ -63,7 +63,7 @@ if(typeof(String.prototype.trim) === "undefined") {
(function($) {
$().ready(function() {
$('.author-autocomplete').each(sync_authors).autocomplete(PORTAL_URL+'/listAuthors', {
}).result(autocomplete_ready);
'matchContains': true, 'scroll': true, 'max': 30}).result(autocomplete_ready);
$('.polgroup-autocomplete').each(sync_polgroups).autocomplete(PORTAL_URL+'/listPolgroups', {
}).result(autocomplete_ready);
$('.topic-autocomplete').each(sync_topics).autocomplete(PORTAL_URL+'/listTopics', {