]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/exporter/mappings.py
add a new after_head_js block (immediately after the <head> tag), allows to add track...
[osqa.git] / forum_modules / exporter / mappings.py
1 from django.http import HttpResponseRedirect, HttpResponse, Http404, HttpResponsePermanentRedirect
2 from django.template.defaultfilters import slugify
3
4 from forum.views import readers
5 from forum.modules import decorate
6 from forum.models import Question
7
8 import settings, logging
9
10 @decorate(readers.question, needs_origin=True)
11 def match_question_slug(origin, request, id, slug='', answer=None):
12     try:
13         id = int(id)
14     except:
15         raise Http404()
16
17     if settings.MERGE_MAPPINGS and (int(id) in settings.MERGE_MAPPINGS.get('merged_nodes', {})):
18         try:
19             question = Question.objects.get(id=id)
20
21             if slug != slugify(question.title):
22                 return origin(request, settings.MERGE_MAPPINGS['merged_nodes'][int(id)], slug, answer)
23
24         except:
25             pass
26
27     return origin(request, id, slug, answer)