Changeset - c7d4309149a8
[Not reviewed]
0 2 0
Bradley Kuhn (bkuhn) - 7 years ago 2015-03-04 23:40:54
bkuhn@ebb.org
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.
2 files changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/blog/urls.py
Show inline comments
...
 
@@ -58,13 +58,17 @@ def all_tags_by_use_amount():
 
    return retval
 

	
 
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
 
# functions below (i.e. make both lines below end in '()')
 

	
 
extra_context['all_authors'] = all_authors
 
extra_context['all_tags'] = all_tags_by_use_amount
 
extra_context['all_year_list'] = all_year_list
www/conservancy/templates/base_blog.html
Show inline comments
...
 
@@ -21,16 +21,16 @@
 
<ul>
 
{% for tag in all_tags %}
 
<li><a href="{{ tag.get_absolute_url }}">{{ tag.label }}</a>
 
(<a href="/feeds/blog/?tag={{ tag.slug }}">rss</a>)</li>
 
{% endfor %}
 
</ul>
 
{% if date_list %}
 
{% if all_year_list %}
 
<h2>Blog Index by Year</h2>
 
<ul>
 
{% for year in date_list reversed %}<li><a href="{{ year|date:"Y" }}/">{{ year|date:"Y" }}</a></li>{% endfor %}
 
{% for year in all_year_list reversed %}<li><a href="{{ year|date:"Y" }}/">{{ year|date:"Y" }}</a></li>{% endfor %}
 
</ul>
 
{% endif %}
 

	
 
<h2><a href="/blog/">See all posts&hellip;</a></h2>
 
<!-- <p><a href="/blog/query/">Query...</a></p> -->
 
         </div>
0 comments (0 inline, 0 general)