PageRenderTime 144ms CodeModel.GetById 40ms app.highlight 43ms RepoModel.GetById 58ms app.codeStats 0ms

/tests/regressiontests/generic_views/urls.py

https://code.google.com/p/mango-py/
Python | 217 lines | 214 code | 3 blank | 0 comment | 0 complexity | 79b77898b99c9b49f3470253892ab38b MD5 | raw file
  1from django.conf.urls.defaults import *
  2from django.views.generic import TemplateView
  3from django.views.decorators.cache import cache_page
  4
  5import views
  6
  7
  8urlpatterns = patterns('',
  9    # base
 10    #(r'^about/login-required/$',
 11    #    views.DecoratedAboutView()),
 12
 13    # TemplateView
 14    (r'^template/no_template/$',
 15        TemplateView.as_view()),
 16    (r'^template/simple/(?P<foo>\w+)/$',
 17        TemplateView.as_view(template_name='generic_views/about.html')),
 18    (r'^template/custom/(?P<foo>\w+)/$',
 19        views.CustomTemplateView.as_view(template_name='generic_views/about.html')),
 20
 21    (r'^template/cached/(?P<foo>\w+)/$',
 22        cache_page(2.0)(TemplateView.as_view(template_name='generic_views/about.html'))),
 23
 24    # DetailView
 25    (r'^detail/obj/$',
 26        views.ObjectDetail.as_view()),
 27    url(r'^detail/artist/(?P<pk>\d+)/$',
 28        views.ArtistDetail.as_view(),
 29        name="artist_detail"),
 30    url(r'^detail/author/(?P<pk>\d+)/$',
 31        views.AuthorDetail.as_view(),
 32        name="author_detail"),
 33    (r'^detail/author/byslug/(?P<slug>[\w-]+)/$',
 34        views.AuthorDetail.as_view()),
 35    (r'^detail/author/(?P<pk>\d+)/template_name_suffix/$',
 36        views.AuthorDetail.as_view(template_name_suffix='_view')),
 37    (r'^detail/author/(?P<pk>\d+)/template_name/$',
 38        views.AuthorDetail.as_view(template_name='generic_views/about.html')),
 39    (r'^detail/author/(?P<pk>\d+)/context_object_name/$',
 40        views.AuthorDetail.as_view(context_object_name='thingy')),
 41    (r'^detail/author/(?P<pk>\d+)/dupe_context_object_name/$',
 42        views.AuthorDetail.as_view(context_object_name='object')),
 43    (r'^detail/page/(?P<pk>\d+)/field/$',
 44        views.PageDetail.as_view()),
 45    (r'^detail/author/invalid/url/$',
 46        views.AuthorDetail.as_view()),
 47    (r'^detail/author/invalid/qs/$',
 48        views.AuthorDetail.as_view(queryset=None)),
 49
 50    # Create/UpdateView
 51    (r'^edit/artists/create/$',
 52        views.ArtistCreate.as_view()),
 53    (r'^edit/artists/(?P<pk>\d+)/update/$',
 54        views.ArtistUpdate.as_view()),
 55
 56    (r'^edit/authors/create/naive/$',
 57        views.NaiveAuthorCreate.as_view()),
 58    (r'^edit/authors/create/redirect/$',
 59        views.NaiveAuthorCreate.as_view(success_url='/edit/authors/create/')),
 60    (r'^edit/authors/create/interpolate_redirect/$',
 61        views.NaiveAuthorCreate.as_view(success_url='/edit/author/%(id)d/update/')),
 62    (r'^edit/authors/create/restricted/$',
 63        views.AuthorCreateRestricted.as_view()),
 64    (r'^edit/authors/create/$',
 65        views.AuthorCreate.as_view()),
 66    (r'^edit/authors/create/special/$',
 67        views.SpecializedAuthorCreate.as_view()),
 68
 69    (r'^edit/author/(?P<pk>\d+)/update/naive/$',
 70        views.NaiveAuthorUpdate.as_view()),
 71    (r'^edit/author/(?P<pk>\d+)/update/redirect/$',
 72        views.NaiveAuthorUpdate.as_view(success_url='/edit/authors/create/')),
 73    (r'^edit/author/(?P<pk>\d+)/update/interpolate_redirect/$',
 74        views.NaiveAuthorUpdate.as_view(success_url='/edit/author/%(id)d/update/')),
 75    (r'^edit/author/(?P<pk>\d+)/update/$',
 76        views.AuthorUpdate.as_view()),
 77    (r'^edit/author/update/$',
 78        views.OneAuthorUpdate.as_view()),
 79    (r'^edit/author/(?P<pk>\d+)/update/special/$',
 80        views.SpecializedAuthorUpdate.as_view()),
 81    (r'^edit/author/(?P<pk>\d+)/delete/naive/$',
 82        views.NaiveAuthorDelete.as_view()),
 83    (r'^edit/author/(?P<pk>\d+)/delete/redirect/$',
 84        views.NaiveAuthorDelete.as_view(success_url='/edit/authors/create/')),
 85    (r'^edit/author/(?P<pk>\d+)/delete/$',
 86        views.AuthorDelete.as_view()),
 87    (r'^edit/author/(?P<pk>\d+)/delete/special/$',
 88        views.SpecializedAuthorDelete.as_view()),
 89
 90    # ArchiveIndexView
 91    (r'^dates/books/$',
 92        views.BookArchive.as_view()),
 93    (r'^dates/books/context_object_name/$',
 94        views.BookArchive.as_view(context_object_name='thingies')),
 95    (r'^dates/books/allow_empty/$',
 96        views.BookArchive.as_view(allow_empty=True)),
 97    (r'^dates/books/template_name/$',
 98        views.BookArchive.as_view(template_name='generic_views/list.html')),
 99    (r'^dates/books/template_name_suffix/$',
100        views.BookArchive.as_view(template_name_suffix='_detail')),
101    (r'^dates/books/invalid/$',
102        views.BookArchive.as_view(queryset=None)),
103    (r'^dates/books/paginated/$',
104        views.BookArchive.as_view(paginate_by=10)),
105
106    # ListView
107    (r'^list/dict/$',
108        views.DictList.as_view()),
109    (r'^list/dict/paginated/$',
110        views.DictList.as_view(paginate_by=1)),
111    url(r'^list/artists/$',
112        views.ArtistList.as_view(),
113        name="artists_list"),
114    url(r'^list/authors/$',
115        views.AuthorList.as_view(),
116        name="authors_list"),
117    (r'^list/authors/paginated/$',
118        views.AuthorList.as_view(paginate_by=30)),
119    (r'^list/authors/paginated/(?P<page>\d+)/$',
120        views.AuthorList.as_view(paginate_by=30)),
121    (r'^list/authors/notempty/$',
122        views.AuthorList.as_view(allow_empty=False)),
123    (r'^list/authors/template_name/$',
124        views.AuthorList.as_view(template_name='generic_views/list.html')),
125    (r'^list/authors/template_name_suffix/$',
126        views.AuthorList.as_view(template_name_suffix='_objects')),
127    (r'^list/authors/context_object_name/$',
128        views.AuthorList.as_view(context_object_name='author_list')),
129    (r'^list/authors/dupe_context_object_name/$',
130        views.AuthorList.as_view(context_object_name='object_list')),
131    (r'^list/authors/invalid/$',
132        views.AuthorList.as_view(queryset=None)),
133    (r'^list/authors/paginated/custom_class/$',
134        views.AuthorList.as_view(paginate_by=5, paginator_class=views.CustomPaginator)),
135    (r'^list/authors/paginated/custom_constructor/$',
136        views.AuthorListCustomPaginator.as_view()),
137
138    # YearArchiveView
139    # Mixing keyword and possitional captures below is intentional; the views
140    # ought to be able to accept either.
141    (r'^dates/books/(?P<year>\d{4})/$',
142        views.BookYearArchive.as_view()),
143    (r'^dates/books/(?P<year>\d{4})/make_object_list/$',
144        views.BookYearArchive.as_view(make_object_list=True)),
145    (r'^dates/books/(?P<year>\d{4})/allow_empty/$',
146        views.BookYearArchive.as_view(allow_empty=True)),
147    (r'^dates/books/(?P<year>\d{4})/allow_future/$',
148        views.BookYearArchive.as_view(allow_future=True)),
149    (r'^dates/books/(?P<year>\d{4})/paginated/$',
150        views.BookYearArchive.as_view(make_object_list=True, paginate_by=30)),
151    (r'^dates/books/no_year/$',
152        views.BookYearArchive.as_view()),
153
154    # MonthArchiveView
155    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/$',
156        views.BookMonthArchive.as_view()),
157    (r'^dates/books/(?P<year>\d{4})/(?P<month>\d{1,2})/$',
158        views.BookMonthArchive.as_view(month_format='%m')),
159    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/allow_empty/$',
160        views.BookMonthArchive.as_view(allow_empty=True)),
161    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/allow_future/$',
162        views.BookMonthArchive.as_view(allow_future=True)),
163    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/paginated/$',
164        views.BookMonthArchive.as_view(paginate_by=30)),
165    (r'^dates/books/(?P<year>\d{4})/no_month/$',
166        views.BookMonthArchive.as_view()),
167
168    # WeekArchiveView
169    (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/$',
170        views.BookWeekArchive.as_view()),
171    (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/allow_empty/$',
172        views.BookWeekArchive.as_view(allow_empty=True)),
173    (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/allow_future/$',
174        views.BookWeekArchive.as_view(allow_future=True)),
175    (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/paginated/$',
176        views.BookWeekArchive.as_view(paginate_by=30)),
177    (r'^dates/books/(?P<year>\d{4})/week/no_week/$',
178        views.BookWeekArchive.as_view()),
179    (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/monday/$',
180        views.BookWeekArchive.as_view(week_format='%W')),
181
182    # DayArchiveView
183    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/$',
184        views.BookDayArchive.as_view()),
185    (r'^dates/books/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$',
186        views.BookDayArchive.as_view(month_format='%m')),
187    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/allow_empty/$',
188        views.BookDayArchive.as_view(allow_empty=True)),
189    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/allow_future/$',
190        views.BookDayArchive.as_view(allow_future=True)),
191    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/paginated/$',
192        views.BookDayArchive.as_view(paginate_by=True)),
193    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/no_day/$',
194        views.BookDayArchive.as_view()),
195
196    # TodayArchiveView
197    (r'dates/books/today/$',
198        views.BookTodayArchive.as_view()),
199    (r'dates/books/today/allow_empty/$',
200        views.BookTodayArchive.as_view(allow_empty=True)),
201
202    # DateDetailView
203    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<pk>\d+)/$',
204        views.BookDetail.as_view()),
205    (r'^dates/books/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<pk>\d+)/$',
206        views.BookDetail.as_view(month_format='%m')),
207    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<pk>\d+)/allow_future/$',
208        views.BookDetail.as_view(allow_future=True)),
209    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/nopk/$',
210        views.BookDetail.as_view()),
211
212    (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/byslug/(?P<slug>[\w-]+)/$',
213        views.BookDetail.as_view()),
214
215    # Useful for testing redirects
216    (r'^accounts/login/$',  'django.contrib.auth.views.login')
217)