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.
This commit is contained in:
		
							parent
							
								
									20f2339a1f
								
							
						
					
					
						commit
						8b469cff18
					
				
					 4 changed files with 26 additions and 3 deletions
				
			
		|  | @ -7,6 +7,8 @@ class FundraisingGoal(models.Model): | ||||||
|     fundraiser_code_name      = models.CharField(max_length=200, blank=False, unique=True) |     fundraiser_code_name      = models.CharField(max_length=200, blank=False, unique=True) | ||||||
|     fundraiser_goal_amount   = models.DecimalField(max_digits=10, decimal_places=2) |     fundraiser_goal_amount   = models.DecimalField(max_digits=10, decimal_places=2) | ||||||
|     fundraiser_so_far_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): |     def __unicode__(self): | ||||||
|         return self.fundraiser_code_name |         return self.fundraiser_code_name | ||||||
|  |  | ||||||
|  | @ -104,6 +104,9 @@ el.attachEvent('on'+ev, function() {handler.apply(el);}); | ||||||
| </script> | </script> | ||||||
| --> | --> | ||||||
| <h3>Support NPO Accounting Project Now!</h3> | <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/> | $<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/> | 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> | <div id="progressbar"><span id="fundraiser-percentage">(i.e., {{ fundgoal.percentage_there|floatformat:1 }}%)</span></div> | ||||||
|  |  | ||||||
|  | @ -7,11 +7,14 @@ | ||||||
| $(document).ready(function() { | $(document).ready(function() { | ||||||
|     var goal  = $('span#fundraiser-goal').text(); |     var goal  = $('span#fundraiser-goal').text(); | ||||||
|     var soFar = $('span#fundraiser-so-far').text(); |     var soFar = $('span#fundraiser-so-far').text(); | ||||||
|  |     var donationCount = $('span#fundraiser-donation-count').text(); | ||||||
|     var noCommaGoal = goal.replace(/,/g, ""); |     var noCommaGoal = goal.replace(/,/g, ""); | ||||||
|     var noCommaSoFar = soFar.replace(/,/g, ""); |     var noCommaSoFar = soFar.replace(/,/g, ""); | ||||||
|  |     var noCommaDonationCount = parseInt(donationCount.replace(/,/g, "")); | ||||||
|     var percentage = (parseFloat(noCommaSoFar) / parseFloat(noCommaGoal)) * 100; |     var percentage = (parseFloat(noCommaSoFar) / parseFloat(noCommaGoal)) * 100; | ||||||
|     var curValue = 0.00; |     var curValue = 0.00; | ||||||
|     var incrementSoFar = 0.00; |     var incrementSoFar = 0.00; | ||||||
|  |     var incrementDonationCount = 0; | ||||||
| 
 | 
 | ||||||
|     $('span#fundraiser-percentage').text(""); |     $('span#fundraiser-percentage').text(""); | ||||||
|     $('span#fundraiser-percentage').css({ 'color'        : 'green', |     $('span#fundraiser-percentage').css({ 'color'        : 'green', | ||||||
|  | @ -22,7 +25,7 @@ $(document).ready(function() { | ||||||
|                                           'text-align'   : 'inherit'}); |                                           'text-align'   : 'inherit'}); | ||||||
|     $("#progressbar").progressbar({ value:  curValue }); |     $("#progressbar").progressbar({ value:  curValue }); | ||||||
| 
 | 
 | ||||||
|     function slowRise() { |     function riseDonationProgressBar() { | ||||||
|         if (curValue >= percentage) { |         if (curValue >= percentage) { | ||||||
|             $('span#fundraiser-so-far').text(soFar); |             $('span#fundraiser-so-far').text(soFar); | ||||||
|             $("#progressbar").progressbar({ value :  percentage }); |             $("#progressbar").progressbar({ value :  percentage }); | ||||||
|  | @ -32,10 +35,22 @@ $(document).ready(function() { | ||||||
|             $("#progressbar").progressbar({ value:  curValue }); |             $("#progressbar").progressbar({ value:  curValue }); | ||||||
|             $('span#fundraiser-so-far').text(newVal.toLocaleString()); |             $('span#fundraiser-so-far').text(newVal.toLocaleString()); | ||||||
|             curValue += 0.5; |             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-content').hide(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -22,6 +22,9 @@ | ||||||
| <p>Support our GPL compliance work now & <span class="donate-box-highlight">donations count double!</span></p> | <p>Support our GPL compliance work now & <span class="donate-box-highlight">donations count double!</span></p> | ||||||
| 
 | 
 | ||||||
| {% cache 3600 compliancedonation fundgoal.fundraiser_so_far_amount %} | {% 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> | $<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/> | 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> | <div id="progressbar"><span id="fundraiser-percentage">(i.e., {{ fundgoal.percentage_there|floatformat:1 }}%)</span></div> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Bradley M. Kuhn
						Bradley M. Kuhn