]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/readers.py
Fix OSQA 269, User messages in new admin don't seem to link properly.
[osqa.git] / forum / views / readers.py
index 3efb554544ce8c3bbf2706064931c24017872464..a48c35b19041b94e7ecf2932dc1fae3ddbae18c7 100644 (file)
@@ -97,7 +97,7 @@ def question_list(request, initial, list_description=_('questions'), sort=None,
 
     answer_count = Answer.objects.filter(deleted=None, parent__in=questions).count()   
     answer_description = _("answers")
 
     answer_count = Answer.objects.filter(deleted=None, parent__in=questions).count()   
     answer_description = _("answers")
-    
+
     return {
         "questions" : questions,
         "questions_count" : questions.count(),
     return {
         "questions" : questions,
         "questions_count" : questions.count(),
@@ -108,6 +108,7 @@ def question_list(request, initial, list_description=_('questions'), sort=None,
         "answer_description": answer_description,
         "base_path" : base_path,
         "page_title" : page_title,
         "answer_description": answer_description,
         "base_path" : base_path,
         "page_title" : page_title,
+        "tab" : "questions",
         }
 
 
         }
 
 
@@ -127,13 +128,9 @@ def search(request):
     else:
         return render_to_response("search.html", context_instance=RequestContext(request))
 
     else:
         return render_to_response("search.html", context_instance=RequestContext(request))
 
-@decoratable
-def do_question_search(keywords):
-    return Question.objects.filter(Q(title__icontains=keywords) | Q(body__icontains=keywords))
-
 @decorators.render('questions.html')
 def question_search(request, keywords):
 @decorators.render('questions.html')
 def question_search(request, keywords):
-    initial = do_question_search(keywords)
+    initial = Question.objects.search(keywords)
 
     return question_list(request, initial, _("questions matching '%(keywords)s'") % {'keywords': keywords},
             base_path="%s?t=question&q=%s" % (reverse('search'), django_urlquote(keywords)), sort=False)
 
     return question_list(request, initial, _("questions matching '%(keywords)s'") % {'keywords': keywords},
             base_path="%s?t=question&q=%s" % (reverse('search'), django_urlquote(keywords)), sort=False)
@@ -234,7 +231,11 @@ def question(request, id, slug):
     if question.deleted and not request.user.can_view_deleted_post(question):
         raise Http404
 
     if question.deleted and not request.user.can_view_deleted_post(question):
         raise Http404
 
-    answer_form = AnswerForm(question)
+    if request.POST:
+        answer_form = AnswerForm(question, request.POST)
+    else:
+        answer_form = AnswerForm(question)
+
     answers = request.user.get_visible_answers(question)
 
     if answers is not None:
     answers = request.user.get_visible_answers(question)
 
     if answers is not None: