Merge branch 'relaunch_ry' into relaunch
commit
c4494de34c
|
@ -343,6 +343,7 @@ class CampaignPledgeForm(forms.Form):
|
||||||
class CCForm(forms.Form):
|
class CCForm(forms.Form):
|
||||||
username = forms.CharField(max_length=30, required=True )
|
username = forms.CharField(max_length=30, required=True )
|
||||||
work_id = forms.IntegerField(required=False, widget=forms.HiddenInput() )
|
work_id = forms.IntegerField(required=False, widget=forms.HiddenInput() )
|
||||||
|
stripe_token = forms.CharField(required=False, widget=forms.HiddenInput())
|
||||||
preapproval_amount= forms.DecimalField(
|
preapproval_amount= forms.DecimalField(
|
||||||
required=False,
|
required=False,
|
||||||
min_value=D('1.00'),
|
min_value=D('1.00'),
|
||||||
|
@ -350,8 +351,6 @@ class CCForm(forms.Form):
|
||||||
decimal_places=2,
|
decimal_places=2,
|
||||||
label="Pledge",
|
label="Pledge",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DonateForm(forms.Form):
|
class DonateForm(forms.Form):
|
||||||
preapproval_amount = forms.DecimalField( widget=forms.HiddenInput() )
|
preapproval_amount = forms.DecimalField( widget=forms.HiddenInput() )
|
||||||
|
|
|
@ -6,8 +6,11 @@
|
||||||
{% block extra_extra_head %}
|
{% block extra_extra_head %}
|
||||||
<link type="text/css" rel="stylesheet" href="/static/css/campaign.css" />
|
<link type="text/css" rel="stylesheet" href="/static/css/campaign.css" />
|
||||||
<link type="text/css" rel="stylesheet" href="/static/css/pledge.css" />
|
<link type="text/css" rel="stylesheet" href="/static/css/pledge.css" />
|
||||||
|
<link href="/static/stripe/tag.css" rel="stylesheet" type="text/css">
|
||||||
|
|
||||||
|
<script type="text/javascript" src="/static/stripe/tag.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript" src="/static/js/reconcile_pledge.js"></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block doccontent %}
|
{% block doccontent %}
|
||||||
|
@ -30,11 +33,13 @@
|
||||||
<p> Click the button to be sent to the {{nonprofit.name}} donation site. When you complete your donation of at least ${{ needed }}, you'll be sent back to Unglue.it and your pledge will automatically be entered. You can move your donation credit to another campaign or campaigns at any time. {{nonprofit.name}} will hold all funds and earn any interest until a campaign you support succeeds.
|
<p> Click the button to be sent to the {{nonprofit.name}} donation site. When you complete your donation of at least ${{ needed }}, you'll be sent back to Unglue.it and your pledge will automatically be entered. You can move your donation credit to another campaign or campaigns at any time. {{nonprofit.name}} will hold all funds and earn any interest until a campaign you support succeeds.
|
||||||
</p>
|
</p>
|
||||||
<div id="donate_charity">
|
<div id="donate_charity">
|
||||||
|
|
||||||
<form method="GET" action="{{nonprofit.link}}">
|
<form method="GET" action="{{nonprofit.link}}">
|
||||||
{{ donate_form.non_field_errors }}
|
{{ donate_form.non_field_errors }}
|
||||||
{{donate_form}}
|
{{donate_form}}
|
||||||
<input name="donate_submit" type="submit" value="Go Donate!" id="donate_submit" />
|
<input name="donate_submit" type="submit" value="Go Donate!" id="donate_submit" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="authorize" class="clearfix">
|
<div id="authorize" class="clearfix">
|
||||||
|
@ -43,17 +48,30 @@
|
||||||
</p>
|
</p>
|
||||||
{% if request.user.credit.available %}<p>Although you have ${{request.user.credit.available}} in donation credits, you can't support a campaign with a mixture of credit card pledges and donations.{% endif %}
|
{% if request.user.credit.available %}<p>Although you have ${{request.user.credit.available}} in donation credits, you can't support a campaign with a mixture of credit card pledges and donations.{% endif %}
|
||||||
<div id="cc_pledge">
|
<div id="cc_pledge">
|
||||||
<form method="POST" action="#">
|
<span class="payment-errors"></span>
|
||||||
{% csrf_token %}
|
<form action="" method="post" id="payment-form">
|
||||||
{{ form.non_field_errors }}
|
{% csrf_token %}
|
||||||
{{form}}
|
{{ form.non_field_errors }}
|
||||||
<input name="cc_submit" type="submit" value="Verify Credit Card" id="cc_submit" />
|
{{form}}
|
||||||
</form>
|
<payment key="{{STRIPE_PK}}"></payment>
|
||||||
|
<input name="cc_submit" type="submit" value="Verify Credit Card" id="cc_submit" />
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script type="application/x-javascript">
|
||||||
|
|
||||||
|
var $j = jQuery.noConflict();
|
||||||
|
console.debug('setting up handlers in stripe.html');
|
||||||
|
|
||||||
|
$j('payment').bind('success.payment', function () {
|
||||||
|
console.debug('success.payment ev');
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ from tastypie.models import ApiKey
|
||||||
from regluit.payment.models import Transaction, Sent, CreditLog
|
from regluit.payment.models import Transaction, Sent, CreditLog
|
||||||
from notification import models as notification
|
from notification import models as notification
|
||||||
|
|
||||||
|
from regluit.payment.stripelib import STRIPE_PK
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ def slideshow(max):
|
||||||
# add all the works with active campaigns
|
# add all the works with active campaigns
|
||||||
for campaign in ending:
|
for campaign in ending:
|
||||||
worklist.append(campaign.work)
|
worklist.append(campaign.work)
|
||||||
|
|
||||||
# then fill out the rest of the list with popular but inactive works
|
# then fill out the rest of the list with popular but inactive works
|
||||||
remainder = max - count
|
remainder = max - count
|
||||||
remainder_works = models.Work.objects.exclude(campaigns__status='ACTIVE').order_by('-num_wishes')[:remainder]
|
remainder_works = models.Work.objects.exclude(campaigns__status='ACTIVE').order_by('-num_wishes')[:remainder]
|
||||||
|
@ -183,7 +184,7 @@ def work(request, work_id, action='display'):
|
||||||
countdown = "in %s minutes" % str(time_remaining.seconds/60 + 1)
|
countdown = "in %s minutes" % str(time_remaining.seconds/60 + 1)
|
||||||
else:
|
else:
|
||||||
countdown = "right now"
|
countdown = "right now"
|
||||||
|
|
||||||
if action == 'preview':
|
if action == 'preview':
|
||||||
work.last_campaign_status = 'ACTIVE'
|
work.last_campaign_status = 'ACTIVE'
|
||||||
|
|
||||||
|
@ -708,13 +709,27 @@ class FundPledgeView(FormView):
|
||||||
transaction = None
|
transaction = None
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super(FundPledgeView, self).get_form_kwargs()
|
||||||
|
|
||||||
assert self.request.user.is_authenticated()
|
assert self.request.user.is_authenticated()
|
||||||
if self.transaction is None:
|
if self.transaction is None:
|
||||||
self.transaction = get_object_or_404(Transaction, id=self.kwargs["t_id"])
|
self.transaction = get_object_or_404(Transaction, id=self.kwargs["t_id"])
|
||||||
return {'data':{'preapproval_amount':self.transaction.max_amount,
|
|
||||||
|
if kwargs.has_key('data'):
|
||||||
|
data = kwargs['data'].copy()
|
||||||
|
else:
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
data.update(
|
||||||
|
{'preapproval_amount':self.transaction.max_amount,
|
||||||
'username':self.request.user.username,
|
'username':self.request.user.username,
|
||||||
'work_id':self.transaction.campaign.work.id,
|
'work_id':self.transaction.campaign.work.id,
|
||||||
'title':self.transaction.campaign.work.title} }
|
'title':self.transaction.campaign.work.title}
|
||||||
|
)
|
||||||
|
|
||||||
|
kwargs['data'] = data
|
||||||
|
|
||||||
|
return kwargs
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(FundPledgeView, self).get_context_data(**kwargs)
|
context = super(FundPledgeView, self).get_context_data(**kwargs)
|
||||||
|
@ -723,11 +738,22 @@ class FundPledgeView(FormView):
|
||||||
context['needed'] = self.transaction.max_amount - self.request.user.credit.available
|
context['needed'] = self.transaction.max_amount - self.request.user.credit.available
|
||||||
context['transaction']=self.transaction
|
context['transaction']=self.transaction
|
||||||
context['nonprofit'] = settings.NONPROFIT
|
context['nonprofit'] = settings.NONPROFIT
|
||||||
|
context['STRIPE_PK'] = STRIPE_PK
|
||||||
# note that get_form_kwargs() will already have been called once
|
# note that get_form_kwargs() will already have been called once
|
||||||
donate_args=self.get_form_kwargs()
|
donate_args=self.get_form_kwargs()
|
||||||
donate_args['data']['preapproval_amount']=context['needed']
|
donate_args['data']['preapproval_amount']=context['needed']
|
||||||
context['donate_form'] = DonateForm(**donate_args)
|
context['donate_form'] = DonateForm(**donate_args)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
logger.info('request.POST: {0}'.format(request.POST))
|
||||||
|
return super(FundPledgeView, self).post(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
stripe_token = form.cleaned_data["stripe_token"]
|
||||||
|
|
||||||
|
return HttpResponse("cleaned_data: {0}".format(form.cleaned_data.items()))
|
||||||
|
|
||||||
|
|
||||||
class NonprofitCampaign(FormView):
|
class NonprofitCampaign(FormView):
|
||||||
template_name="nonprofit.html"
|
template_name="nonprofit.html"
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<link href="/static/stripe/tag.css" rel="stylesheet" type="text/css">
|
<link href="/static/stripe/tag.css" rel="stylesheet" type="text/css">
|
||||||
<script type="text/javascript" src="/static/stripe/tag.js"></script>
|
<script type="text/javascript" src="/static/stripe/tag.js"></script>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block doccontent %}
|
{% block doccontent %}
|
||||||
|
@ -22,6 +23,16 @@ Stripe Test!:
|
||||||
<input type="submit" value="Submit">
|
<input type="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<script type="application/x-javascript">
|
||||||
|
|
||||||
|
var $j = jQuery.noConflict();
|
||||||
|
console.debug('setting up handlers in stripe.html');
|
||||||
|
|
||||||
|
$j('payment').bind('success.payment', function () {
|
||||||
|
console.debug('success.payment ev');
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue