Added author nickname autocompletion
authorDmitriy Morozov <dmitriy@mrzv.org>
Wed, 25 Aug 2010 15:16:05 -0700
changeset 36 78a9c77198b2
parent 35 1055e4bef0e6
child 37 29436a74b91b
Added author nickname autocompletion
alexandria.py
--- a/alexandria.py	Mon May 31 19:53:56 2010 -0700
+++ b/alexandria.py	Wed Aug 25 15:16:05 2010 -0700
@@ -64,8 +64,17 @@
 def _complete_label(cfg, prefix, **opts):
     return [t.name for t in Tag.query.filter(Tag.name.startswith(unicode(prefix))).order_by(asc(Tag.name)).all()]
 
+def _complete_author(cfg, prefix, **opts):
+    nicknames = [an.name for an in AuthorNickname.query.filter(AuthorNickname.name.startswith(unicode(prefix)))]
+    # TODO: for now no authors, how do we deal with spaces in the names?
+    # authors =   [a.name  for a  in Author.query.filter(Author.name.startswith(unicode(prefix)))]
+    result = nicknames # + authors
+    result.sort()
+    return result
+
+
 laopts = [('l', 'label',  [], 'label of the document', _complete_label),
-          ('a', 'author', [], 'author of the document')]
+          ('a', 'author', [], 'author of the document', _complete_author)]
 
 latopts = laopts + [('t', 'title',  '', 'paper title')]