]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/readers.py
Some other user private stuff was not being properly checked.
[osqa.git] / forum / views / readers.py
index 5f583444e2d80e44505df9413cd559ddbe1b4943..385a4bee2c7e15b4aa0bedafceb7a80c50ae953e 100644 (file)
@@ -4,7 +4,7 @@ import logging
 from urllib import unquote
 from django.conf import settings as django_settings
 from django.shortcuts import render_to_response, get_object_or_404
 from urllib import unquote
 from django.conf import settings as django_settings
 from django.shortcuts import render_to_response, get_object_or_404
-from django.http import HttpResponseRedirect, HttpResponse, HttpResponseForbidden, Http404
+from django.http import HttpResponseRedirect, HttpResponse, HttpResponseForbidden, Http404, HttpResponsePermanentRedirect
 from django.core.paginator import Paginator, EmptyPage, InvalidPage
 from django.template import RequestContext
 from django import template
 from django.core.paginator import Paginator, EmptyPage, InvalidPage
 from django.template import RequestContext
 from django import template
@@ -96,7 +96,7 @@ def question_list(request, initial, list_description=_('questions'), sort=None,
     return {
         "questions" : questions,
         "questions_count" : questions.count(),
     return {
         "questions" : questions,
         "questions_count" : questions.count(),
-        "tags_autocomplete" : _get_tags_cache_json(),
+        #"tags_autocomplete" : _get_tags_cache_json(),
         "list_description": list_description,
         "base_path" : base_path,
         }
         "list_description": list_description,
         "base_path" : base_path,
         }
@@ -120,8 +120,8 @@ def search(request):
 
 @decorators.render('questions.html')
 def question_search(request, keywords):
 
 @decorators.render('questions.html')
 def question_search(request, keywords):
-    def question_search(keywords, orderby):
-        return Question.objects.filter(Q(title__icontains=keywords) | Q(html__icontains=keywords))
+    def question_search(keywords):
+        return Question.objects.filter(Q(title__icontains=keywords) | Q(body__icontains=keywords))
 
     from forum.modules import get_handler
 
 
     from forum.modules import get_handler
 
@@ -200,7 +200,7 @@ def update_question_view_times(request, question):
 
 def match_question_slug(slug):
     slug_words = slug.split('-')
 
 def match_question_slug(slug):
     slug_words = slug.split('-')
-    qs = Question.objects.filter(title__istartswith=slug_words[0])
+    qs = Question.objects.filter(node_type="question", title__istartswith=slug_words[0])
 
     for q in qs:
         if slug == urlquote(slugify(q.title)):
 
     for q in qs:
         if slug == urlquote(slugify(q.title)):
@@ -210,20 +210,16 @@ def match_question_slug(slug):
 
 def question(request, id, slug):
     try:
 
 def question(request, id, slug):
     try:
-        question = Question.objects.get(id=id)
+        question = Question.objects.get(node_type="question", id=id)
     except:
         question = match_question_slug(slug)
         if question is not None:
     except:
         question = match_question_slug(slug)
         if question is not None:
-            return HttpResponseRedirect(question.get_absolute_url())
+            return HttpResponsePermanentRedirect(question.get_absolute_url())
         else:
             raise Http404()
 
     if slug != urlquote(slugify(question.title)):
         else:
             raise Http404()
 
     if slug != urlquote(slugify(question.title)):
-        match = match_question_slug(slug)
-        if match is not None:
-            return HttpResponseRedirect(match.get_absolute_url())    
-
-        return HttpResponseRedirect(question.get_absolute_url())
+        return HttpResponsePermanentRedirect(question.get_absolute_url())
 
     page = int(request.GET.get('page', 1))
     view_id, order_by = get_answer_sort_order(request)
 
     page = int(request.GET.get('page', 1))
     view_id, order_by = get_answer_sort_order(request)