Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

added permanent redirect for old links

  • Loading branch information...
commit eb161bd32a1b1d5190b81e7d7ab10739a7c4ac44 1 parent 9d7f86e
@ialbert authored
4 main/server/
@@ -342,14 +342,14 @@ def redirect_post(request, pid):
nid = REMAP[pid]
post = models.Post.objects.get(id=nid)
- return html.redirect(post.get_absolute_url())
+ return html.redirect(post.get_absolute_url(), permanent=True)
except Exception, exc:
messages.error(request, "Unable to redirect: %s" % exc)
return html.redirect("/")
def redirect_tag(request, tag):
- return html.redirect("/show/tag/%s/" % tag)
+ return html.redirect("/show/tag/%s/" % tag, permanent=True)
except Exception, exc:
messages.error(request, "Unable to redirect: %s" % exc)
return html.redirect("/")
9 main/server/
@@ -4,7 +4,7 @@
import re, string, mimetypes, os, json, random, hashlib, unittest
from django.template import RequestContext, loader
from django.core.servers.basehttp import FileWrapper
-from django.http import HttpResponse, HttpResponseRedirect
+from django.http import HttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect
from django.shortcuts import render_to_response
from django.core.context_processors import csrf
from django.core.paginator import Paginator, InvalidPage, EmptyPage
@@ -174,9 +174,12 @@ def json_response(adict, **kwd):
"""Returns a http response in JSON format from a dictionary"""
return HttpResponse(json.dumps(adict), **kwd)
-def redirect(url):
+def redirect(url, permanent=False):
"Redirects to a url"
- return HttpResponseRedirect(url)
+ if permanent:
+ return HttpResponsePermanentRedirect(url)
+ else:
+ return HttpResponseRedirect(url)
def template(request, name, mimetype=None, **kwd):
"""Renders a template and returns it as an http response"""
2  main/server/templates/widgets/post.edit.actions.html
@@ -10,7 +10,7 @@
&bull; <input type="hidden" value="{{}}">
<a class="add-comment">comment</a>
{% else %}
- &bull; <a href="/openid/login/?next={{request.path}}"> log in to comment</a>
+ &bull; <a href="/openid/login/"> log in to comment</a>
{% endif %}
{% if post.has_revisions %}
1  main/
@@ -93,6 +93,7 @@
url(r'^note/clear/(?P<uid>\d+)/$','action.note_clear', name="note-clear"),
# redirecting to new post
+ url(r'^questions/(?P<pid>\d+)/$','action.redirect_post', name="redirect-short"),
url(r'^questions/(?P<pid>\d+)/([-\w]+)/$','action.redirect_post', name="redirect-post"),
url(r'^questions/tagged/(?P<tag>.+)/$','action.redirect_tag', name="redirect-tag"),
Please sign in to comment.
Something went wrong with that request. Please try again.