]> git.openstreetmap.org Git - osqa.git/commitdiff
Relaxes the question url a bit, but issues redirects to the correct url.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 8 Jul 2010 14:19:44 +0000 (14:19 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 8 Jul 2010 14:19:44 +0000 (14:19 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@502 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/urls.py
forum/views/readers.py

index 92c0d6bf6a18f1347d9af9c656fb49b4d1aeae48..5f3fbc5ebe857c460e30b999676990b80d33ddd7 100644 (file)
@@ -93,6 +93,7 @@ urlpatterns += patterns('',
 
                         url(r'^%s(?P<id>\d+)/(?P<slug>[\w-]*)$' % _('question/'),
                             'django.views.generic.simple.redirect_to', {'url': '/questions/%(id)s/%(slug)s'}),
 
                         url(r'^%s(?P<id>\d+)/(?P<slug>[\w-]*)$' % _('question/'),
                             'django.views.generic.simple.redirect_to', {'url': '/questions/%(id)s/%(slug)s'}),
+                        url(r'^%s(?P<id>\d+)/?$' % _('questions/'), app.readers.question, name='question'),
                         url(r'^%s(?P<id>\d+)/(?P<slug>[\w-]*)$' % _('questions/'), app.readers.question, name='question'),
                         url(r'^%s(?P<id>\d+)/(?P<slug>[\w-]*)/(?P<answer>\d+)$' % _('questions/'), app.readers.question),
 
                         url(r'^%s(?P<id>\d+)/(?P<slug>[\w-]*)$' % _('questions/'), app.readers.question, name='question'),
                         url(r'^%s(?P<id>\d+)/(?P<slug>[\w-]*)/(?P<answer>\d+)$' % _('questions/'), app.readers.question),
 
index 69ef208a2e9119f703d0ab1d5774fa5277682b10..da881d78ec28dc240d816c7c23bf019aab63053e 100644 (file)
@@ -280,7 +280,7 @@ def answer_redirect(request, answer):
         answer.question.get_absolute_url(), _('page'), page, answer.id))
 
 @decorators.render("question.html", 'questions')
         answer.question.get_absolute_url(), _('page'), page, answer.id))
 
 @decorators.render("question.html", 'questions')
-def question(request, id, slug, answer=None):
+def question(request, id, slug=None, answer=None):
     try:
         question = Question.objects.get(id=id)
     except:
     try:
         question = Question.objects.get(id=id)
     except:
@@ -305,6 +305,9 @@ def question(request, id, slug, answer=None):
 
         return answer_redirect(request, answer)
 
 
         return answer_redirect(request, answer)
 
+    if (not slug) or (slug != urlquote(slugify(question.title))):
+        return HttpResponsePermanentRedirect(question.get_absolute_url())
+
     if request.POST:
         answer_form = AnswerForm(question, request.POST)
     else:
     if request.POST:
         answer_form = AnswerForm(question, request.POST)
     else: