redirect old pad.ma find urls
This commit is contained in:
parent
fbd401f09c
commit
6728b8cbaa
2 changed files with 31 additions and 1 deletions
|
@ -1,8 +1,37 @@
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
|
from urllib import quote
|
||||||
|
|
||||||
import models
|
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):
|
def padma_video(request, url):
|
||||||
url = url.split('/')
|
url = url.split('/')
|
||||||
hid = url[0]
|
hid = url[0]
|
||||||
|
@ -27,5 +56,5 @@ def padma_video(request, url):
|
||||||
}.get(view, view)
|
}.get(view, view)
|
||||||
#FIXME: reqrite layer urls
|
#FIXME: reqrite layer urls
|
||||||
#FIXME: rewrite timerange urls
|
#FIXME: rewrite timerange urls
|
||||||
return redirect(url)
|
return redirect(url, permanent=True)
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ urlpatterns += patterns('',
|
||||||
urlpatterns += patterns('',
|
urlpatterns += patterns('',
|
||||||
(r'^(V[a-z0-9]*)$', 'urlalias.views.padma_video'),
|
(r'^(V[a-z0-9]*)$', 'urlalias.views.padma_video'),
|
||||||
(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('',
|
urlpatterns += patterns('',
|
||||||
(r'^(?P<id>[A-Z0-9].*)/embed', 'app.views.embed'),
|
(r'^(?P<id>[A-Z0-9].*)/embed', 'app.views.embed'),
|
||||||
|
|
Loading…
Reference in a new issue