#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (C) 2008-2011 Étienne Loks # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # See the file COPYING for details. from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() from settings import ROOT_PATH, EXTRA_URL, INSTALLED_APPS from main.models import Area def i18n_javascript(request): return admin.site.i18n_javascript(request) BASE = '^' + EXTRA_URL urlpatterns = patterns('', (BASE + r'admin/jsi18n/$', i18n_javascript), (BASE + r'admin/(.*)', admin.site.root), (BASE + r'static/(?P.*)$', 'django.views.static.serve', {'document_root': ROOT_PATH + 'static/'}), (BASE + r'media/(?P.*)$', 'django.views.static.serve', {'document_root': ROOT_PATH + 'media/'}), (BASE + r'charte/$', 'chimere.main.views.charte'), ) urlpatterns += patterns('chimere.main.views', ) url_areas = Area.objects.filter(urn__isnull=False) urlpatterns += patterns('chimere.main.views', (BASE + r'$', 'index'), (BASE + r'simple/?$', 'index', {'simple':True}) ) for area in url_areas: urlpatterns += patterns('chimere.main.views', (BASE + '(' + area.urn + ')/?$', 'index', {'default_area':area}), (BASE + '(' + area.urn + ')/simple/?$', 'index', {'default_area':area, 'simple':True}),) EXTRA = "|".join([area.urn for area in url_areas]) default_dct = {} EXTRA_NO_AREA = EXTRA if EXTRA: EXTRA_NO_AREA = "(%s)?/?" % EXTRA EXTRA = "(?P%s)?/?" % EXTRA else: default_dct = {'area_name':''} urlpatterns += patterns('chimere.main.views', (BASE + EXTRA + r'contact/$', 'contactus', default_dct), (BASE + EXTRA + r'edit/$', 'edit', default_dct), (BASE + EXTRA + r'edit_route/$', 'editRoute', default_dct), (BASE + EXTRA + r'upload_file/((?P\w+)/)?$', 'uploadFile', default_dct), (BASE + EXTRA + r'process_route_file/(?P\d+)/$', 'processRouteFile', default_dct), (BASE + EXTRA + r'submited/(?P\w+)/$', 'submited', default_dct), (BASE + EXTRA + r'getDetail/(?P\d+)/$', 'getDetail', default_dct), (BASE + EXTRA + r'getDescriptionDetail/(?P\d+)/$', 'getDescriptionDetail', default_dct), (BASE + EXTRA + r'getGeoObjects/(?P\w+)(/(?P\w+))?$', 'getGeoObjects', default_dct), (BASE + EXTRA + r'getAvailableCategories/((?P\w+))?(/(?P\w+))?(/(?P\w+))?$', 'getAvailableCategories', default_dct), (BASE + EXTRA + r'ty/(?P\w+)$', 'redirectFromTinyURN', default_dct), ) if 'chimere.rss' in INSTALLED_APPS: urlpatterns += patterns('', (r'^' + EXTRA_URL, include('chimere.rss.urls')),)