urls.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from django.conf import settings
  2. from django.conf.urls.defaults import *
  3. from documents.models import *
  4. from documents import views as dc_views
  5. from documents.feeds import LatestDocumentsFeed
  6. # custom views stories
  7. urlpatterns = patterns(
  8. "documents.views",
  9. url(r"^$", view=dc_views.index, name="dc-index"),
  10. url(r"^feed.xml", LatestDocumentsFeed(), name="dc-feed"),
  11. # We use a custom view so we can increment the view_count
  12. url(
  13. r"(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\-\d\w]+)/$",
  14. view=dc_views.document_detail,
  15. name="dc-document-detail",
  16. ),
  17. url(
  18. r"(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\-\d\w]+)/$",
  19. view=dc_views.document_detail,
  20. name="dc-pdf-document-detail",
  21. ),
  22. )
  23. doc_args = {"date_field": "published_on", "queryset": Document.published_objects.all()}
  24. urlpatterns += patterns(
  25. "django.views.generic.date_based",
  26. url(
  27. r"(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$",
  28. "archive_day",
  29. doc_args,
  30. name="dc-document-archive-day",
  31. ),
  32. url(
  33. r"(?P<year>\d{4})/(?P<month>[a-z]{3})/$",
  34. "archive_month",
  35. doc_args,
  36. name="dc-document-archive-month",
  37. ),
  38. url(
  39. r"(?P<year>\d{4})/$", "archive_year", doc_args, name="dc-document-archive-year"
  40. ),
  41. )