X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/47bc0543a1d3f25ec90311883b4e28186a3ddd7e..de61afcbf3b458518c743b6f3db8767701b04129:/forum/views/readers.py diff --git a/forum/views/readers.py b/forum/views/readers.py index 5f58344..385a4be 100644 --- a/forum/views/readers.py +++ b/forum/views/readers.py @@ -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 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 @@ -96,7 +96,7 @@ def question_list(request, initial, list_description=_('questions'), sort=None, 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, } @@ -120,8 +120,8 @@ def search(request): @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 @@ -200,7 +200,7 @@ def update_question_view_times(request, question): 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)): @@ -210,20 +210,16 @@ def match_question_slug(slug): 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: - return HttpResponseRedirect(question.get_absolute_url()) + return HttpResponsePermanentRedirect(question.get_absolute_url()) 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)