Changeset - 8b469cff1830
[Not reviewed]
0 4 0
Bradley Kuhn (bkuhn) - 9 years ago 2015-03-12 01:10:28
bkuhn@ebb.org
Support display of donation count in fundraiser.

Allow display of a donation count in the fundraiser pages, with an
optional threshold that must be met before it's displayed.
4 files changed with 26 insertions and 3 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/fundgoal/models.py
Show inline comments
...
 
@@ -7,6 +7,8 @@ class FundraisingGoal(models.Model):
 
    fundraiser_code_name      = models.CharField(max_length=200, blank=False, unique=True)
 
    fundraiser_goal_amount   = models.DecimalField(max_digits=10, decimal_places=2)
 
    fundraiser_so_far_amount = models.DecimalField(max_digits=10, decimal_places=2)
 
    fundraiser_donation_count = models.IntegerField()
 
    fundraiser_donation_count_disclose_threshold = models.IntegerField()
 

	
 
    def __unicode__(self):
 
        return self.fundraiser_code_name
www/conservancy/static/npoacct/index.html
Show inline comments
...
 
@@ -104,6 +104,9 @@ el.attachEvent('on'+ev, function() {handler.apply(el);});
 
</script>
 
-->
 
<h3>Support NPO Accounting Project Now!</h3>
 
{% if fundgoal.fundraiser_donation_count > fundgoal.fundraiser_donation_count_disclose_threshold %}
 
Thanks to <span id="fundraiser-donation-count">{{ fundgoal.fundraiser_donation_count|intcomma }}</span> donations,<br/>
 
{% endif %}
 
$<span id="fundraiser-so-far">{{ fundgoal.fundraiser_so_far_amount|floatformat:0|intcomma }}</span> raised toward<br/>
 
our $<span id="fundraiser-goal">{{ fundgoal.fundraiser_goal_amount|floatformat:0|intcomma  }}</span> goal.<br/>
 
<div id="progressbar"><span id="fundraiser-percentage">(i.e., {{ fundgoal.percentage_there|floatformat:1 }}%)</span></div>
www/conservancy/static/supporter-page.js
Show inline comments
...
 
@@ -7,11 +7,14 @@
 
$(document).ready(function() {
 
    var goal  = $('span#fundraiser-goal').text();
 
    var soFar = $('span#fundraiser-so-far').text();
 
    var donationCount = $('span#fundraiser-donation-count').text();
 
    var noCommaGoal = goal.replace(/,/g, "");
 
    var noCommaSoFar = soFar.replace(/,/g, "");
 
    var noCommaDonationCount = parseInt(donationCount.replace(/,/g, ""));
 
    var percentage = (parseFloat(noCommaSoFar) / parseFloat(noCommaGoal)) * 100;
 
    var curValue = 0.00;
 
    var incrementSoFar = 0.00;
 
    var incrementDonationCount = 0;
 

	
 
    $('span#fundraiser-percentage').text("");
 
    $('span#fundraiser-percentage').css({ 'color'        : 'green',
...
 
@@ -22,7 +25,7 @@ $(document).ready(function() {
 
                                          'text-align'   : 'inherit'});
 
    $("#progressbar").progressbar({ value:  curValue });
 

	
 
    function slowRise() {
 
    function riseDonationProgressBar() {
 
        if (curValue >= percentage) {
 
            $('span#fundraiser-so-far').text(soFar);
 
            $("#progressbar").progressbar({ value :  percentage });
...
 
@@ -32,10 +35,22 @@ $(document).ready(function() {
 
            $("#progressbar").progressbar({ value:  curValue });
 
            $('span#fundraiser-so-far').text(newVal.toLocaleString());
 
            curValue += 0.5;
 
            setTimeout(slowRise, 50);
 
            setTimeout(riseDonationProgressBar, 50);
 
        }
 
    }
 
    slowRise();
 
    function riseDonationCount() {
 
        if (incrementDonationCount >= noCommaDonationCount) {
 
            $('span#fundraiser-donation-count').text(donationCount);
 
        } else {
 
            $('span#fundraiser-donation-count').text(incrementDonationCount.toLocaleString());
 
            incrementDonationCount++;
 
            setTimeout(riseDonationCount, 50);
 
        }
 
    }
 
    if (noCommaDonationCount > 0) {
 
        riseDonationCount();
 
    }
 
    riseDonationProgressBar();
 

	
 
    $('.toggle-content').hide();
 

	
www/conservancy/templates/base_compliance.html
Show inline comments
...
 
@@ -22,6 +22,9 @@
 
<p>Support our GPL compliance work now &amp; <span class="donate-box-highlight">donations count double!</span></p>
 

	
 
{% cache 3600 compliancedonation fundgoal.fundraiser_so_far_amount %}
 
{% if fundgoal.fundraiser_donation_count > fundgoal.fundraiser_donation_count_disclose_threshold %}
 
Thanks to <span id="fundraiser-donation-count">{{ fundgoal.fundraiser_donation_count|intcomma }}</span> donations,<br/>
 
{% endif %}
 
$<span id="fundraiser-so-far">{{ fundgoal.fundraiser_so_far_amount|floatformat:0|intcomma }}</span>
 
of $<span id="fundraiser-goal">{{ fundgoal.fundraiser_goal_amount|floatformat:0|intcomma  }}</span> match met.<br/>
 
<div id="progressbar"><span id="fundraiser-percentage">(i.e., {{ fundgoal.percentage_there|floatformat:1 }}%)</span></div>
0 comments (0 inline, 0 general)