Mercurial > public > sg101
comparison donations/views.py @ 1087:7fb9bc5a1232
Add progress bar to donations page.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 03 May 2016 21:17:28 -0500 |
parents | 75189bd9c4ba |
children | fbfb1a9c70e2 |
comparison
equal
deleted
inserted
replaced
1086:aa43db10c565 | 1087:7fb9bc5a1232 |
---|---|
55 return response.read() | 55 return response.read() |
56 | 56 |
57 | 57 |
58 def index(request): | 58 def index(request): |
59 gross, net, donations = Donation.objects.monthly_stats() | 59 gross, net, donations = Donation.objects.monthly_stats() |
60 goal = settings.DONATIONS_GOAL | |
60 current_site = Site.objects.get_current() | 61 current_site = Site.objects.get_current() |
61 form_action, business = paypal_params() | 62 form_action, business = paypal_params() |
62 | 63 |
64 pct = max(0, min(100, int(net / goal * 100))) | |
65 | |
63 return render(request, 'donations/index.html', { | 66 return render(request, 'donations/index.html', { |
64 'goal': settings.DONATIONS_GOAL, | 67 'goal': goal, |
65 'gross': gross, | 68 'gross': gross, |
66 'net': net, | 69 'net': net, |
67 'left': settings.DONATIONS_GOAL - net, | 70 'left': settings.DONATIONS_GOAL - net, |
71 'pct': pct, | |
68 'donations': donations, | 72 'donations': donations, |
69 'form_action': form_action, | 73 'form_action': form_action, |
70 'business': business, | 74 'business': business, |
71 'anonymous': settings.DONATIONS_ANON_NAME, | 75 'anonymous': settings.DONATIONS_ANON_NAME, |
72 'item_name': settings.DONATIONS_ITEM_NAME, | 76 'item_name': settings.DONATIONS_ITEM_NAME, |