]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/commands.py
OSQA-140:
[osqa.git] / forum / views / commands.py
index b12991137d7c9f65d8e6fc1aed1af3778a601433..a55ac5670b01936639878ed9300f85aea562a1dd 100644 (file)
@@ -43,7 +43,7 @@ class AnonymousNotAllowedException(Exception):
 
 class NotEnoughLeftException(Exception):
     def __init__(self, action, limit):
-        super(NotEnoughRepPointsException, self).__init__(
+        super(NotEnoughLeftException, self).__init__(
             _("""
             Sorry, but you don't have enough %(action)s left for today..<br />
             The limit is %(limit)s per day..<br />
@@ -239,6 +239,9 @@ def comment(request, id):
     if not len(comment_text):
         raise Exception(_("Comment is empty"))
 
+    if not len(comment_text) > settings.FORM_MIN_COMMENT_BODY:
+        raise Exception(_("Comment must be at least %s characters" % settings.FORM_MIN_COMMENT_BODY))
+
     comment.create_revision(user, body=comment_text)
 
     if comment.active_revision.revision == 1:
@@ -346,6 +349,17 @@ def mark_tag(request, tag=None, **kwargs):#tagging system
             ts.update(reason=reason)
     return HttpResponse(simplejson.dumps(''), mimetype="application/json")
 
+def matching_tags(request):
+    if len(request.GET['q']) == 0:
+       raise Exception(_("Invalid request"))
+
+    possible_tags = Tag.objects.filter(name__istartswith = request.GET['q'])
+    tag_output = ''
+    for tag in possible_tags:
+        tag_output += (tag.name + "|" + tag.name + "." + tag.used_count.__str__() + "\n")
+        
+    return HttpResponse(tag_output, mimetype="text/plain")
+
 @ajax_login_required
 def ajax_toggle_ignored_questions(request):#ajax tagging and tag-filtering system
     if request.user.hide_ignored_questions: