forked from 0x2620/pandora
urlalias = app to migrate old urls
This commit is contained in:
parent
b1924e3c47
commit
287ef26dff
4 changed files with 50 additions and 0 deletions
0
pandora/urlalias/__init__.py
Normal file
0
pandora/urlalias/__init__.py
Normal file
15
pandora/urlalias/models.py
Normal file
15
pandora/urlalias/models.py
Normal file
|
@ -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)
|
||||||
|
|
23
pandora/urlalias/tests.py
Normal file
23
pandora/urlalias/tests.py
Normal file
|
@ -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
|
||||||
|
"""}
|
||||||
|
|
12
pandora/urlalias/views.py
Normal file
12
pandora/urlalias/views.py
Normal file
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue