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
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,
}
@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
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)):
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)