urls.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. from __future__ import absolute_import
  2. from django.conf.urls import patterns, url
  3. from django.views.decorators.cache import cache_page
  4. from django.views.generic import TemplateView
  5. from . import models
  6. from . import views
  7. urlpatterns = patterns('',
  8. # base
  9. #(r'^about/login-required/$',
  10. # views.DecoratedAboutView()),
  11. # TemplateView
  12. (r'^template/no_template/$',
  13. TemplateView.as_view()),
  14. (r'^template/simple/(?P<foo>\w+)/$',
  15. TemplateView.as_view(template_name='generic_views/about.html')),
  16. (r'^template/custom/(?P<foo>\w+)/$',
  17. views.CustomTemplateView.as_view(template_name='generic_views/about.html')),
  18. (r'^template/cached/(?P<foo>\w+)/$',
  19. cache_page(2.0)(TemplateView.as_view(template_name='generic_views/about.html'))),
  20. # DetailView
  21. (r'^detail/obj/$',
  22. views.ObjectDetail.as_view()),
  23. url(r'^detail/artist/(?P<pk>\d+)/$',
  24. views.ArtistDetail.as_view(),
  25. name="artist_detail"),
  26. url(r'^detail/author/(?P<pk>\d+)/$',
  27. views.AuthorDetail.as_view(),
  28. name="author_detail"),
  29. (r'^detail/author/bycustompk/(?P<foo>\d+)/$',
  30. views.AuthorDetail.as_view(pk_url_kwarg='foo')),
  31. (r'^detail/author/byslug/(?P<slug>[\w-]+)/$',
  32. views.AuthorDetail.as_view()),
  33. (r'^detail/author/bycustomslug/(?P<foo>[\w-]+)/$',
  34. views.AuthorDetail.as_view(slug_url_kwarg='foo')),
  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. (r'^detail/nonmodel/1/$',
  50. views.NonModelDetail.as_view()),
  51. # Create/UpdateView
  52. (r'^edit/artists/create/$',
  53. views.ArtistCreate.as_view()),
  54. (r'^edit/artists/(?P<pk>\d+)/update/$',
  55. views.ArtistUpdate.as_view()),
  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. (r'^edit/author/(?P<pk>\d+)/update/naive/$',
  69. views.NaiveAuthorUpdate.as_view()),
  70. (r'^edit/author/(?P<pk>\d+)/update/redirect/$',
  71. views.NaiveAuthorUpdate.as_view(success_url='/edit/authors/create/')),
  72. (r'^edit/author/(?P<pk>\d+)/update/interpolate_redirect/$',
  73. views.NaiveAuthorUpdate.as_view(success_url='/edit/author/%(id)d/update/')),
  74. (r'^edit/author/(?P<pk>\d+)/update/$',
  75. views.AuthorUpdate.as_view()),
  76. (r'^edit/author/update/$',
  77. views.OneAuthorUpdate.as_view()),
  78. (r'^edit/author/(?P<pk>\d+)/update/special/$',
  79. views.SpecializedAuthorUpdate.as_view()),
  80. (r'^edit/author/(?P<pk>\d+)/delete/naive/$',
  81. views.NaiveAuthorDelete.as_view()),
  82. (r'^edit/author/(?P<pk>\d+)/delete/redirect/$',
  83. views.NaiveAuthorDelete.as_view(success_url='/edit/authors/create/')),
  84. (r'^edit/author/(?P<pk>\d+)/delete/$',
  85. views.AuthorDelete.as_view()),
  86. (r'^edit/author/(?P<pk>\d+)/delete/special/$',
  87. views.SpecializedAuthorDelete.as_view()),
  88. # ArchiveIndexView
  89. (r'^dates/books/$',
  90. views.BookArchive.as_view()),
  91. (r'^dates/books/context_object_name/$',
  92. views.BookArchive.as_view(context_object_name='thingies')),
  93. (r'^dates/books/allow_empty/$',
  94. views.BookArchive.as_view(allow_empty=True)),
  95. (r'^dates/books/template_name/$',
  96. views.BookArchive.as_view(template_name='generic_views/list.html')),
  97. (r'^dates/books/template_name_suffix/$',
  98. views.BookArchive.as_view(template_name_suffix='_detail')),
  99. (r'^dates/books/invalid/$',
  100. views.BookArchive.as_view(queryset=None)),
  101. (r'^dates/books/paginated/$',
  102. views.BookArchive.as_view(paginate_by=10)),
  103. (r'^dates/books/reverse/$',
  104. views.BookArchive.as_view(queryset=models.Book.objects.order_by('pubdate'))),
  105. (r'^dates/books/by_month/$',
  106. views.BookArchive.as_view(date_list_period='month')),
  107. (r'^dates/booksignings/$',
  108. views.BookSigningArchive.as_view()),
  109. # ListView
  110. (r'^list/dict/$',
  111. views.DictList.as_view()),
  112. (r'^list/dict/paginated/$',
  113. views.DictList.as_view(paginate_by=1)),
  114. url(r'^list/artists/$',
  115. views.ArtistList.as_view(),
  116. name="artists_list"),
  117. url(r'^list/authors/$',
  118. views.AuthorList.as_view(),
  119. name="authors_list"),
  120. (r'^list/authors/paginated/$',
  121. views.AuthorList.as_view(paginate_by=30)),
  122. (r'^list/authors/paginated/(?P<page>\d+)/$',
  123. views.AuthorList.as_view(paginate_by=30)),
  124. (r'^list/authors/notempty/$',
  125. views.AuthorList.as_view(allow_empty=False)),
  126. (r'^list/authors/notempty/paginated/$',
  127. views.AuthorList.as_view(allow_empty=False, paginate_by=2)),
  128. (r'^list/authors/template_name/$',
  129. views.AuthorList.as_view(template_name='generic_views/list.html')),
  130. (r'^list/authors/template_name_suffix/$',
  131. views.AuthorList.as_view(template_name_suffix='_objects')),
  132. (r'^list/authors/context_object_name/$',
  133. views.AuthorList.as_view(context_object_name='author_list')),
  134. (r'^list/authors/dupe_context_object_name/$',
  135. views.AuthorList.as_view(context_object_name='object_list')),
  136. (r'^list/authors/invalid/$',
  137. views.AuthorList.as_view(queryset=None)),
  138. (r'^list/authors/paginated/custom_class/$',
  139. views.AuthorList.as_view(paginate_by=5, paginator_class=views.CustomPaginator)),
  140. (r'^list/authors/paginated/custom_constructor/$',
  141. views.AuthorListCustomPaginator.as_view()),
  142. # YearArchiveView
  143. # Mixing keyword and possitional captures below is intentional; the views
  144. # ought to be able to accept either.
  145. (r'^dates/books/(?P<year>\d{4})/$',
  146. views.BookYearArchive.as_view()),
  147. (r'^dates/books/(?P<year>\d{4})/make_object_list/$',
  148. views.BookYearArchive.as_view(make_object_list=True)),
  149. (r'^dates/books/(?P<year>\d{4})/allow_empty/$',
  150. views.BookYearArchive.as_view(allow_empty=True)),
  151. (r'^dates/books/(?P<year>\d{4})/allow_future/$',
  152. views.BookYearArchive.as_view(allow_future=True)),
  153. (r'^dates/books/(?P<year>\d{4})/paginated/$',
  154. views.BookYearArchive.as_view(make_object_list=True, paginate_by=30)),
  155. (r'^dates/books/no_year/$',
  156. views.BookYearArchive.as_view()),
  157. (r'^dates/books/(?P<year>\d{4})/reverse/$',
  158. views.BookYearArchive.as_view(queryset=models.Book.objects.order_by('pubdate'))),
  159. (r'^dates/booksignings/(?P<year>\d{4})/$',
  160. views.BookSigningYearArchive.as_view()),
  161. # MonthArchiveView
  162. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/$',
  163. views.BookMonthArchive.as_view()),
  164. (r'^dates/books/(?P<year>\d{4})/(?P<month>\d{1,2})/$',
  165. views.BookMonthArchive.as_view(month_format='%m')),
  166. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/allow_empty/$',
  167. views.BookMonthArchive.as_view(allow_empty=True)),
  168. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/allow_future/$',
  169. views.BookMonthArchive.as_view(allow_future=True)),
  170. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/paginated/$',
  171. views.BookMonthArchive.as_view(paginate_by=30)),
  172. (r'^dates/books/(?P<year>\d{4})/no_month/$',
  173. views.BookMonthArchive.as_view()),
  174. (r'^dates/booksignings/(?P<year>\d{4})/(?P<month>[a-z]{3})/$',
  175. views.BookSigningMonthArchive.as_view()),
  176. # WeekArchiveView
  177. (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/$',
  178. views.BookWeekArchive.as_view()),
  179. (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/allow_empty/$',
  180. views.BookWeekArchive.as_view(allow_empty=True)),
  181. (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/allow_future/$',
  182. views.BookWeekArchive.as_view(allow_future=True)),
  183. (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/paginated/$',
  184. views.BookWeekArchive.as_view(paginate_by=30)),
  185. (r'^dates/books/(?P<year>\d{4})/week/no_week/$',
  186. views.BookWeekArchive.as_view()),
  187. (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/monday/$',
  188. views.BookWeekArchive.as_view(week_format='%W')),
  189. (r'^dates/booksignings/(?P<year>\d{4})/week/(?P<week>\d{1,2})/$',
  190. views.BookSigningWeekArchive.as_view()),
  191. # DayArchiveView
  192. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/$',
  193. views.BookDayArchive.as_view()),
  194. (r'^dates/books/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$',
  195. views.BookDayArchive.as_view(month_format='%m')),
  196. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/allow_empty/$',
  197. views.BookDayArchive.as_view(allow_empty=True)),
  198. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/allow_future/$',
  199. views.BookDayArchive.as_view(allow_future=True)),
  200. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/allow_empty_and_future/$',
  201. views.BookDayArchive.as_view(allow_empty=True, allow_future=True)),
  202. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/paginated/$',
  203. views.BookDayArchive.as_view(paginate_by=True)),
  204. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/no_day/$',
  205. views.BookDayArchive.as_view()),
  206. (r'^dates/booksignings/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/$',
  207. views.BookSigningDayArchive.as_view()),
  208. # TodayArchiveView
  209. (r'^dates/books/today/$',
  210. views.BookTodayArchive.as_view()),
  211. (r'^dates/books/today/allow_empty/$',
  212. views.BookTodayArchive.as_view(allow_empty=True)),
  213. (r'^dates/booksignings/today/$',
  214. views.BookSigningTodayArchive.as_view()),
  215. # DateDetailView
  216. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<pk>\d+)/$',
  217. views.BookDetail.as_view()),
  218. (r'^dates/books/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<pk>\d+)/$',
  219. views.BookDetail.as_view(month_format='%m')),
  220. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<pk>\d+)/allow_future/$',
  221. views.BookDetail.as_view(allow_future=True)),
  222. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/nopk/$',
  223. views.BookDetail.as_view()),
  224. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/byslug/(?P<slug>[\w-]+)/$',
  225. views.BookDetail.as_view()),
  226. (r'^dates/books/get_object_custom_queryset/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<pk>\d+)/$',
  227. views.BookDetailGetObjectCustomQueryset.as_view()),
  228. (r'^dates/booksignings/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<pk>\d+)/$',
  229. views.BookSigningDetail.as_view()),
  230. # Useful for testing redirects
  231. (r'^accounts/login/$', 'django.contrib.auth.views.login')
  232. )