diff options
author | luxagraf <sng@luxagraf.net> | 2015-11-04 21:40:38 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2015-11-04 21:40:38 -0500 |
commit | 24b760797fd26e80c1738c614408b02b50284d4d (patch) | |
tree | 3f847d1d9d049f8c456cc31c2ad5980101aecb11 /app/blog/urls.py | |
parent | 535038e99462cf3738e48871ff69b0192ec62572 (diff) |
cleaned up the code in blog and refactored to PEP 8 and class based views
Diffstat (limited to 'app/blog/urls.py')
-rw-r--r-- | app/blog/urls.py | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/app/blog/urls.py b/app/blog/urls.py index eb69873..d8fa395 100644 --- a/app/blog/urls.py +++ b/app/blog/urls.py @@ -1,21 +1,44 @@ -from django.conf.urls import * +from django.conf.urls import url from django.views.generic.base import RedirectView -""" -urlpatterns = patterns('', - (r'(?P<slug>[-\w]+)/(?P<page>\d+)/$', 'blog.views.entry_list_by_area'), - (r'(?P<page>\d+)/$', 'blog.views.entry_list'), - (r'(?P<slug>[-\w]+)/$', RedirectView.as_view(url="/writing/%(slug)s/1/")), - (r'', RedirectView.as_view(url="/writing/1/")), -) -""" +from . import views -urlpatterns = patterns('', - url(r'(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[-\w]+)$', 'blog.views.entry_detail'), - url(r'(?P<year>\d{4})/(?P<month>\d{2})/$', 'blog.views.date_list', name="blog_by_month"), - url(r'(?P<year>\d{4})/$', 'blog.views.date_list', name="blog_by_year"), - (r'(?P<slug>[-\w]+)/(?P<page>\d+)/$', 'blog.views.entry_list_by_area'), - (r'(?P<page>\d+)/$', 'blog.views.entry_list'), - url(r'(?P<slug>[-\w]+)/$', RedirectView.as_view(url="/jrnl/%(slug)s/1/")), - url(r'', RedirectView.as_view(url="/jrnl/1/")), -) +urlpatterns = [ + url( + regex=r'(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[-\w]+)$', + view=views.EntryDetailView.as_view(), + name="detail" + ), + url( + regex=r'^(?P<year>[0-9]{4})/(?P<month>[0-9]+)/$', + view=views.EntryMonthArchiveView.as_view(month_format='%m'), + name="list_month" + ), + url( + regex=r'(?P<year>\d{4})/$', + view=views.EntryYearArchiveView.as_view(), + name="list_year" + ), + url( + regex=r'(?P<slug>[-\w]+)/(?P<page>\d+)/$', + view=views.EntryCountryList.as_view(), + name="list_country" + ), + url( + regex=r'(?P<page>\d+)/$', + view=views.EntryList.as_view(), + name="list" + ), + # redirect /slug/ to /slug/1/ for live server + url( + regex=r'(?P<slug>[-\w]+)/$', + view=RedirectView.as_view(url="/jrnl/%(slug)s/1/"), + name="live_location_redirect" + ), + # redirect / to /1/ for live server + url( + regex=r'', + view=RedirectView.as_view(url="/jrnl/1/"), + name="live_redirect" + ), +] |