comparison gpp/donations/views.py @ 35:f77a1cdd7a46

Donations: first cut at a donations view and a form built for paypal.
author Brian Neal <bgneal@gmail.com>
date Sun, 07 Jun 2009 00:22:50 +0000
parents c018872385ea
children 296b610ee507
comparison
equal deleted inserted replaced
34:d5d7e510ecd7 35:f77a1cdd7a46
1 # Create your views here. 1 """
2 Views for the donations application.
3 """
4 from django.shortcuts import render_to_response
5 from django.template import RequestContext
6 from django.http import Http404 # TODO: remove
7 from django.conf import settings
8 from django.contrib.sites.models import Site
9
10 from donations.models import Donation
11
12
13 def index(request):
14 gross, net, donations = Donation.objects.monthly_stats()
15 current_site = Site.objects.get_current()
16
17 if settings.DEBUG:
18 form_action = 'https://www.sandbox.paypal.com/cgi-bin/webscr'
19 business = settings.DONATIONS_BUSINESS_DEBUG
20 else:
21 form_action = 'https://www.paypal.com/cgi-bin/webscr'
22 business = settings.DONATIONS_BUSINESS
23
24 return render_to_response('donations/index.html', {
25 'goal': settings.DONATIONS_GOAL,
26 'gross': gross,
27 'net': net,
28 'left': settings.DONATIONS_GOAL - net,
29 'donations': donations,
30 'form_action': form_action,
31 'business': business,
32 'anonymous': settings.DONATIONS_ANON_NAME,
33 'item_name': settings.DONATIONS_ITEM_NAME,
34 'item_number': settings.DONATIONS_ITEM_NUM,
35 'item_anon_number': settings.DONATIONS_ITEM_ANON_NUM,
36 'domain': current_site.domain,
37 },
38 context_instance = RequestContext(request))
39
40
41 def ipn(request):
42 raise Http404 #TODO
43
44
45 def thanks(request):
46 raise Http404 #TODO