2009-04-12 03:50:47 +00:00
|
|
|
# coding: utf-8
|
2007-09-17 14:48:33 +00:00
|
|
|
from os import path
|
|
|
|
|
|
|
|
from django.conf.urls.defaults import *
|
2007-09-19 13:26:56 +00:00
|
|
|
|
|
|
|
from models import *
|
2007-09-17 14:48:33 +00:00
|
|
|
import views
|
|
|
|
|
2008-07-18 19:45:00 +00:00
|
|
|
|
2007-09-17 14:48:33 +00:00
|
|
|
base_dir = path.dirname(path.abspath(__file__))
|
|
|
|
media_dir = path.join(base_dir, 'media')
|
|
|
|
locale_dir = path.join(base_dir, 'locale')
|
|
|
|
|
|
|
|
js_info_dict = {
|
|
|
|
'domain': 'djangojs',
|
|
|
|
'packages': ('regressiontests.views',),
|
|
|
|
}
|
|
|
|
|
2010-12-13 13:52:52 +00:00
|
|
|
js_info_dict_english_translation = {
|
|
|
|
'domain': 'djangojs',
|
|
|
|
'packages': ('regressiontests.views.app0',),
|
|
|
|
}
|
|
|
|
|
2010-05-13 13:29:31 +00:00
|
|
|
js_info_dict_multi_packages1 = {
|
|
|
|
'domain': 'djangojs',
|
|
|
|
'packages': ('regressiontests.views.app1', 'regressiontests.views.app2'),
|
|
|
|
}
|
|
|
|
|
|
|
|
js_info_dict_multi_packages2 = {
|
|
|
|
'domain': 'djangojs',
|
|
|
|
'packages': ('regressiontests.views.app3', 'regressiontests.views.app4'),
|
|
|
|
}
|
|
|
|
|
2008-07-18 19:45:00 +00:00
|
|
|
date_based_info_dict = {
|
|
|
|
'queryset': Article.objects.all(),
|
|
|
|
'date_field': 'date_created',
|
|
|
|
'month_format': '%m',
|
|
|
|
}
|
2010-10-01 02:01:20 +00:00
|
|
|
|
|
|
|
object_list_dict = {
|
|
|
|
'queryset': Article.objects.all(),
|
|
|
|
'paginate_by': 2,
|
|
|
|
}
|
|
|
|
|
|
|
|
object_list_no_paginate_by = {
|
|
|
|
'queryset': Article.objects.all(),
|
|
|
|
}
|
|
|
|
|
2009-04-09 15:23:56 +00:00
|
|
|
numeric_days_info_dict = dict(date_based_info_dict, day_format='%d')
|
|
|
|
|
2008-08-23 04:46:33 +00:00
|
|
|
date_based_datefield_info_dict = dict(date_based_info_dict, queryset=DateArticle.objects.all())
|
2007-09-19 13:26:56 +00:00
|
|
|
|
2007-09-17 14:48:33 +00:00
|
|
|
urlpatterns = patterns('',
|
|
|
|
(r'^$', views.index_page),
|
2008-07-18 19:45:00 +00:00
|
|
|
|
2007-09-19 13:26:56 +00:00
|
|
|
# Default views
|
2007-09-17 14:48:33 +00:00
|
|
|
(r'^shortcut/(\d+)/(.*)/$', 'django.views.defaults.shortcut'),
|
|
|
|
(r'^non_existing_url/', 'django.views.defaults.page_not_found'),
|
|
|
|
(r'^server_error/', 'django.views.defaults.server_error'),
|
2008-07-18 19:45:00 +00:00
|
|
|
|
2007-09-19 13:26:56 +00:00
|
|
|
# i18n views
|
2008-07-18 19:45:00 +00:00
|
|
|
(r'^i18n/', include('django.conf.urls.i18n')),
|
2007-09-17 14:48:33 +00:00
|
|
|
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
|
2010-12-13 13:52:52 +00:00
|
|
|
(r'^jsi18n_english_translation/$', 'django.views.i18n.javascript_catalog', js_info_dict_english_translation),
|
2010-05-13 13:29:31 +00:00
|
|
|
(r'^jsi18n_multi_packages1/$', 'django.views.i18n.javascript_catalog', js_info_dict_multi_packages1),
|
|
|
|
(r'^jsi18n_multi_packages2/$', 'django.views.i18n.javascript_catalog', js_info_dict_multi_packages2),
|
2008-07-18 19:45:00 +00:00
|
|
|
|
2007-09-19 13:26:56 +00:00
|
|
|
# Static views
|
2007-09-17 14:48:33 +00:00
|
|
|
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': media_dir}),
|
2009-04-12 03:50:47 +00:00
|
|
|
|
|
|
|
# Special URLs for particular regression cases.
|
|
|
|
url(u'^中文/$', 'regressiontests.views.views.redirect'),
|
|
|
|
url(u'^中文/target/$', 'regressiontests.views.views.index_page'),
|
2008-07-18 19:45:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Date-based generic views.
|
|
|
|
urlpatterns += patterns('django.views.generic.date_based',
|
|
|
|
(r'^date_based/object_detail/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/$',
|
|
|
|
'object_detail',
|
|
|
|
dict(slug_field='slug', **date_based_info_dict)),
|
|
|
|
(r'^date_based/object_detail/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/allow_future/$',
|
|
|
|
'object_detail',
|
|
|
|
dict(allow_future=True, slug_field='slug', **date_based_info_dict)),
|
2009-04-09 15:23:56 +00:00
|
|
|
(r'^date_based/archive_day/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$',
|
|
|
|
'archive_day',
|
|
|
|
numeric_days_info_dict),
|
2008-07-18 19:45:00 +00:00
|
|
|
(r'^date_based/archive_month/(?P<year>\d{4})/(?P<month>\d{1,2})/$',
|
|
|
|
'archive_month',
|
|
|
|
date_based_info_dict),
|
2008-08-23 04:46:33 +00:00
|
|
|
(r'^date_based/datefield/archive_month/(?P<year>\d{4})/(?P<month>\d{1,2})/$',
|
|
|
|
'archive_month',
|
|
|
|
date_based_datefield_info_dict),
|
2008-07-18 19:45:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# crud generic views.
|
|
|
|
urlpatterns += patterns('django.views.generic.create_update',
|
|
|
|
(r'^create_update/member/create/article/$', 'create_object',
|
|
|
|
dict(login_required=True, model=Article)),
|
|
|
|
(r'^create_update/create/article/$', 'create_object',
|
|
|
|
dict(post_save_redirect='/views/create_update/view/article/%(slug)s/',
|
|
|
|
model=Article)),
|
|
|
|
(r'^create_update/update/article/(?P<slug>[-\w]+)/$', 'update_object',
|
|
|
|
dict(post_save_redirect='/views/create_update/view/article/%(slug)s/',
|
|
|
|
slug_field='slug', model=Article)),
|
|
|
|
(r'^create_update/create_custom/article/$', views.custom_create),
|
|
|
|
(r'^create_update/delete/article/(?P<slug>[-\w]+)/$', 'delete_object',
|
|
|
|
dict(post_delete_redirect='/views/create_update/', slug_field='slug',
|
|
|
|
model=Article)),
|
|
|
|
|
|
|
|
# No post_save_redirect and no get_absolute_url on model.
|
|
|
|
(r'^create_update/no_redirect/create/article/$', 'create_object',
|
|
|
|
dict(model=Article)),
|
|
|
|
(r'^create_update/no_redirect/update/article/(?P<slug>[-\w]+)/$',
|
|
|
|
'update_object', dict(slug_field='slug', model=Article)),
|
|
|
|
|
|
|
|
# get_absolute_url on model, but no passed post_save_redirect.
|
|
|
|
(r'^create_update/no_url/create/article/$', 'create_object',
|
|
|
|
dict(model=UrlArticle)),
|
|
|
|
(r'^create_update/no_url/update/article/(?P<slug>[-\w]+)/$',
|
|
|
|
'update_object', dict(slug_field='slug', model=UrlArticle)),
|
2007-09-17 14:48:33 +00:00
|
|
|
)
|
2009-03-31 17:10:06 +00:00
|
|
|
|
2010-10-01 02:01:20 +00:00
|
|
|
urlpatterns += patterns('django.views.generic.list_detail',
|
|
|
|
(r'^object_list/page(?P<page>[\w]*)/$', 'object_list', object_list_dict),
|
|
|
|
(r'^object_list_no_paginate_by/page(?P<page>[0-9]+)/$', 'object_list',
|
|
|
|
object_list_no_paginate_by),
|
|
|
|
)
|
|
|
|
|
2009-03-31 17:10:06 +00:00
|
|
|
# a view that raises an exception for the debug view
|
|
|
|
urlpatterns += patterns('',
|
2010-03-05 18:53:07 +00:00
|
|
|
(r'^raises/$', views.raises),
|
|
|
|
(r'^raises404/$', views.raises404),
|
2009-03-31 17:10:06 +00:00
|
|
|
)
|
2010-03-02 19:37:48 +00:00
|
|
|
|
|
|
|
# rediriects, both temporary and permanent, with non-ASCII targets
|
|
|
|
urlpatterns += patterns('django.views.generic.simple',
|
|
|
|
('^nonascii_redirect/$', 'redirect_to',
|
|
|
|
{'url': u'/views/中文/target/', 'permanent': False}),
|
|
|
|
('^permanent_nonascii_redirect/$', 'redirect_to',
|
|
|
|
{'url': u'/views/中文/target/', 'permanent': True}),
|
|
|
|
)
|
|
|
|
|
2010-03-08 15:20:29 +00:00
|
|
|
urlpatterns += patterns('regressiontests.views.views',
|
|
|
|
url(r'view_exception/(?P<n>\d+)/$', 'view_exception', name='view_exception'),
|
2010-03-08 17:01:21 +00:00
|
|
|
url(r'template_exception/(?P<n>\d+)/$', 'template_exception', name='template_exception'),
|
2010-12-21 17:18:41 +00:00
|
|
|
|
|
|
|
(r'^shortcuts/render_to_response/$', 'render_to_response_view'),
|
|
|
|
(r'^shortcuts/render_to_response/request_context/$', 'render_to_response_view_with_request_context'),
|
|
|
|
(r'^shortcuts/render_to_response/mimetype/$', 'render_to_response_view_with_mimetype'),
|
|
|
|
(r'^shortcuts/render/$', 'render_view'),
|
|
|
|
(r'^shortcuts/render/base_context/$', 'render_view_with_base_context'),
|
2010-12-22 04:54:10 +00:00
|
|
|
(r'^shortcuts/render/content_type/$', 'render_view_with_content_type'),
|
|
|
|
(r'^shortcuts/render/status/$', 'render_view_with_status'),
|
2011-01-05 22:41:43 +00:00
|
|
|
(r'^shortcuts/render/current_app/$', 'render_view_with_current_app'),
|
|
|
|
(r'^shortcuts/render/current_app_conflict/$', 'render_view_with_current_app_conflict'),
|
2010-03-08 15:20:29 +00:00
|
|
|
)
|
2010-09-11 03:13:23 +00:00
|
|
|
|
|
|
|
# simple generic views.
|
|
|
|
urlpatterns += patterns('django.views.generic.simple',
|
|
|
|
(r'^simple/redirect_to/$', 'redirect_to', dict(url='/views/simple/target/')),
|
|
|
|
(r'^simple/redirect_to_temp/$', 'redirect_to', dict(url='/views/simple/target/', permanent=False)),
|
|
|
|
(r'^simple/redirect_to_none/$', 'redirect_to', dict(url=None)),
|
|
|
|
(r'^simple/redirect_to_arg/(?P<id>\d+)/$', 'redirect_to', dict(url='/views/simple/target_arg/%(id)s/')),
|
|
|
|
(r'^simple/redirect_to_query/$', 'redirect_to', dict(url='/views/simple/target/', query_string=True)),
|
|
|
|
)
|