From ee6db3c3dc4dbe8903265fde6e799872dcd0fc71 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 8 Feb 2016 13:18:18 -0500 Subject: added note month and year archives --- app/notes/urls.py | 11 ++++++++++- app/notes/views.py | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/notes/urls.py b/app/notes/urls.py index 00a8cce..0f9fad7 100644 --- a/app/notes/urls.py +++ b/app/notes/urls.py @@ -21,7 +21,16 @@ urlpatterns = [ views.NoteDetailView.as_view(), name="detail" ), - + url( + r'^(?P[0-9]{4})/(?P[0-9]{2})/$', + views.NoteMonthArchiveView.as_view(month_format='%m'), + name="list_month" + ), + url( + r'(?P\d{4})/$', + views.NoteYearArchiveView.as_view(), + name="list_year" + ), url( diff --git a/app/notes/views.py b/app/notes/views.py index b8bc04e..1fbe6f4 100644 --- a/app/notes/views.py +++ b/app/notes/views.py @@ -1,5 +1,6 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext +from django.views.generic.dates import YearArchiveView, MonthArchiveView from django.views.generic.detail import DetailView from utils.views import PaginatedListView @@ -29,6 +30,21 @@ class NoteDetailViewAMP(NoteDetailView): template_name = "details/entry.amp" +class NoteYearArchiveView(YearArchiveView): + queryset = LuxNote.objects.all() + date_field = "pub_date" + make_object_list = True + allow_future = True + template_name = "archives/notes_date.html" + + +class NoteMonthArchiveView(MonthArchiveView): + queryset = LuxNote.objects.all() + date_field = "pub_date" + allow_future = True + template_name = "archives/notes_date.html" + + """ Legacy Notes views """ -- cgit v1.2.3-70-g09d2