From 6728b8cbaa29f39aa6669b9f86f9d5a76d0a4aa2 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 14 Feb 2012 14:37:47 +0530 Subject: [PATCH] redirect old pad.ma find urls --- pandora/urlalias/views.py | 31 ++++++++++++++++++++++++++++++- pandora/urls.py | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/pandora/urlalias/views.py b/pandora/urlalias/views.py index 2b194d67..b6c0f161 100644 --- a/pandora/urlalias/views.py +++ b/pandora/urlalias/views.py @@ -1,8 +1,37 @@ # Create your views here. from django.shortcuts import get_object_or_404, redirect +from urllib import quote import models +def padma_find(request): + url = '/' + l = request.GET.get('l', None) + q = request.GET.get('q', None) + f = request.GET.get('f', '') + s = request.GET.get('s', None) + v = request.GET.get('v', None) + if l: + alias = get_object_or_404(models.ListAlias, old=l) + if alias: + url = '/list=%s' % alias.new + if f: + f = { + 'transcript': 'transcripts', + 'location': 'places', + 'description': 'descriptions', + 'keyword': 'keywords', + }.get(f, f) + if v != 'map': + v = 'grid' + if q: + url = '/%s=%s' % (f, quote(q)) + if s: + url = '/%s%s' % (s, url) + if url != '/': + url = '/%s%s' % (v, url) + return redirect(url, permanent=True) + def padma_video(request, url): url = url.split('/') hid = url[0] @@ -27,5 +56,5 @@ def padma_video(request, url): }.get(view, view) #FIXME: reqrite layer urls #FIXME: rewrite timerange urls - return redirect(url) + return redirect(url, permanent=True) diff --git a/pandora/urls.py b/pandora/urls.py index ad2b3c12..31c7c795 100644 --- a/pandora/urls.py +++ b/pandora/urls.py @@ -47,6 +47,7 @@ urlpatterns += patterns('', urlpatterns += patterns('', (r'^(V[a-z0-9]*)$', 'urlalias.views.padma_video'), (r'^(V[a-z0-9]*/.*)$', 'urlalias.views.padma_video'), + (r'^find$', 'urlalias.views.padma_find'), ) urlpatterns += patterns('', (r'^(?P[A-Z0-9].*)/embed', 'app.views.embed'),