First cut at a donation page for partnering non-profit
parent
87f07bd9c3
commit
55d8bcdd2c
|
@ -166,6 +166,21 @@ class CampaignPledgeForm(forms.Form):
|
|||
|
||||
return cleaned_data
|
||||
|
||||
class DonateForm(forms.Form):
|
||||
donation_amount = forms.DecimalField(
|
||||
required=False,
|
||||
min_value=D('1.00'),
|
||||
max_value=D('100000.00'),
|
||||
decimal_places=2,
|
||||
label="Donation",
|
||||
)
|
||||
anonymous = forms.BooleanField(required=False, label=_("Don't display my username in the donors' list"))
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = self.cleaned_data
|
||||
return cleaned_data
|
||||
|
||||
|
||||
|
||||
class GoodreadsShelfLoadingForm(forms.Form):
|
||||
goodreads_shelf_name_number = forms.CharField(widget=forms.Select(choices=(
|
||||
|
|
|
@ -5,7 +5,8 @@ from django.views.generic import ListView, DetailView
|
|||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
from regluit.core.models import Campaign
|
||||
from regluit.frontend.views import CampaignFormView, GoodreadsDisplayView, LibraryThingView, PledgeView, CampaignListView
|
||||
from regluit.frontend.views import CampaignFormView, GoodreadsDisplayView, LibraryThingView, PledgeView
|
||||
from regluit.frontend.views import CampaignListView, DonateView
|
||||
|
||||
urlpatterns = patterns(
|
||||
"regluit.frontend.views",
|
||||
|
@ -46,6 +47,7 @@ urlpatterns = patterns(
|
|||
url(r"^subjects/$", "subjects", name="subjects"),
|
||||
url(r"^librarything/$", LibraryThingView.as_view(), name="librarything"),
|
||||
url(r"^librarything/load/$","librarything_load", name="librarything_load"),
|
||||
url(r"^donate/$", DonateView.as_view(), name="donate"),
|
||||
url('^404testing/$', direct_to_template, {'template': '404.html'}),
|
||||
url('^500testing/$', direct_to_template, {'template': '500.html'}),
|
||||
url('^robots.txt$', direct_to_template, {'template': 'robots.txt'}),
|
||||
|
|
|
@ -34,9 +34,9 @@ from regluit.core.search import gluejar_search
|
|||
from regluit.core.goodreads import GoodreadsClient
|
||||
from regluit.frontend.forms import UserData, ProfileForm, CampaignPledgeForm, GoodreadsShelfLoadingForm
|
||||
from regluit.frontend.forms import RightsHolderForm, UserClaimForm, LibraryThingForm, OpenCampaignForm
|
||||
from regluit.frontend.forms import ManageCampaignForm
|
||||
from regluit.frontend.forms import ManageCampaignForm, DonateForm
|
||||
from regluit.payment.manager import PaymentManager
|
||||
from regluit.payment.parameters import TARGET_TYPE_CAMPAIGN
|
||||
from regluit.payment.parameters import TARGET_TYPE_CAMPAIGN, TARGET_TYPE_DONATION
|
||||
|
||||
from regluit.core import goodreads
|
||||
from tastypie.models import ApiKey
|
||||
|
@ -228,7 +228,51 @@ class PledgeView(FormView):
|
|||
logger.info("PledgeView paypal: Error " + str(t.reference))
|
||||
return HttpResponse(response)
|
||||
|
||||
class DonateView(FormView):
|
||||
template_name="donate.html"
|
||||
form_class = DonateForm
|
||||
embedded = False
|
||||
|
||||
#def get_context_data(self, **kwargs):
|
||||
# context = super(DonateView, self).get_context_data(**kwargs)
|
||||
#
|
||||
# form = CampaignPledgeForm(data)
|
||||
#
|
||||
# context.update({'work':work,'campaign':campaign, 'premiums':premiums, 'form':form, 'premium_id':premium_id})
|
||||
# return context
|
||||
|
||||
def form_valid(self, form):
|
||||
donation_amount = form.cleaned_data["donation_amount"]
|
||||
anonymous = form.cleaned_data["anonymous"]
|
||||
|
||||
# right now, if there is a non-zero pledge amount, go with that. otherwise, do the pre_approval
|
||||
campaign = None
|
||||
|
||||
p = PaymentManager(embedded=self.embedded)
|
||||
|
||||
# we should force login at this point -- or if no account, account creation, login, and return to this spot
|
||||
if self.request.user.is_authenticated():
|
||||
user = self.request.user
|
||||
else:
|
||||
user = None
|
||||
|
||||
# instant payment: send to the partnering RH
|
||||
receiver_list = [{'email':settings.PAYPAL_NONPROFIT_PARTNER_EMAIL, 'amount':donation_amount}]
|
||||
|
||||
#redirect the page back to campaign page on success
|
||||
return_url = self.request.build_absolute_uri(reverse('donate'))
|
||||
|
||||
t, url = p.pledge('USD', TARGET_TYPE_DONATION, receiver_list, campaign=campaign, list=None, user=user,
|
||||
return_url=return_url, anonymous=anonymous)
|
||||
|
||||
if url:
|
||||
return HttpResponseRedirect(url)
|
||||
else:
|
||||
response = t.reference
|
||||
logger.info("PledgeView paypal: Error " + str(t.reference))
|
||||
return HttpResponse(response)
|
||||
|
||||
|
||||
def claim(request):
|
||||
if request.method == 'GET':
|
||||
data = request.GET
|
||||
|
|
|
@ -5,6 +5,7 @@ PAYMENT_TYPE_AUTHORIZATION = 2
|
|||
TARGET_TYPE_NONE = 0
|
||||
TARGET_TYPE_CAMPAIGN = 1
|
||||
TARGET_TYPE_LIST = 2
|
||||
TARGET_TYPE_DONATION = 3
|
||||
|
||||
COMPLETE_URL = '/paymentcomplete'
|
||||
CANCEL_URL = '/paymentcancel'
|
||||
|
|
|
@ -73,11 +73,12 @@ PAYPAL_SANDBOX_PASSWORD = ''
|
|||
PAYPAL_BUYER_LOGIN =''
|
||||
PAYPAL_BUYER_PASSWORD = ''
|
||||
|
||||
# in live system, replace with the real Gluejar paypal email and that for our non-profit partner
|
||||
PAYPAL_GLUEJAR_EMAIL = "glueja_1317336101_biz@gluejar.com"
|
||||
PAYPAL_NONPROFIT_PARTNER_EMAIL = "nppart_1318957063_per@gluejar.com"
|
||||
|
||||
# for test purposes have a single RH paypal email
|
||||
PAYPAL_TEST_RH_EMAIL = "rh1_1317336251_biz@gluejar.com"
|
||||
PAYPAL_TEST_NONPROFIT_PARTNER_EMAIL = "nppart_1318957063_per@gluejar.com"
|
||||
|
||||
BASE_URL = 'http://0.0.0.0'
|
||||
|
||||
|
|
|
@ -67,11 +67,12 @@ PAYPAL_SANDBOX_PASSWORD = ''
|
|||
PAYPAL_BUYER_LOGIN =''
|
||||
PAYPAL_BUYER_PASSWORD = ''
|
||||
|
||||
# in live system, replace with the real Gluejar paypal email and that for our non-profit partner
|
||||
PAYPAL_GLUEJAR_EMAIL = "glueja_1317336101_biz@gluejar.com"
|
||||
PAYPAL_NONPROFIT_PARTNER_EMAIL = "nppart_1318957063_per@gluejar.com"
|
||||
|
||||
# for test purposes have a single RH paypal email
|
||||
PAYPAL_TEST_RH_EMAIL = "rh1_1317336251_biz@gluejar.com"
|
||||
PAYPAL_TEST_NONPROFIT_PARTNER_EMAIL = ""
|
||||
|
||||
# Goodreads API
|
||||
GOODREADS_API_KEY = "vfqIO6QAhBVvlxt6hAzZJg"
|
||||
|
|
Loading…
Reference in New Issue