redirect old /itf/ urls

This commit is contained in:
Sanj 2012-06-02 00:10:07 +05:30
parent 06d51e722e
commit 4a3b27b2ac
5 changed files with 36 additions and 5 deletions

View File

@ -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'),

View File

@ -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

View File

@ -6,7 +6,7 @@
<link rel="stylesheet" href="/static/css/noel/inner.css" type="text/css" />
<link rel="stylesheet" href="/static/css/noel/inner-details.css" type="text/css" />
<link type="text/css" rel="stylesheet" href="/static/css/jquery.tooltip.css" />
<link rel="canonical" href="{{ item.get_absolute_url }}" />
<link rel="canonical" href="http://theatreforum.in{{ item.get_absolute_url }}" />
<!--
<script type="text/javascript" src="/static/js/history/history.js"></script>
<script type="text/javascript" src="/static/js/history/amplify.store.js"></script>

View File

@ -36,7 +36,7 @@
<p>
<a href="{{ result.object.get_absolute_url }}&amp;search={{ query }}">{{ result.object.title }}</a> <br />
{{ result.text|truncatewords:60|markdown|safe }}
</p>
{% empty %}
<p class="noResults">No results found.</p>

View File

@ -31,7 +31,7 @@ urlpatterns = patterns('',
# (r'api/', 'api.views.api'),
# (r'jsdoc/', 'api.views.jsdoc'),
# (r'site.json', 'app.views.site_json'),
(r'^itf/', include('festival.urls')),
(r'^itf/(?P<old_url>.*)', 'festival.views.redirect'),
# (r'^accounts/register/', 'registration.views.register', {'form_class': ItfRegistrationForm }),
(r'^accounts/', include('registration.urls')),
(r'^admin/', include(admin.site.urls)),