summaryrefslogtreecommitdiffstats
path: root/hyperkitty/views
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2013-06-19 18:28:04 +0200
committerAurélien Bompard <aurelien@bompard.org>2013-06-19 18:28:04 +0200
commit6ada7fb3f6842998e274d06900d353142992c622 (patch)
tree183ced94d8f30f007b2672de0fc1e5133d51c945 /hyperkitty/views
parent72f2e6b28475b4615f4c3fabc3b5788b441a3c55 (diff)
downloadhyperkitty-6ada7fb3f6842998e274d06900d353142992c622.tar.gz
hyperkitty-6ada7fb3f6842998e274d06900d353142992c622.tar.xz
hyperkitty-6ada7fb3f6842998e274d06900d353142992c622.zip
Add an autocomplete widget on the add_tag box
Diffstat (limited to 'hyperkitty/views')
-rw-r--r--hyperkitty/views/thread.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py
index fa1b860..56f9f5c 100644
--- a/hyperkitty/views/thread.py
+++ b/hyperkitty/views/thread.py
@@ -245,6 +245,18 @@ def tags(request, mlist_fqdn, threadid):
return HttpResponse(json.dumps(response),
mimetype='application/javascript')
+def suggest_tags(request, mlist_fqdn, threadid):
+ term = request.GET.get("term")
+ current_tags = Tag.objects.filter(
+ list_address=mlist_fqdn, threadid=threadid
+ ).values_list("tag", flat=True)
+ if term:
+ tags = Tag.objects.filter(list_address=mlist_fqdn, tag__istartswith=term)
+ else:
+ tags = Tag.objects.all()
+ tags = tags.exclude(tag__in=current_tags).values_list("tag", flat=True)
+ tags = [ t.encode("utf8") for t in tags ]
+ return HttpResponse(json.dumps(tags), mimetype='application/javascript')
def favorite(request, mlist_fqdn, threadid):