Changeset - 67e64d3a6c8f
[Not reviewed]
0 2 0
Brett Smith (brett) - 4 years ago 2019-11-22 14:46:07
brett@sfconservancy.org
base: Break out individual local context variables.
2 files changed with 19 insertions and 14 deletions:
0 comments (0 inline, 0 general)
www/conservancy/local_context_processors.py
Show inline comments
...
 
@@ -17,14 +17,15 @@ def fundgoal_lookup(fundraiser_sought):
 
    except FundraisingGoal.DoesNotExist:
 
        # we have no object!  do something
 
        return None
 

	
 
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:
 
    _HOST_URL_VAR = {'host_url': 'https://' + conservancy.settings.FORCE_CANONICAL_HOSTNAME}
 
    def host_url(request):
 
        return _HOST_URL_VAR
www/conservancy/templates/base_conservancy.html
Show inline comments
...
 
@@ -42,38 +42,42 @@
 
      </div>
 
      <div id="navbar-clear"></div>
 

	
 
    </div>
 

	
 
{% 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 %}
 
    <div class="fundraiser-top-text">
 
      <p>
 
        {% 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 &mdash; <a href="/supporter">sign up now</a>!
 
          Thanks to {{ sitegoal.fundraiser_donation_count|intcomma }} Supporters we earned our full match!
 
          Help us go further to stand up for software freedom &mdash; <a href="/supporter">sign up now</a>!
 
        {% else %}
 
          {% if sitefundgoal_timeleft.total_seconds <= 0 %}
 
            The
 
          {% elif sitefundgoal_timeleft.days == 0 %}
 
            Through today only, the
 
          {% elif sitefundgoal_timeleft.days == 1 %}
0 comments (0 inline, 0 general)