From 838fdcbfa46ce93aeb58e585159263c9f24f242a Mon Sep 17 00:00:00 2001 From: Ben Sturmfels Date: Fri, 20 Oct 2023 12:47:58 +1100 Subject: [PATCH] Move fundraising goal banner into a template include --- .../fundraiser_goal_banner_partial.html | 77 +++++++++++++++++++ .../templates/base_conservancy.html | 77 +------------------ 2 files changed, 78 insertions(+), 76 deletions(-) create mode 100644 www/conservancy/apps/fundgoal/templates/fundgoal/fundraiser_goal_banner_partial.html diff --git a/www/conservancy/apps/fundgoal/templates/fundgoal/fundraiser_goal_banner_partial.html b/www/conservancy/apps/fundgoal/templates/fundgoal/fundraiser_goal_banner_partial.html new file mode 100644 index 00000000..87c25761 --- /dev/null +++ b/www/conservancy/apps/fundgoal/templates/fundgoal/fundraiser_goal_banner_partial.html @@ -0,0 +1,77 @@ +{% load humanize %} +{% load subtract %} + +{% comment %} +# FUNDRAISER VARIABLES AND CONSTANTS GUIDE + +## From Local Context + +* 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: The number of new Sustainers that can be double-matched this fundraiser. + (No, this name makes no sense. We're repurposing an existing model field for this new reason.) +* sitefundgoal_endtime: DateTime when sitefundgoal ends. + +## Local convenience variables + +* 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 +* this_match_exceeded: this_match_so_far - this_match_goal + +{% endcomment %} +{% 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 sitefundgoal_timeleft=sitefundgoal.fundraiser_endtime|subtract:datetime_now this_match_exceeded=this_match_so_far|subtract:this_match_goal %} +
+
+
+ {% if this_match_remaining <= 0 %} + Thanks to so many donors, 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 + {% elif sitefundgoal_timeleft.days == 0 %} + Through today only, the + {% elif sitefundgoal_timeleft.days == 1 %} + Through tomorrow only, the + {% elif sitefundgoal_timeleft.days < 14 %} + For only {{ sitefundgoal_timeleft.days }} more days, the + {% else %} + Until January 15, the + {% endif %} + next ${{ this_match_remaining|floatformat:0|intcomma }} of support we receive will be matched! + + {% endif %} +
+ +{% if 1 %} + +
+ {% if this_match_remaining <= 0 %} +
+ ${{ this_match_goal|floatformat:0|intcomma }} fully matched! +
+
+ ${{this_match_exceeded|floatformat:0|intcomma }} additional
raised!
+
+ {% else %} +
+ ${{ this_match_so_far|floatformat:0|intcomma }} matched! +
+
+ ${{ this_match_remaining|floatformat:0|intcomma }} to go! +
+ {% endif %} +
+
+{% endif %} + +
+
+{% endwith %} +{% endwith %} diff --git a/www/conservancy/templates/base_conservancy.html b/www/conservancy/templates/base_conservancy.html index d24f0796..533e44fc 100644 --- a/www/conservancy/templates/base_conservancy.html +++ b/www/conservancy/templates/base_conservancy.html @@ -1,5 +1,3 @@ -{% load humanize %} -{% load subtract %} {% load min %} {% load static %} @@ -83,81 +81,8 @@ -{% comment %} -# FUNDRAISER VARIABLES AND CONSTANTS GUIDE - -## From Local Context - -* 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: The number of new Sustainers that can be double-matched this fundraiser. - (No, this name makes no sense. We're repurposing an existing model field for this new reason.) -* sitefundgoal_endtime: DateTime when sitefundgoal ends. - -## Local convenience variables - -* 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 -* this_match_exceeded: this_match_so_far - this_match_goal - -{% endcomment %} {% if datetime_now < sitefundgoal.fundraiser_endtime %} -{% 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 sitefundgoal_timeleft=sitefundgoal.fundraiser_endtime|subtract:datetime_now this_match_exceeded=this_match_so_far|subtract:this_match_goal %} -
-
-
- {% if this_match_remaining <= 0 %} - Thanks to so many donors, 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 - {% elif sitefundgoal_timeleft.days == 0 %} - Through today only, the - {% elif sitefundgoal_timeleft.days == 1 %} - Through tomorrow only, the - {% elif sitefundgoal_timeleft.days < 14 %} - For only {{ sitefundgoal_timeleft.days }} more days, the - {% else %} - Until January 15, the - {% endif %} - next ${{ this_match_remaining|floatformat:0|intcomma }} of support we receive will be matched! - - {% endif %} -
- -{% if 1 %} - -
- {% if this_match_remaining <= 0 %} -
- ${{ this_match_goal|floatformat:0|intcomma }} fully matched! -
-
- ${{this_match_exceeded|floatformat:0|intcomma }} additional
raised!
-
- {% else %} -
- ${{ this_match_so_far|floatformat:0|intcomma }} matched! -
-
- ${{ this_match_remaining|floatformat:0|intcomma }} to go! -
- {% endif %} -
-
-{% endif %} - -
-
-{% endwith %} -{% endwith %} + {% include "fundgoal/fundraiser_goal_banner_partial.html" %} {% endif %}