]> git.openstreetmap.org Git - osqa.git/commitdiff
Makes related questions search work with weighted results.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 4 May 2011 17:55:13 +0000 (17:55 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 4 May 2011 17:55:13 +0000 (17:55 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1021 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/views/commands.py

index 0b5412686d2ae558961d2d859fc49bc06c4c8176..f34619a4c1437db21f4597b2f40cb5524daf758e 100644 (file)
@@ -534,6 +534,10 @@ def matching_users(request):
 def related_questions(request):
     if request.POST and request.POST.get('title', None):
         can_rank, questions = Question.objects.search(request.POST['title'])
+
+        if can_rank and isinstance(can_rank, basestring):
+            questions = questions.order_by(can_rank)
+
         return HttpResponse(simplejson.dumps(
                 [dict(title=q.title, url=q.get_absolute_url(), score=q.score, summary=q.summary)
                  for q in questions.filter_state(deleted=False)[0:10]]), mimetype="application/json")