urls.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. from django.conf import settings
  2. from django.conf.urls.defaults import *
  3. from newsroom.models import *
  4. from newsroom import views as nr_views
  5. from newsroom.feeds import LatestNewsFeed
  6. # custom views stories
  7. urlpatterns = patterns(
  8. "newsroom.views",
  9. url(r"^feed.xml", LatestNewsFeed(), name="nr-news-feed"),
  10. url(r"^authors/$", view=nr_views.author_list, name="nr-author-list"),
  11. url(
  12. r"^authors/(?P<type_slug>[\-\d\w]+)/(?P<slug>[\-\d\w]+)/$",
  13. view=nr_views.author_detail,
  14. name="nr-author-detail",
  15. ),
  16. url(r"^archives/$", view=nr_views.archive_index, name="nr-archive-index"),
  17. url(
  18. r"^archives/(?P<year>\d{4})/$",
  19. view=nr_views.archive_year,
  20. name="nr-archive-year",
  21. ),
  22. url(
  23. r"^archives/(?P<year>\d{4})/(?P<slug>[\-\d\w]+)/$",
  24. view=nr_views.archive_detail,
  25. name="nr-archive-section-detail",
  26. ),
  27. url(r"^$", view=nr_views.paper_index, name="nr-index"),
  28. # We use a custom view so we can increment the view_count
  29. url(
  30. r"^editorials/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\-\d\w]+)/$",
  31. view=nr_views.editorial_detail,
  32. name="nr-editorial-detail",
  33. ),
  34. url(
  35. r"(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\-\d\w]+)/$",
  36. view=nr_views.story_detail,
  37. name="nr-story-detail",
  38. ),
  39. url(r"^tags/$", view=nr_views.tag_index, name="nr-tag-index"),
  40. url(r"^tags/(?P<name>[\-\d\w]+)/$", view=nr_views.tag_detail, name="nr-tag-detail"),
  41. )
  42. # editorials
  43. editorial_args = {
  44. "date_field": "published_on",
  45. "queryset": Editorial.objects.published(),
  46. }
  47. urlpatterns += patterns(
  48. "django.views.generic.date_based",
  49. url(
  50. r"^editorials/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$",
  51. "archive_day",
  52. editorial_args,
  53. name="nr-editorial-archive-day",
  54. ),
  55. url(
  56. r"^editorials/(?P<year>\d{4})/(?P<month>[a-z]{3})/$",
  57. "archive_month",
  58. editorial_args,
  59. name="nr-editorial-archive-month",
  60. ),
  61. url(
  62. r"^editorials/(?P<year>\d{4})/$",
  63. "archive_year",
  64. editorial_args,
  65. name="nr-editorial-archive-year",
  66. ),
  67. )
  68. # stories
  69. story_args = {"date_field": "published_on", "queryset": Story.objects.published()}
  70. urlpatterns += patterns(
  71. "django.views.generic.date_based",
  72. # url(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\-\d\w]+)/$', 'object_detail', story_args, name='nr-story-detail'),
  73. url(
  74. r"(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$",
  75. "archive_day",
  76. story_args,
  77. name="nr-story-archive-day",
  78. ),
  79. url(
  80. r"(?P<year>\d{4})/(?P<month>[a-z]{3})/$",
  81. "archive_month",
  82. story_args,
  83. name="nr-story-archive-month",
  84. ),
  85. url(r"(?P<year>\d{4})/$", "archive_year", story_args, name="nr-story-archive-year"),
  86. )
  87. urlpatterns += patterns(
  88. "django.views.generic.list_detail",
  89. url(
  90. r"page/(?P<page>[0-9]+)/$",
  91. "object_list",
  92. {"queryset": Story.objects.published(), "allow_empty": True, "paginate_by": 5},
  93. name="nr-story-list",
  94. ),
  95. )