Place Supporters counter on front & sponsors pages

The number of current supporters now appears on the frontpage and the
sponsors page.
This commit is contained in:
Bradley M. Kuhn 2015-01-03 10:02:02 -05:00
parent f723a74f51
commit e45322d3c9
4 changed files with 8 additions and 2 deletions

View file

@ -1,4 +1,5 @@
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from conservancy.apps.supporters.models import Supporter as Supporter
from conservancy.apps.news.models import PressRelease from conservancy.apps.news.models import PressRelease
from conservancy.apps.blog.models import Entry as BlogEntry from conservancy.apps.blog.models import Entry as BlogEntry
from datetime import datetime, timedelta from datetime import datetime, timedelta
@ -9,11 +10,13 @@ def view(request):
Performs all object queries necessary to render the front page. Performs all object queries necessary to render the front page.
""" """
supporters_count = len(Supporter.objects.all().filter(display_until_date__gte=datetime.now()))
press_releases = PressRelease.objects.all().filter(pub_date__lte=datetime.now(), sites=2)[:5] press_releases = PressRelease.objects.all().filter(pub_date__lte=datetime.now(), sites=2)[:5]
blog = BlogEntry.objects.all().filter(pub_date__lte=datetime.now())[:3] blog = BlogEntry.objects.all().filter(pub_date__lte=datetime.now())[:3]
c = { c = {
'press_releases': press_releases, 'press_releases': press_releases,
'supporters_count': supporters_count,
'blog' : blog 'blog' : blog
} }
return render_to_response("frontpage.html", c) return render_to_response("frontpage.html", c)

View file

@ -9,11 +9,13 @@ def view(request):
""" """
supporters = Supporter.objects.all().filter(display_until_date__gte=datetime.now()) supporters = Supporter.objects.all().filter(display_until_date__gte=datetime.now())
supporters_count = len(supporters)
anonymous_count = len(supporters.filter(display_name = 'Anonymous')) anonymous_count = len(supporters.filter(display_name = 'Anonymous'))
supporters = supporters.exclude(display_name = 'Anonymous') supporters = supporters.exclude(display_name = 'Anonymous')
c = { c = {
'supporters' : supporters, 'supporters' : supporters,
'supporters_count' : supporters_count,
'anonymous_count' : anonymous_count 'anonymous_count' : anonymous_count
} }
return render_to_response("sponsors.html", c) return render_to_response("sponsors.html", c)

View file

@ -36,7 +36,7 @@
<h2>Support Conservancy</h2> <h2>Support Conservancy</h2>
<p>As a 501(c)(3) non-profit organization, Conservancy relies on <p>As a 501(c)(3) non-profit organization, Conservancy relies on
charitable donations for its operations. charitable donations for its operations.
Please <a href="/supporter/"><strong>become a Conservancy support Please join {{supporters_count|safe}} others and <a href="/supporter/"><strong>become a Conservancy support
today</strong></a> and/or <a href="/donate/">donate generously</a> to help our work! today</strong></a> and/or <a href="/donate/">donate generously</a> to help our work!
</p> </p>
<h2>Follow Conservancy News &amp; Blogs</h2> <h2>Follow Conservancy News &amp; Blogs</h2>

View file

@ -51,7 +51,8 @@ any of its sponsors.</p>
<br/> <br/>
<h2>Supporters</h2> <h2>Supporters</h2>
<p>Conservancy Supporters are individuals who give $120 or more annually as <p>Conservancy currently has {{supporters_count|safe}} Supporters.
Conservancy Supporters are individuals who give $120 or more annually as
part of <a href="/supporter/">the Official Conservancy Supporter part of <a href="/supporter/">the Official Conservancy Supporter
program</a>. Those who request public acknowledgment are listed here in program</a>. Those who request public acknowledgment are listed here in
alphabetical order by surname:</p> alphabetical order by surname:</p>