urls.py 14 KB

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