Rework if-then-else mess; format div's

This commit is contained in:
Bradley Kuhn 2026-01-14 13:30:08 -08:00
parent 76ef5019af
commit ce2bbbba7b

View file

@ -1,111 +1,104 @@
{% load humanize %}
{% if sitefundgoal1.days_remaining >= -22 or sitefundgoal0.days_remaining >= -22 %} {# IF LEVEL 0 (only show this at all for 7 days after fundraiser and stretch are over) #}
<div class="fundraiser-top-text ph3 pt2 pb3 mb2 mb3-ns">
<div class="mw8 center ph2 ph4-ns">
<div class="mt2 mb3 tc">
{% if sitefundgoal0.match_remaining <= 0 %} {# LEVEL 1 #}
{% if sitefundgoal1.days_remaining >= 0 %} {# LEVEL 2.0 #}
{% if sitefundgoal1.match_remaining <= 0 %} {# LEFT OFF HERE #}
Thanks to so many donors, we earned our full original match donation &mdash; <em>as well as</em> our <strong>extended</strong> match!
Help us go further to stand up for software freedom &mdash; <a href="/sustainer">sign up now</a>!
{% else %}
Thanks to so many donors, we met <em>our largest match donation ever of <strong>$211,939</strong>.
A generous anonymous donor has provided <em>another $40,000</em> of matching funds.
<a href="https://sfconservancy.org/sustainer/">Give now to help us</a> reach this stretch goal!<br/>
{% endif %}
{% if sitefundgoal1.days_remaining == 0 %}
For the <strongly>only</strong> the next {{ sitefundgoal1.hours_remaining }} hour{{ sitefundgoal1.hours_remaining|pluralize }}, the
{% elif sitefundgoal1.days_remaining == 1 %}
Through tomorrow only, the
{% elif sitefundgoal1.days_remaining < 14 %}
For only {{ sitefundgoal1.days_remaining }} more days, the
{% else %}
Until FIXME_DATE, the
{% endif %}
next <b>${{ sitefundgoal1.match_remaining|floatformat:0|intcomma }}</b> of <a href="/sustainer/">support we receive</a> will be matched!
{% endif %}
{% else %} {# ELSE LEVEL 2.0 when (sitefundgoal1.days_remaining < 0) #}
Thanks to all our donors who participated in our
historic donation match challenge! Thanks to you, we raised our goal of <b>$503,878</b> to support software freedom:
{% endif %} {# ENDIF LEVEL 2.0 (whether or not there are any sitefundgoal1.days_remaining) #}
<div class="fundraiser-top-text ph3 pt2 pb3 mb2 mb3-ns">
<div class="mw8 center ph2 ph4-ns">
<div class="mt2 mb3 tc">
{% if sitefundgoal0.match_remaining <= 0 %} {# IF LEVEL 0.1 #}
{% if sitefundgoal1.days_remaining >= 0 %} {# IF LEVEL 0.1.0 #}
{% if sitefundgoal1.match_remaining <= 0 %} {# IF LEVEL 0.1.0.0 #}
{# The problem with automating this is that it does not actually test here if we made the match or not; we are usually watching it so carefully that it should not matter? We also have made ever match we did since 2015, so no one has probably thought hard about this problem. -- bkuhn #}
Thanks to so many donors, we earned our full original match donation &mdash; <em>as well as</em> our <strong>extended</strong> match!
Help us go further to stand up for software freedom &mdash; <a href="/sustainer">sign up now</a>!
{% else %} {# ELSE LEVEL 0.1.0.0 when sitefundgoal1.match_remaining > 0 #}
Thanks to so many donors, we met <em>our largest match donation ever of <strong>$211,939</strong>.
A generous anonymous donor has provided <em>another $40,000</em> of matching funds.
<a href="https://sfconservancy.org/sustainer/">Give now to help us</a> reach this stretch goal!<br/>
{% if sitefundgoal1.days_remaining == 0 %} {# IF LEVEL 0.1.0.0.0 sitefundgoal1.days_remaining alternatives #}
For the <strong>only</strong> the next {{ sitefundgoal1.hours_remaining }} hour{{ sitefundgoal1.hours_remaining|pluralize }}, the
{% elif sitefundgoal1.days_remaining == 1 %} {# ELIF LEVEL 0.1.0.0.0 sitefundgoal1.days_remaining alternatives #}
Through tomorrow only, the
{% elif sitefundgoal1.days_remaining < 14 %} {# ELIF LEVEL 0.1.0.0.0 sitefundgoal1.days_remaining alternatives #}
For only {{ sitefundgoal1.days_remaining }} more days, the
{% else %} {# ELIF LEVEL 0.1.0.0.0 sitefundgoal1.days_remaining alternatives #}
Until FIXME_DATE, the
{% endif %} {# ELSE LEVEL 0.1.0.0.0 sitefundgoal1.days_remaining alternatives #}
next <b>${{ sitefundgoal1.match_remaining|floatformat:0|intcomma }}</b> of <a href="/sustainer/">financial support we receive</a> will be matched!
{% endif %} {# ENDIF LEVEL 0.1.0.0 (testing whether or not sitefundgoal1.match_remaining has anything left in it) #}
{% else %} {# ELSE LEVEL 0.1.0 when (sitefundgoal1.days_remaining < 0) #}
Thanks to all our donors who participated in our historic donation match challenge!
Thanks to all of you, we raised our goal of <b>$503,878</b> to support software freedom:
{% endif %} {# ENDIF LEVEL 0.1.0 (whether or not there are any sitefundgoal1.days_remaining) #}
<a href="/sustainer/" style="text-decoration: none !important">
<div id="siteprogressbar" class="flex items-stretch w-100">
{% if sitefundgoal1.match_remaining <= 0 %}
<div class="progress matched ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal1.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100 ph1 done">${{ sitefundgoal1.fundraiser_goal_amount|floatformat:0|intcomma }} fully matched!</span>
</div>
{% else %}
<div class="progress ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal1.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100">${{ sitefundgoal1.fundraiser_so_far_amount|floatformat:0|intcomma }} matched!</span>
</div>
<div class="final-goal pv1 b flex items-center" style="flex-basis: {{ sitefundgoal1.match_remaining }}px">
<span id="site-fundraiser-final-goal" class="goalText tc w-100 ph1">${{ sitefundgoal1.match_remaining|floatformat:0|intcomma }} to go!</span>
</div>
</div>
<a href="/sustainer/" style="text-decoration: none !important">
<div id="siteprogressbar" class="flex items-stretch w-100">
{% if sitefundgoal0.match_remaining <= 0 %}
<div class="progress matched ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100 ph1 done">${{ sitefundgoal0.fundraiser_goal_amount|floatformat:0|intcomma }} fully matched!</span>
</div>
{% else %}
<div class="progress ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100">${{ sitefundgoal0.fundraiser_so_far_amount|floatformat:0|intcomma }} matched!</span>
</div>
<div class="final-goal pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.match_remaining }}px">
<span id="site-fundraiser-final-goal" class="goalText tc w-100 ph1">${{ sitefundgoal0.match_remaining|floatformat:0|intcomma }} to go!</span>
{% endif %}
</div>
{% if sitefundgoal1.match_remaining <= 0 %} {# IF LEVEL 0.1.1 #}
<div class="progress matched ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal1.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100 ph1 done">${{ sitefundgoal1.fundraiser_goal_amount|floatformat:0|intcomma }} fully matched!</span>
</div>
{% else %} {# ELSE LEVEL 0.1.1 when sitefundgoal1.match_remaining > 0 #}
<div class="progress ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal1.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100">${{ sitefundgoal1.fundraiser_so_far_amount|floatformat:0|intcomma }} matched!</span>
</div>
<div class="final-goal pv1 b flex items-center" style="flex-basis: {{ sitefundgoal1.match_remaining }}px">
<span id="site-fundraiser-final-goal" class="goalText tc w-100 ph1">${{ sitefundgoal1.match_remaining|floatformat:0|intcomma }} to go!</span>
</div>
{% endif %} {# ENDIF LEVEL 0.1.1 testing whether or not sitefundgoal1.match_remaining has anything in it #}
</div>
</a>
</div>
</div>
{% endif %}
{% else %} {# ELSE LEVEL 1 when (sitefundgoal0.match_remaining > 0) #}
<div class="fundraiser-top-text ph3 pt2 pb3 mb2 mb3-ns">
<div class="mw8 center ph2 ph4-ns">
<div class="mt2 mb3 tc">
{% if sitefundgoal0.days_remaining >= 0 %}
{% if sitefundgoal0.match_remaining <= 0 %}
Thanks to so many donors, we earned our full match!
Help us go further to stand up for software freedom &mdash; <a href="/sustainer">sign up now</a>!
{% else %}
{% if sitefundgoal0.days_remaining == 0 %}
For the next {{ sitefundgoal0.hours_remaining }} hour{{ sitefundgoal0.hours_remaining|pluralize }} <strong>only</strong>, the
{% elif sitefundgoal0.days_remaining == 1 %}
Help us reach our goal of <b>$503,878</b> this season to keep SFC going. Through tomorrow only, the
{% elif sitefundgoal0.days_remaining < 14 %}
Help us reach our goal of <b>$503,878</b> this season to keep SFC going. For only {{ sitefundgoal0.days_remaining }} more days, the
{% else %}
Help us reach our goal of <b>$503,878</b> this season to keep SFC going. Until January 15, the
{% endif %}
next <b>${{ sitefundgoal0.match_remaining|floatformat:0|intcomma }}</b> of <a href="/sustainer/">support we receive</a> will be matched!
{% endif %}
{% else %}
Thanks to all our donors who participated in our
historic donation match challenge! Thanks to you, <a href="https://sfconservancy.org/blog/2025/jan/16/end-of-year-2024-fundraiser-a-massive-success/">we
raised more than $480k to support software freedom</a>:
{% endif %}
</div>
<a href="/sustainer/" style="text-decoration: none !important">
<div id="siteprogressbar" class="flex items-stretch w-100">
{% if sitefundgoal0.match_remaining <= 0 %}
<div class="progress matched ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100 ph1 done">${{ sitefundgoal0.fundraiser_goal_amount|floatformat:0|intcomma }} fully matched!</span>
</div>
{% else %}
<div class="progress ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100">${{ sitefundgoal0.fundraiser_so_far_amount|floatformat:0|intcomma }} matched!</span>
</div>
<div class="final-goal pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.match_remaining }}px">
<span id="site-fundraiser-final-goal" class="goalText tc w-100 ph1">${{ sitefundgoal0.match_remaining|floatformat:0|intcomma }} to go!</span>
</div>
{% endif %} {# ENDIF LEVEL 1, two choices for based on sitefundgoal0.match_remaining #}
{% if sitefundgoal0.match_remaining <= 0 %} {# IF LEVEL 0.1.2, pointless test of sitefundgoal0.match_remaining (if we get here, else block should never be used!) #}
<div class="progress matched ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100 ph1 done">${{ sitefundgoal0.fundraiser_goal_amount|floatformat:0|intcomma }} fully matched!</span>
</div>
{% else %} {# ELSE LEVEL 0.1.2, sitefundgoal0.match_remaining > 0 , but NOTE! We are here inside IF LEVEL 0.1, so this *should* never appear, included just for consistency #}
<div class="progress ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100">${{ sitefundgoal0.fundraiser_so_far_amount|floatformat:0|intcomma }} matched!</span>
</div>
<div class="final-goal pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.match_remaining }}px">
<span id="site-fundraiser-final-goal" class="goalText tc w-100 ph1">${{ sitefundgoal0.match_remaining|floatformat:0|intcomma }} to go!</span>
</div>
{% endif %} {# ENDIF LEVEL 0.1.2, this ends the pointless block here for consistency, see comment above. #}
</div>
</a>
{% else %} {# ELSE LEVEL 0.1 when (sitefundgoal0.match_remaining > 0) #}
{% if sitefundgoal0.days_remaining >= 0 %} {# IF LEVEL 0.1.3 #}
{% if sitefundgoal0.match_remaining <= 0 %} {# IF LEVEL 0.1.3.0 #}
Thanks to so many donors, we earned our full match!
Help us go further to stand up for software freedom &mdash; <a href="/sustainer">sign up now</a>!
{% else %} {# ELSE LEVEL 0.1.3.0 when sitefundgoal0.match_remaining > 0 #}
{% if sitefundgoal0.days_remaining == 0 %} {# IF LEVEL 0.1.3.0.0 testing options for sitefundgoal0.days_remaining #}
For the next {{ sitefundgoal0.hours_remaining }} hour{{ sitefundgoal0.hours_remaining|pluralize }} <strong>only</strong>, the
{% elif sitefundgoal0.days_remaining == 1 %} {# ELSIF LEVEL 0.1.3.0.0 testing options for sitefundgoal0.days_remaining #}
Help us reach our goal of <b>$503,878</b> this season to keep SFC going. Through tomorrow only, the
{% elif sitefundgoal0.days_remaining < 14 %} {# ELSIF LEVEL 0.1.3.0.0 testing options for sitefundgoal0.days_remaining #}
Help us reach our goal of <b>$503,878</b> this season to keep SFC going. For only {{ sitefundgoal0.days_remaining }} more days, the
{% else %} {# ELSE LEVEL 0.1.3.0.0 testing options for sitefundgoal0.days_remaining #}
Help us reach our goal of <b>$503,878</b> this season to keep SFC going. Until January 15, the
{% endif %} {# ENDIF LEVEL 0.1.3.0.0 testing options for sitefundgoal0.days_remaining #}
next <b>${{ sitefundgoal0.match_remaining|floatformat:0|intcomma }}</b> of <a href="/sustainer/">support we receive</a> will be matched!
{% else %} {# ENDIF LEVEL 0.1.3, sitefundgoal0.days_remaining < 0 #}
{# The problem with automating this is that it does not actually test here if we made the match or not; we are usually watching it so carefully that it should not matter? We also have made ever match we did since 2015, so no one has probably thought hard about this problem. -- bkuhn #}
Thanks to all our donors who participated in our historic donation match challenge!
{% endif %} {# ENDIF LEVEL 0.1.3, testing if there are any sitefundgoal0.days_remaining left #}
<a href="/sustainer/" style="text-decoration: none !important">
<div id="siteprogressbar" class="flex items-stretch w-100">
{% if sitefundgoal0.match_remaining <= 0 %} {# IF LEVEL 0.1.3.1 #}
<div class="progress matched ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100 ph1 done">${{ sitefundgoal0.fundraiser_goal_amount|floatformat:0|intcomma }} fully matched!</span>
</div>
{% else %} {# ELSE LEVEL 0.1.3.1 sitefundgoal0.match_remaining > 0 #}
<div class="progress ph1 pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.fundraiser_so_far_amount }}px">
<span id="site-fundraiser-match-count" class="soFarText tc w-100">${{ sitefundgoal0.fundraiser_so_far_amount|floatformat:0|intcomma }} matched!</span>
</div>
<div class="final-goal pv1 b flex items-center" style="flex-basis: {{ sitefundgoal0.match_remaining }}px">
<span id="site-fundraiser-final-goal" class="goalText tc w-100 ph1">${{ sitefundgoal0.match_remaining|floatformat:0|intcomma }} to go!</span>
</div>
{% endif %} {# ENDIF LEVEL 0.1.3.1 sitefundgoal0.match_remaining #}
</div>
</a>
{% endif %} {# ENDIF LEVEL 0.1, two choices for based on sitefundgoal0.match_remaining #}
</div>
</div>
</div>
{% endif %} {# ENDIF LEVEL 0 (the fundraiser has been over for > 7 days) #}