2014-05-15 17:41:55 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2015-04-21 19:54:00 +00:00
|
|
|
from functools import partial
|
2007-09-17 14:48:33 +00:00
|
|
|
from os import path
|
|
|
|
|
2015-01-28 12:35:27 +00:00
|
|
|
from django.conf.urls import include, url
|
2015-03-12 08:32:29 +00:00
|
|
|
from django.conf.urls.i18n import i18n_patterns
|
2012-12-08 10:13:52 +00:00
|
|
|
from django.utils._os import upath
|
2015-03-12 08:32:29 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2014-08-12 14:54:42 +00:00
|
|
|
from django.views import defaults, i18n, static
|
2007-09-19 13:26:56 +00:00
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
from . import views
|
2007-09-17 14:48:33 +00:00
|
|
|
|
2012-12-08 10:13:52 +00:00
|
|
|
base_dir = path.dirname(path.abspath(upath(__file__)))
|
2007-09-17 14:48:33 +00:00
|
|
|
media_dir = path.join(base_dir, 'media')
|
|
|
|
locale_dir = path.join(base_dir, 'locale')
|
|
|
|
|
|
|
|
js_info_dict = {
|
|
|
|
'domain': 'djangojs',
|
2013-02-26 12:19:18 +00:00
|
|
|
'packages': ('view_tests',),
|
2007-09-17 14:48:33 +00:00
|
|
|
}
|
|
|
|
|
2010-12-13 13:52:52 +00:00
|
|
|
js_info_dict_english_translation = {
|
|
|
|
'domain': 'djangojs',
|
2013-02-26 12:19:18 +00:00
|
|
|
'packages': ('view_tests.app0',),
|
2010-12-13 13:52:52 +00:00
|
|
|
}
|
|
|
|
|
2010-05-13 13:29:31 +00:00
|
|
|
js_info_dict_multi_packages1 = {
|
|
|
|
'domain': 'djangojs',
|
2013-02-26 12:19:18 +00:00
|
|
|
'packages': ('view_tests.app1', 'view_tests.app2'),
|
2010-05-13 13:29:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
js_info_dict_multi_packages2 = {
|
|
|
|
'domain': 'djangojs',
|
2013-02-26 12:19:18 +00:00
|
|
|
'packages': ('view_tests.app3', 'view_tests.app4'),
|
2010-05-13 13:29:31 +00:00
|
|
|
}
|
|
|
|
|
2012-11-17 14:37:30 +00:00
|
|
|
js_info_dict_admin = {
|
|
|
|
'domain': 'djangojs',
|
2013-02-26 12:19:18 +00:00
|
|
|
'packages': ('django.contrib.admin', 'view_tests'),
|
2012-11-17 14:37:30 +00:00
|
|
|
}
|
|
|
|
|
2014-02-23 14:10:31 +00:00
|
|
|
js_info_dict_app1 = {
|
|
|
|
'domain': 'djangojs',
|
|
|
|
'packages': ('view_tests.app1',),
|
|
|
|
}
|
|
|
|
|
|
|
|
js_info_dict_app2 = {
|
|
|
|
'domain': 'djangojs',
|
|
|
|
'packages': ('view_tests.app2',),
|
|
|
|
}
|
|
|
|
|
2014-02-18 13:46:23 +00:00
|
|
|
js_info_dict_app5 = {
|
|
|
|
'domain': 'djangojs',
|
|
|
|
'packages': ('view_tests.app5',),
|
|
|
|
}
|
|
|
|
|
2014-04-02 00:46:34 +00:00
|
|
|
urlpatterns = [
|
|
|
|
url(r'^$', views.index_page),
|
2008-07-18 19:45:00 +00:00
|
|
|
|
2007-09-19 13:26:56 +00:00
|
|
|
# Default views
|
2015-04-21 19:54:00 +00:00
|
|
|
url(r'^non_existing_url/', partial(defaults.page_not_found, exception=None)),
|
2014-04-02 00:46:34 +00:00
|
|
|
url(r'^server_error/', defaults.server_error),
|
2008-07-18 19:45:00 +00:00
|
|
|
|
2011-04-02 13:27:40 +00:00
|
|
|
# a view that raises an exception for the debug view
|
2014-04-02 00:46:34 +00:00
|
|
|
url(r'raises/$', views.raises),
|
2013-08-04 09:01:01 +00:00
|
|
|
|
2014-04-02 00:46:34 +00:00
|
|
|
url(r'raises400/$', views.raises400),
|
|
|
|
url(r'raises403/$', views.raises403),
|
|
|
|
url(r'raises404/$', views.raises404),
|
|
|
|
url(r'raises500/$', views.raises500),
|
2011-04-02 13:27:40 +00:00
|
|
|
|
2014-06-16 07:39:18 +00:00
|
|
|
url(r'technical404/$', views.technical404, name="my404"),
|
|
|
|
url(r'classbased404/$', views.Http404View.as_view()),
|
|
|
|
|
2007-09-19 13:26:56 +00:00
|
|
|
# i18n views
|
2014-04-02 00:46:34 +00:00
|
|
|
url(r'^i18n/', include('django.conf.urls.i18n')),
|
|
|
|
url(r'^jsi18n/$', i18n.javascript_catalog, js_info_dict),
|
2014-02-23 14:10:31 +00:00
|
|
|
url(r'^jsi18n/app1/$', i18n.javascript_catalog, js_info_dict_app1),
|
|
|
|
url(r'^jsi18n/app2/$', i18n.javascript_catalog, js_info_dict_app2),
|
2014-04-02 00:46:34 +00:00
|
|
|
url(r'^jsi18n/app5/$', i18n.javascript_catalog, js_info_dict_app5),
|
|
|
|
url(r'^jsi18n_english_translation/$', i18n.javascript_catalog, js_info_dict_english_translation),
|
|
|
|
url(r'^jsi18n_multi_packages1/$', i18n.javascript_catalog, js_info_dict_multi_packages1),
|
|
|
|
url(r'^jsi18n_multi_packages2/$', i18n.javascript_catalog, js_info_dict_multi_packages2),
|
|
|
|
url(r'^jsi18n_admin/$', i18n.javascript_catalog, js_info_dict_admin),
|
|
|
|
url(r'^jsi18n_template/$', views.jsi18n),
|
2014-02-23 14:10:31 +00:00
|
|
|
url(r'^jsi18n_multi_catalogs/$', views.jsi18n_multi_catalogs),
|
2015-06-05 14:10:28 +00:00
|
|
|
url(r'^jsoni18n/$', i18n.json_catalog, js_info_dict),
|
2008-07-18 19:45:00 +00:00
|
|
|
|
2007-09-19 13:26:56 +00:00
|
|
|
# Static views
|
2014-08-12 14:54:42 +00:00
|
|
|
url(r'^site_media/(?P<path>.*)$', static.serve, {'document_root': media_dir}),
|
2014-04-02 00:46:34 +00:00
|
|
|
]
|
|
|
|
|
2015-03-12 08:32:29 +00:00
|
|
|
urlpatterns += i18n_patterns(
|
|
|
|
url(_(r'^translated/$'), views.index_page, name='i18n_prefixed'),
|
|
|
|
)
|
|
|
|
|
2014-04-02 00:46:34 +00:00
|
|
|
urlpatterns += [
|
2014-04-14 18:12:44 +00:00
|
|
|
url(r'view_exception/(?P<n>[0-9]+)/$', views.view_exception, name='view_exception'),
|
|
|
|
url(r'template_exception/(?P<n>[0-9]+)/$', views.template_exception, name='template_exception'),
|
2014-04-02 00:46:34 +00:00
|
|
|
url(r'^raises_template_does_not_exist/(?P<path>.+)$', views.raises_template_does_not_exist, name='raises_template_does_not_exist'),
|
|
|
|
url(r'^render_no_template/$', views.render_no_template, name='render_no_template'),
|
|
|
|
]
|