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
...
 
@@ -4,12 +4,14 @@ from decimal import *
 
class FundraisingGoal(models.Model):
 
    """Conservancy fundraiser Goal"""
 

	
 
    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
 

	
 
    def percentage_there(self):
 
        return (self.fundraiser_so_far_amount / self.fundraiser_goal_amount ) * Decimal('100.00')
www/conservancy/static/npoacct/index.html
Show inline comments
...
 
@@ -101,12 +101,15 @@ el.attachEvent('on'+ev, function() {handler.apply(el);});
 
    };
 
   $('#bank-account-form').submit(tokenizeInstrument);
 
*/
 
</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>
 
<p style="font-size: 75%">(Progress bar updated daily.)</p>
 
<a id="donate" style="text-decoration:none"></a>
 
<h3 class="donate-box-highlight">Help us reach our goal:</h3>
www/conservancy/static/supporter-page.js
Show inline comments
...
 
@@ -4,41 +4,56 @@
 
**  Find a copy of GPL at https://sfconservancy.org/GPLv3
 
*/
 

	
 
$(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',
 
                                          'font-weight'  : 'bold',
 
                                          'float'        : 'right',
 
                                          'margin-right' : '40%',
 
                                          'margin-top'   : '2.5%',
 
                                          'text-align'   : 'inherit'});
 
    $("#progressbar").progressbar({ value:  curValue });
 

	
 
    function slowRise() {
 
    function riseDonationProgressBar() {
 
        if (curValue >= percentage) {
 
            $('span#fundraiser-so-far').text(soFar);
 
            $("#progressbar").progressbar({ value :  percentage });
 
            $('span#fundraiser-percentage').text(percentage.toFixed(1) + "%");
 
        } else {
 
            var newVal = (curValue / 100.00) * noCommaGoal;
 
            $("#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();
 

	
 
    $('.toggle-control')
 
     .addClass('clickable')
 
     .bind('click', function() {
www/conservancy/templates/base_compliance.html
Show inline comments
...
 
@@ -19,12 +19,15 @@
 

	
 
<h3>Support GPL Compliance Now!</h3>
 

	
 
<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>
 
{% endcache %}
 

	
 
<p><span class="donate-box-highlight">Donate now via PayPal:</span>
0 comments (0 inline, 0 general)