diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 8ee34eca1..751fa1c8f 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -126,7 +126,6 @@ def upload(request): } } ''' - user = request.user f = get_object_or_404_json(models.File, oshash=request.POST['oshash']) if 'frame' in request.FILES: if f.frames.count() == 0: @@ -134,8 +133,7 @@ def upload(request): name = frame.name #float required? position = float(os.path.splitext(name)[0]) - fr = models.Frame(file=f, position=position) - fr.save() + fr, created = models.Frame.objects.get_or_create(file=f, position=position) fr.frame.save(name, frame) response = json_response({}) else: diff --git a/pandora/urlalias/views.py b/pandora/urlalias/views.py index a9dcac259..49f02ec3c 100644 --- a/pandora/urlalias/views.py +++ b/pandora/urlalias/views.py @@ -1,12 +1,21 @@ # Create your views here. +from django.shortcuts import get_object_or_404, redirect + import models -def padma_video(request, hid, view=''): +def padma_video(request, url): + url = url.split('/') + hid = url[0] + if len(url) > 1: + view = url[1] + else: + view = None alias = get_object_or_404(models.IDAlias, old=hid) url = '/%s' % alias.new if view: url += '/' + { + 'editor': 'timeline', }.get(view, view) #FIXME: reqire layer urls, reqrite timerange urls - raise redirect(url) + return redirect(url) diff --git a/pandora/urls.py b/pandora/urls.py index 72878e069..e962204d2 100644 --- a/pandora/urls.py +++ b/pandora/urls.py @@ -38,6 +38,10 @@ if settings.DEBUG: {'document_root': settings.TESTS_ROOT}), ) +urlpatterns += patterns('', + (r'^(V[a-z0-9]*)$', 'urlalias.views.padma_video'), + (r'^(V[a-z0-9]*/.*)$', 'urlalias.views.padma_video'), +) urlpatterns += patterns('', (r'^.*?embed$', 'app.views.embed'), (r'^[A-Z0-9].*$', 'app.views.index'),