urls.py 12 KB

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