annotate 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
rev   line source
bgneal@35 1 """
bgneal@35 2 Views for the donations application.
bgneal@35 3 """
bgneal@35 4 from django.shortcuts import render_to_response
bgneal@35 5 from django.template import RequestContext
bgneal@35 6 from django.http import Http404 # TODO: remove
bgneal@35 7 from django.conf import settings
bgneal@35 8 from django.contrib.sites.models import Site
bgneal@35 9
bgneal@35 10 from donations.models import Donation
bgneal@35 11
bgneal@35 12
bgneal@35 13 def index(request):
bgneal@35 14 gross, net, donations = Donation.objects.monthly_stats()
bgneal@35 15 current_site = Site.objects.get_current()
bgneal@35 16
bgneal@35 17 if settings.DEBUG:
bgneal@35 18 form_action = 'https://www.sandbox.paypal.com/cgi-bin/webscr'
bgneal@35 19 business = settings.DONATIONS_BUSINESS_DEBUG
bgneal@35 20 else:
bgneal@35 21 form_action = 'https://www.paypal.com/cgi-bin/webscr'
bgneal@35 22 business = settings.DONATIONS_BUSINESS
bgneal@35 23
bgneal@35 24 return render_to_response('donations/index.html', {
bgneal@35 25 'goal': settings.DONATIONS_GOAL,
bgneal@35 26 'gross': gross,
bgneal@35 27 'net': net,
bgneal@35 28 'left': settings.DONATIONS_GOAL - net,
bgneal@35 29 'donations': donations,
bgneal@35 30 'form_action': form_action,
bgneal@35 31 'business': business,
bgneal@35 32 'anonymous': settings.DONATIONS_ANON_NAME,
bgneal@35 33 'item_name': settings.DONATIONS_ITEM_NAME,
bgneal@35 34 'item_number': settings.DONATIONS_ITEM_NUM,
bgneal@35 35 'item_anon_number': settings.DONATIONS_ITEM_ANON_NUM,
bgneal@35 36 'domain': current_site.domain,
bgneal@35 37 },
bgneal@35 38 context_instance = RequestContext(request))
bgneal@35 39
bgneal@35 40
bgneal@35 41 def ipn(request):
bgneal@35 42 raise Http404 #TODO
bgneal@35 43
bgneal@35 44
bgneal@35 45 def thanks(request):
bgneal@35 46 raise Http404 #TODO