2010-09-26 21:20:05 +00:00
|
|
|
from django.shortcuts import render_to_response
|
2015-12-01 02:49:50 +00:00
|
|
|
from conservancy import context_processors as context_processors
|
|
|
|
from django.template import RequestContext
|
2015-01-03 15:02:02 +00:00
|
|
|
from conservancy.apps.supporters.models import Supporter as Supporter
|
2010-09-26 21:56:29 +00:00
|
|
|
from conservancy.apps.news.models import PressRelease
|
2010-10-04 15:27:04 +00:00
|
|
|
from conservancy.apps.blog.models import Entry as BlogEntry
|
2010-09-26 21:20:05 +00:00
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
|
|
def view(request):
|
|
|
|
"""Conservancy front page view
|
|
|
|
|
|
|
|
Performs all object queries necessary to render the front page.
|
|
|
|
"""
|
|
|
|
|
2015-01-03 15:02:02 +00:00
|
|
|
supporters_count = len(Supporter.objects.all().filter(display_until_date__gte=datetime.now()))
|
2010-09-26 21:20:05 +00:00
|
|
|
press_releases = PressRelease.objects.all().filter(pub_date__lte=datetime.now(), sites=2)[:5]
|
2010-10-04 15:27:04 +00:00
|
|
|
blog = BlogEntry.objects.all().filter(pub_date__lte=datetime.now())[:3]
|
2010-09-26 21:20:05 +00:00
|
|
|
|
|
|
|
c = {
|
|
|
|
'press_releases': press_releases,
|
2015-01-03 15:02:02 +00:00
|
|
|
'supporters_count': supporters_count,
|
2010-10-04 15:27:04 +00:00
|
|
|
'blog' : blog
|
2010-09-26 21:20:05 +00:00
|
|
|
}
|
2015-12-01 02:49:50 +00:00
|
|
|
return render_to_response("frontpage.html", c, context_instance=RequestContext(request))
|