62 |
62 |
63 # cfg because of the middleware |
63 # cfg because of the middleware |
64 def _complete_label(cfg, prefix, **opts): |
64 def _complete_label(cfg, prefix, **opts): |
65 return [t.name for t in Tag.query.filter(Tag.name.startswith(unicode(prefix))).order_by(asc(Tag.name)).all()] |
65 return [t.name for t in Tag.query.filter(Tag.name.startswith(unicode(prefix))).order_by(asc(Tag.name)).all()] |
66 |
66 |
|
67 def _complete_author(cfg, prefix, **opts): |
|
68 nicknames = [an.name for an in AuthorNickname.query.filter(AuthorNickname.name.startswith(unicode(prefix)))] |
|
69 # TODO: for now no authors, how do we deal with spaces in the names? |
|
70 # authors = [a.name for a in Author.query.filter(Author.name.startswith(unicode(prefix)))] |
|
71 result = nicknames # + authors |
|
72 result.sort() |
|
73 return result |
|
74 |
|
75 |
67 laopts = [('l', 'label', [], 'label of the document', _complete_label), |
76 laopts = [('l', 'label', [], 'label of the document', _complete_label), |
68 ('a', 'author', [], 'author of the document')] |
77 ('a', 'author', [], 'author of the document', _complete_author)] |
69 |
78 |
70 latopts = laopts + [('t', 'title', '', 'paper title')] |
79 latopts = laopts + [('t', 'title', '', 'paper title')] |
71 |
80 |
72 dbopts = [('D', 'database', '', 'directory with the database')] |
81 dbopts = [('D', 'database', '', 'directory with the database')] |
73 |
82 |