Ben Sturmfels
b7e2ce2a4d
The relative imports make it clearer what code is within the project and where it's coming from.
21 lines
684 B
Python
21 lines
684 B
Python
from datetime import datetime
|
|
|
|
from django.shortcuts import render
|
|
|
|
from .apps.blog.models import Entry
|
|
from .apps.news.models import PressRelease
|
|
from .apps.supporters.models import Supporter
|
|
|
|
|
|
def view(request):
|
|
"""Conservancy front page view
|
|
|
|
Performs all object queries necessary to render the front page.
|
|
"""
|
|
now = datetime.now()
|
|
context = {
|
|
'press_releases': PressRelease.objects.all().filter(pub_date__lte=now, sites=2)[:5],
|
|
'supporters_count': Supporter.objects.all().filter(display_until_date__gte=now).count(),
|
|
'blog': Entry.objects.all().filter(pub_date__lte=now)[:5],
|
|
}
|
|
return render(request, "frontpage.html", context)
|