urls.py 14 KB

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