2016-11-28 19:53:27 +00:00
|
|
|
from datetime import datetime
|
2010-09-26 21:20:05 +00:00
|
|
|
|
2023-10-19 22:44:24 +00:00
|
|
|
from django.shortcuts import render
|
|
|
|
|
|
|
|
from .apps.blog.models import Entry
|
|
|
|
from .apps.news.models import PressRelease
|
|
|
|
from .apps.supporters.models import Supporter
|
|
|
|
|
|
|
|
|
2010-09-26 21:20:05 +00:00
|
|
|
def view(request):
|
|
|
|
"""Conservancy front page view
|
|
|
|
|
|
|
|
Performs all object queries necessary to render the front page.
|
|
|
|
"""
|
2016-11-28 19:53:27 +00:00
|
|
|
now = datetime.now()
|
|
|
|
context = {
|
|
|
|
'press_releases': PressRelease.objects.all().filter(pub_date__lte=now, sites=2)[:5],
|
2021-10-13 10:20:58 +00:00
|
|
|
'supporters_count': Supporter.objects.all().filter(display_until_date__gte=now).count(),
|
2023-10-19 22:44:24 +00:00
|
|
|
'blog': Entry.objects.all().filter(pub_date__lte=now)[:5],
|
2010-09-26 21:20:05 +00:00
|
|
|
}
|
2023-10-19 22:44:24 +00:00
|
|
|
return render(request, "frontpage.html", context)
|