basic withdraw and upgrade
This commit is contained in:
@@ -6,6 +6,8 @@ from __future__ import unicode_literals
|
||||
from rowers.views.statements import *
|
||||
from django.core.mail import EmailMessage
|
||||
|
||||
from rowers import credits
|
||||
|
||||
@csrf_exempt
|
||||
def braintree_webhook_view(request):
|
||||
with open('braintreewebhooks.log','a') as f:
|
||||
@@ -212,6 +214,11 @@ def purchase_checkouts_view(request):
|
||||
return HttpResponseRedirect(reverse('rower_select_instantplan'))
|
||||
|
||||
amount, success = braintreestuff.make_payment(r,data)
|
||||
diff = plan.price - amount
|
||||
|
||||
eurocredits = credits.withdraw(diff,r)
|
||||
|
||||
|
||||
|
||||
if success:
|
||||
messages.info(request,"Your payment was completed and the sessions are copied to your calendar")
|
||||
@@ -243,7 +250,7 @@ def purchase_checkouts_view(request):
|
||||
p.rowers.add(r)
|
||||
|
||||
create_sessions_from_json(plansteps,r,startdate,r.user)
|
||||
|
||||
|
||||
job = myqueue(queuehigh,handle_send_email_instantplan_notification,
|
||||
r.user.username,
|
||||
r.user.email,
|
||||
@@ -251,7 +258,6 @@ def purchase_checkouts_view(request):
|
||||
plan.name,
|
||||
startdate,
|
||||
enddate)
|
||||
print(job,'noot')
|
||||
|
||||
url = reverse('plannedsessions_view')
|
||||
timeperiod = startdate.strftime('%Y-%m-%d')+'/'+enddate.strftime('%Y-%m-%d')
|
||||
|
||||
@@ -2621,10 +2621,24 @@ def rower_view_instantplan(request,id='',userid=0):
|
||||
'id':id,
|
||||
})
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# check if plan is free or credits are sufficient
|
||||
if plan.price > 0:
|
||||
if plan.price > r.eurocredits:
|
||||
messages.error(request,'You did not have enough credit to purchase this plan')
|
||||
url = reverse('rower_view_instantplan',kwargs={
|
||||
'id':id,
|
||||
})
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
|
||||
form = InstantPlanSelectForm(request.POST,targets=targets)
|
||||
|
||||
|
||||
if form.is_valid():
|
||||
if plan.price > 0:
|
||||
eurocredits = credits.withdraw(plan.price,r)
|
||||
|
||||
plansteps = response.json()
|
||||
name = form.cleaned_data['name']
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user