From 2ff13690f8c20fde27c68a97d5cf7458243a6149 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 25 Dec 2013 10:11:21 +0000 Subject: [PATCH] dont return json 404 for non existing old ids --- pandora/urlalias/views.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pandora/urlalias/views.py b/pandora/urlalias/views.py index dce5c882..e2e83c76 100644 --- a/pandora/urlalias/views.py +++ b/pandora/urlalias/views.py @@ -4,6 +4,8 @@ import re from django.shortcuts import get_object_or_404, redirect +import app.views + import models def padma_find(request): @@ -49,11 +51,17 @@ def padma_video(request, url): layer = view view = None if layer: - alias = get_object_or_404(models.LayerAlias, old=layer) - url = '/%s' % alias.new + try: + alias = get_object_or_404(models.LayerAlias, old=layer) + url = '/%s' % alias.new + except: + return app.views.index(request) else: - alias = get_object_or_404(models.IDAlias, old=hid) - url = '/%s' % alias.new + try: + alias = get_object_or_404(models.IDAlias, old=hid) + url = '/%s' % alias.new + except: + return app.views.index(request) if view: timecodes = re.compile('(\d{2}:\d{2}:\d{2}\.\d{3})-(\d{2}:\d{2}:\d{2}\.\d{3})').findall(view) if timecodes: