urls.py 14 KB

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