From 4a3b27b2ac575e03b07a0a16f7e67cfb5eb06a09 Mon Sep 17 00:00:00 2001 From: Sanj Date: Sat, 2 Jun 2012 00:10:07 +0530 Subject: [PATCH] redirect old /itf/ urls --- itf/festival/urls.py | 1 - itf/festival/views.py | 34 ++++++++++++++++++++++++++- itf/templates/noel/render_object.html | 2 +- itf/templates/search/search.html | 2 +- itf/urls.py | 2 +- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/itf/festival/urls.py b/itf/festival/urls.py index 2053595..209f2c8 100755 --- a/itf/festival/urls.py +++ b/itf/festival/urls.py @@ -1,7 +1,6 @@ from django.conf.urls.defaults import * urlpatterns = patterns('', - (r'^$', 'festival.views.home'), (r'^wireframe', 'festival.views.wireframe'), (r'^projects', 'festival.views.projects'), diff --git a/itf/festival/views.py b/itf/festival/views.py index 198af27..053379e 100755 --- a/itf/festival/views.py +++ b/itf/festival/views.py @@ -1,6 +1,6 @@ # Create your views here. from django.shortcuts import render_to_response, get_object_or_404 -from django.http import HttpResponse +from django.http import HttpResponse, HttpResponseRedirect from festival.models import * from bestpractices.models import * from utils import validateEmail @@ -14,6 +14,38 @@ from django.core.mail import send_mail from settings import ERANG_SUBSCRIBE_URL import urllib2 + +def redirect(request, old_url): + REDIRECT_MAPPING = { + 'people': '/m/itf-core/?tab=people', + 'meeting': '/m/itf-core/?tab=meetings', + 'meetings': '/m/itf-core/?tab=meetings', + 'project': '/m/itf-core/?tab=projects', + 'projects': '/m/itf-core/?tab=projects', + 'resources': '/m/bibliography/?tab=documents', + 'bestpractices/story': '/m/bestpractices/?tab=cases', + 'erang': '/m/e-rang/?tab=issues' + } + components = old_url.split("/") + if len(components) > 2 and components[0].startswith('bestpractices'): + part_one = "/".join(components[:-1]) + else: + part_one = components[0] + if part_one in REDIRECT_MAPPING.keys(): + url = REDIRECT_MAPPING[part_one] + if len(components) > 1: + no = components[-1] + try: + object_id = int(no) + if object_id > 0: + url += "&object_id=%d" % object_id + except: + pass + else: + url = "/" + return HttpResponseRedirect(url) + + def index(request): index_data = {} new_meetings = MeetingDay.objects.all().order_by('-meeting_date')[:5] # get 5 latest meetings diff --git a/itf/templates/noel/render_object.html b/itf/templates/noel/render_object.html index 6d1f5d9..dd2b593 100755 --- a/itf/templates/noel/render_object.html +++ b/itf/templates/noel/render_object.html @@ -6,7 +6,7 @@ - +