diff options
Diffstat (limited to 'chimere/urls.py')
| -rw-r--r-- | chimere/urls.py | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/chimere/urls.py b/chimere/urls.py index a018d4a..11bae0a 100644 --- a/chimere/urls.py +++ b/chimere/urls.py @@ -1,3 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2008-2010 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> + +# 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 <http://www.gnu.org/licenses/>. + +# See the file COPYING for details. + + from django.conf.urls.defaults import * from django.contrib import admin @@ -5,6 +25,8 @@ admin.autodiscover() from settings import ROOT_PATH, EXTRA_URL +from main.models import Area + js_info_dict = { 'packages': 'chimere', } @@ -13,21 +35,35 @@ base = '^' + EXTRA_URL urlpatterns = patterns('', (base + r'admin/(.*)', admin.site.root), - (base + r'$', 'chimere.main.views.index'), - (base + r'contact/$', 'chimere.main.views.contactus'), - (base + r'edit/$', 'chimere.main.views.edit'), - (base + r'edit_route/$', 'chimere.main.views.editRoute'), - (base + r'submited/(?P<action>\w+)/$$', 'chimere.main.views.submited'), - (base + r'getDetail/(?P<marker_id>\d+)/$', 'chimere.main.views.getDetail'), - (base + r'getDescriptionDetail/(?P<category_id>\d+)/$', - 'chimere.main.views.getDescriptionDetail'), - (base + r'getGeoObjects/(?P<category_ids>\w+)(/(?P<status>\w+))?$', - 'chimere.main.views.getGeoObjects'), - (base + r'getAvailableCategories/(?P<area>\w+)(/(?P<status>\w+))?(/(?P<force>\w+))?$', - 'chimere.main.views.getAvailableCategories'), (base + r'static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': ROOT_PATH + 'static/'}), (base + r'media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': ROOT_PATH + 'media/'}), (base + r'jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), ) + +urlpatterns += patterns('chimere.main.views', +) + +url_areas = Area.objects.filter(url__isnull=False) +urlpatterns += patterns('chimere.main.views', (base + r'$', 'index'),) + +for area in url_areas: + urlpatterns += patterns('chimere.main.views', + (base + '(' + area.url + ')/?$', 'index', {'default_area':area}),) + +extra = "|".join([area.url for area in url_areas]) +if extra: + extra = "(%s)?/?" % extra +urlpatterns += patterns('chimere.main.views', +(base + extra + r'contact/$', 'contactus'), +(base + extra + r'edit/$', 'edit'), +(base + extra + r'edit_route/$', 'editRoute'), +(base + extra + r'submited/(?P<action>\w+)/$', 'submited'), +(base + extra + r'getDetail/(?P<marker_id>\d+)/$', 'getDetail'), +(base + extra + r'getDescriptionDetail/(?P<category_id>\d+)/$', + 'getDescriptionDetail'), +(base + extra + r'getGeoObjects/(?P<category_ids>\w+)(/(?P<status>\w+))?$', + 'getGeoObjects'), +(base + extra + r'getAvailableCategories/(?P<area>\w+)(/(?P<status>\w+))?(/(?P<force>\w+))?$', + 'getAvailableCategories'),) |
