urls.py 15 KB

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