From 287ef26dffb4095148a36e1f28e48cf7427b6695 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 18 Jan 2011 21:00:49 +0530 Subject: [PATCH] urlalias = app to migrate old urls --- pandora/urlalias/__init__.py | 0 pandora/urlalias/models.py | 15 +++++++++++++++ pandora/urlalias/tests.py | 23 +++++++++++++++++++++++ pandora/urlalias/views.py | 12 ++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 pandora/urlalias/__init__.py create mode 100644 pandora/urlalias/models.py create mode 100644 pandora/urlalias/tests.py create mode 100644 pandora/urlalias/views.py diff --git a/pandora/urlalias/__init__.py b/pandora/urlalias/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pandora/urlalias/models.py b/pandora/urlalias/models.py new file mode 100644 index 00000000..38772ee6 --- /dev/null +++ b/pandora/urlalias/models.py @@ -0,0 +1,15 @@ +from django.db import models + + +class IDAlias(models.Model): + old = models.CharField(max_length=255, unique=True) + new = models.CharField(max_length=255) + +class LayerAlias(models.Model): + old = models.CharField(max_length=255, unique=True) + new = models.CharField(max_length=255) + +class Alias(models.Model): + url = models.CharField(max_length=255, unique=True) + target = models.CharField(max_length=255) + diff --git a/pandora/urlalias/tests.py b/pandora/urlalias/tests.py new file mode 100644 index 00000000..2247054b --- /dev/null +++ b/pandora/urlalias/tests.py @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff --git a/pandora/urlalias/views.py b/pandora/urlalias/views.py new file mode 100644 index 00000000..a9dcac25 --- /dev/null +++ b/pandora/urlalias/views.py @@ -0,0 +1,12 @@ +# Create your views here. +import models + +def padma_video(request, hid, view=''): + alias = get_object_or_404(models.IDAlias, old=hid) + url = '/%s' % alias.new + if view: + url += '/' + { + }.get(view, view) + #FIXME: reqire layer urls, reqrite timerange urls + raise redirect(url) +