From 67e64d3a6c8f49fe9e5ca0985f987382d542a598 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Fri, 22 Nov 2019 09:46:07 -0500 Subject: [PATCH] base: Break out individual local context variables. --- www/conservancy/local_context_processors.py | 3 +- .../templates/base_conservancy.html | 30 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/www/conservancy/local_context_processors.py b/www/conservancy/local_context_processors.py index 7b0f907d..d8830bd2 100644 --- a/www/conservancy/local_context_processors.py +++ b/www/conservancy/local_context_processors.py @@ -20,8 +20,9 @@ def fundgoal_lookup(fundraiser_sought): def sitefundraiser(request): return { + 'datetime_now': DateTime.now(UTC), 'sitefundgoal': fundgoal_lookup(SITE_FUNDGOAL), - 'sitefundgoal_timeleft': FUNDGOAL_ENDTIMES[SITE_FUNDGOAL] - DateTime.now(UTC), + 'sitefundgoal_endtime': FUNDGOAL_ENDTIMES[SITE_FUNDGOAL], } if conservancy.settings.FORCE_CANONICAL_HOSTNAME: diff --git a/www/conservancy/templates/base_conservancy.html b/www/conservancy/templates/base_conservancy.html index 05f32300..99805998 100644 --- a/www/conservancy/templates/base_conservancy.html +++ b/www/conservancy/templates/base_conservancy.html @@ -45,32 +45,36 @@ {% comment %} -FUNDRAISER VARIABLES AND CONSTANTS GUIDE +# FUNDRAISER VARIABLES AND CONSTANTS GUIDE -sitefundgoal attributes: +## From Local Context -fundraiser_goal_amount: The amount being matched -fundraiser_so_far_amount: The amount contributed so far -fundraiser_donation_count: The number of people who have contributed so far -fundraiser_donation_count_disclose_threshold: Not used +* datetime_now: Current DateTime in UTC +* sitefundgoal: The current FundraisingGoal. Attributes: + * fundraiser_goal_amount: The amount being matched + * fundraiser_so_far_amount: The amount contributed so far + * fundraiser_donation_count: The number of people who have contributed so far + * fundraiser_donation_count_disclose_threshold: Not used +* sitefundgoal_endtime: DateTime when sitefundgoal ends. -Local convenience variables: +## Local convenience variables -this_match_goal: The amount being matched -this_match_so_far: The amount contributed so far -this_match_remaining: this_match_goal - this_match_so_far +* sitefundgoal_timeleft: TimeDelta for how much time remains in the current fundraiser +* this_match_goal: The amount being matched +* this_match_so_far: The amount contributed so far +* this_match_remaining: this_match_goal - this_match_so_far {% endcomment %} {% comment %} {% if sitefundgoal %} {% with this_match_goal=sitefundgoal.fundraiser_goal_amount this_match_so_far=sitefundgoal.fundraiser_so_far_amount %} -{% with this_match_remaining=this_match_goal|subtract:this_match_so_far %} +{% with this_match_remaining=this_match_goal|subtract:this_match_so_far sitefundgoal_timeleft=sitefundgoal_endtime|subtract:datetime_now %}

{% if this_match_remaining <= 0 %} - Thanks to {{ sitegoal.fundraiser_donation_count|intcomma }} Supporters we earned our full match! Help us go further to stand up for software - freedom — sign up now! + Thanks to {{ sitegoal.fundraiser_donation_count|intcomma }} Supporters we earned our full match! + Help us go further to stand up for software freedom — sign up now! {% else %} {% if sitefundgoal_timeleft.total_seconds <= 0 %} The