From c7d4309149a861a961c0f1d6b76a11e1b27068f6 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 4 Mar 2015 15:40:54 -0800 Subject: [PATCH] Fix blog by year index. Add an additional context data that is always the entire list of years, and use that instead of date_list for the current queryset. --- www/conservancy/apps/blog/urls.py | 4 ++++ www/conservancy/templates/base_blog.html | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/www/conservancy/apps/blog/urls.py b/www/conservancy/apps/blog/urls.py index f294de57..f75f96e0 100644 --- a/www/conservancy/apps/blog/urls.py +++ b/www/conservancy/apps/blog/urls.py @@ -61,6 +61,9 @@ def all_authors(): return sorted(Person.objects.filter(entry__isnull=False).distinct(), key=last_name) +def all_year_list(): + return Entry.objects.dates(date_field, 'year') + # The functions are passed to the context uncalled so they will be # called for each web request. If we want to only make these database # queries a single time when a web server process begins, call both @@ -68,3 +71,4 @@ def all_authors(): extra_context['all_authors'] = all_authors extra_context['all_tags'] = all_tags_by_use_amount +extra_context['all_year_list'] = all_year_list diff --git a/www/conservancy/templates/base_blog.html b/www/conservancy/templates/base_blog.html index 34367de5..14762a29 100644 --- a/www/conservancy/templates/base_blog.html +++ b/www/conservancy/templates/base_blog.html @@ -24,10 +24,10 @@ (rss) {% endfor %} -{% if date_list %} +{% if all_year_list %}

Blog Index by Year

{% endif %}