website/conservancy/context_processors.py
Bradley M. Kuhn cf5bd77c56 Support two fundraising bars for a stretch match
Long ago, when the bar was all Javascript, we had the ability to have
sub-targets in a single bar.  I was not able to invest the time
necessary to figure out how to do that again using the newer setup
for the fundraising bar, so instead I've added the ability to have a
stretch match bar that appears above the other one once the first
match period ends.

While it handles most of the weird cases with some grace, it will
probably look weird unless you set up a `SITE_FUNDGOAL_0` as a match
that finishes at least a week or two before `SITE_FUNDGOAL_1`.

The two aren't really aware of each other, either, so you have to
make sure the objects are updated properly (i.e., it *will* display
the stretch when `SITE_FUNDGOAL_0` ends even if there are match funds
remaining in `SITE_FUNDGOAL_0`).

A better solution should be found and implemented before 2026-11-22.
If you're actually reading this commit message for a reason other
than historical interest and that date has past, you're probably in
big trouble right now. 😬
2026-01-14 14:16:44 -08:00

18 lines
612 B
Python

from django.conf import settings
from .fundgoal.models import FundraisingGoal
def sitefundraiser(request):
try:
fundgoal0 = FundraisingGoal.objects.get(fundraiser_code_name=settings.SITE_FUNDGOAL_0)
except FundraisingGoal.DoesNotExist:
fundgoal0 = None
try:
fundgoal1 = FundraisingGoal.objects.get(fundraiser_code_name=settings.SITE_FUNDGOAL_1)
except FundraisingGoal.DoesNotExist:
fundgoal1 = None
return {'sitefundgoal0': fundgoal0, 'sitefundgoal1': fundgoal1 }
def host_url(request):
return {'host_url': request.build_absolute_uri('/').rstrip('/')}