fix pep
This commit is contained in:
@@ -72,8 +72,7 @@ def process_webhook(notification):
|
|||||||
transactions = subscription.transactions
|
transactions = subscription.transactions
|
||||||
if transactions:
|
if transactions:
|
||||||
amount = int(transactions[0].amount)
|
amount = int(transactions[0].amount)
|
||||||
eurocredits = credits.upgrade(amount, r)
|
_ = credits.upgrade(amount, r)
|
||||||
eurocredits = credits.upgrade(amount, r)
|
|
||||||
return send_invoice(notification.subscription)
|
return send_invoice(notification.subscription)
|
||||||
if notification.kind == 'subscription_canceled':
|
if notification.kind == 'subscription_canceled':
|
||||||
subscription = notification.subscription
|
subscription = notification.subscription
|
||||||
@@ -97,10 +96,7 @@ def process_webhook(notification):
|
|||||||
|
|
||||||
|
|
||||||
def send_invoice(subscription):
|
def send_invoice(subscription):
|
||||||
with open('braintreewebhooks.log', 'a') as f:
|
dologging('braintreewebhooks.log', 'Subscription ID '+str(subscription.id))
|
||||||
t = time.localtime()
|
|
||||||
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
|
|
||||||
f.write('Subscription ID '+str(subscription.id)+'\n')
|
|
||||||
subscription_id = subscription.id
|
subscription_id = subscription.id
|
||||||
rs = Rower.objects.filter(subscription_id=subscription_id)
|
rs = Rower.objects.filter(subscription_id=subscription_id)
|
||||||
if rs.count() == 0: # pragma: no cover
|
if rs.count() == 0: # pragma: no cover
|
||||||
@@ -176,20 +172,6 @@ def get_client_token(rower):
|
|||||||
return client_token
|
return client_token
|
||||||
|
|
||||||
|
|
||||||
def get_plans_costs(): # pragma: no cover
|
|
||||||
plans = gateway.plan.all()
|
|
||||||
|
|
||||||
localplans = PaidPlan.object.filter(paymentprocessor='braintree')
|
|
||||||
|
|
||||||
for plan in localplans:
|
|
||||||
for btplan in btplans:
|
|
||||||
if int(btplan.id) == plan.external_id:
|
|
||||||
plan.price = float(x)
|
|
||||||
plan.save()
|
|
||||||
|
|
||||||
return plans
|
|
||||||
|
|
||||||
|
|
||||||
def make_payment(rower, data):
|
def make_payment(rower, data):
|
||||||
nonce_from_the_client = data['payment_method_nonce']
|
nonce_from_the_client = data['payment_method_nonce']
|
||||||
nonce = gateway.payment_method_nonce.find(nonce_from_the_client)
|
nonce = gateway.payment_method_nonce.find(nonce_from_the_client)
|
||||||
@@ -226,17 +208,11 @@ def make_payment(rower, data):
|
|||||||
fakturoid_contact_id = fakturoid.get_contacts(rower)
|
fakturoid_contact_id = fakturoid.get_contacts(rower)
|
||||||
if not fakturoid_contact_id:
|
if not fakturoid_contact_id:
|
||||||
fakturoid_contact_id = fakturoid.create_contact(rower)
|
fakturoid_contact_id = fakturoid.create_contact(rower)
|
||||||
id = fakturoid.create_invoice(rower, amount, transaction.id, dosend=True, contact_id=fakturoid_contact_id,
|
_ = fakturoid.create_invoice(rower, amount, transaction.id, dosend=True, contact_id=fakturoid_contact_id,
|
||||||
name=additional_text)
|
name=additional_text)
|
||||||
|
|
||||||
try:
|
|
||||||
job = myqueue(queuehigh, handle_send_email_transaction,
|
|
||||||
name, rower.user.email, amount)
|
|
||||||
job = myqueue(queuehigh, handle_send_email_transation_notification,
|
|
||||||
name.rower.user.email, amount, additional_text)
|
|
||||||
except: # pragma: no cover
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
_ = myqueue(queuehigh, handle_send_email_transaction,
|
||||||
|
name, rower.user.email, amount)
|
||||||
return amount, True
|
return amount, True
|
||||||
else: # pragma: no cover
|
else: # pragma: no cover
|
||||||
return 0, False
|
return 0, False
|
||||||
@@ -280,7 +256,7 @@ def update_subscription(rower, data, method='up'):
|
|||||||
yesterday = (timezone.now()-datetime.timedelta(days=1)).date()
|
yesterday = (timezone.now()-datetime.timedelta(days=1)).date()
|
||||||
rower.paidplan = plan
|
rower.paidplan = plan
|
||||||
amount_int = int(float(amount))
|
amount_int = int(float(amount))
|
||||||
eurocredits = credits.upgrade(amount_int, rower)
|
_ = credits.upgrade(amount_int, rower)
|
||||||
rower.planexpires = result.subscription.billing_period_end_date
|
rower.planexpires = result.subscription.billing_period_end_date
|
||||||
rower.teamplanexpires = result.subscription.billing_period_end_date
|
rower.teamplanexpires = result.subscription.billing_period_end_date
|
||||||
rower.clubsize = plan.clubsize
|
rower.clubsize = plan.clubsize
|
||||||
@@ -319,16 +295,16 @@ def update_subscription(rower, data, method='up'):
|
|||||||
else: # pragma: no cover
|
else: # pragma: no cover
|
||||||
amount = 0
|
amount = 0
|
||||||
|
|
||||||
job = myqueue(queuehigh,
|
_ = myqueue(queuehigh,
|
||||||
handle_send_email_subscription_update,
|
handle_send_email_subscription_update,
|
||||||
name, rower.user.email,
|
name, rower.user.email,
|
||||||
plan.name,
|
plan.name,
|
||||||
plan.paymenttype,
|
plan.paymenttype,
|
||||||
plan.price,
|
plan.price,
|
||||||
amount,
|
amount,
|
||||||
result.subscription.billing_period_end_date.strftime(
|
result.subscription.billing_period_end_date.strftime(
|
||||||
'%Y-%m-%d'),
|
'%Y-%m-%d'),
|
||||||
method)
|
method)
|
||||||
|
|
||||||
return True, amount
|
return True, amount
|
||||||
else: # pragma: no cover
|
else: # pragma: no cover
|
||||||
@@ -352,12 +328,12 @@ def create_subscription(rower, data):
|
|||||||
nonce_from_the_client = data['payment_method_nonce']
|
nonce_from_the_client = data['payment_method_nonce']
|
||||||
nonce = gateway.payment_method_nonce.find(nonce_from_the_client)
|
nonce = gateway.payment_method_nonce.find(nonce_from_the_client)
|
||||||
info = nonce.three_d_secure_info
|
info = nonce.three_d_secure_info
|
||||||
paymenttype = nonce.type
|
# paymenttype = nonce.type
|
||||||
|
|
||||||
if nonce.type != 'PayPalAccount': # pragma: no cover
|
if nonce.type != 'PayPalAccount': # pragma: no cover
|
||||||
if info is None or not info.liability_shifted:
|
if info is None or not info.liability_shifted:
|
||||||
return False, 0
|
return False, 0
|
||||||
amount = data['amount']
|
# amount = data['amount']
|
||||||
|
|
||||||
planid = data['plan']
|
planid = data['plan']
|
||||||
plan = PaidPlan.objects.get(id=planid)
|
plan = PaidPlan.objects.get(id=planid)
|
||||||
@@ -399,7 +375,7 @@ def create_subscription(rower, data):
|
|||||||
|
|
||||||
recurring = plan.paymenttype
|
recurring = plan.paymenttype
|
||||||
|
|
||||||
job = myqueue(
|
_ = myqueue(
|
||||||
queuehigh,
|
queuehigh,
|
||||||
handle_send_email_subscription_create,
|
handle_send_email_subscription_create,
|
||||||
name, rower.user.email,
|
name, rower.user.email,
|
||||||
@@ -420,18 +396,19 @@ def cancel_subscription(rower, id):
|
|||||||
themessages = []
|
themessages = []
|
||||||
errormessages = []
|
errormessages = []
|
||||||
try:
|
try:
|
||||||
result = gateway.subscription.cancel(id)
|
_ = gateway.subscription.cancel(id)
|
||||||
themessages.append("Subscription canceled")
|
themessages.append("Subscription canceled")
|
||||||
except: # pragma: no cover
|
except: # pragma: no cover
|
||||||
errormessages.append(
|
errormessages.append(
|
||||||
"We could not find the subscription record in our customer database. We have notified the site owner, who will contact you.")
|
"We could not find the subscription record in our customer database."
|
||||||
|
" We have notified the site owner, who will contact you.")
|
||||||
|
|
||||||
name = '{f} {l}'.format(f=rower.user.first_name,
|
name = '{f} {l}'.format(f=rower.user.first_name,
|
||||||
l=rower.user.last_name)
|
l=rower.user.last_name)
|
||||||
|
|
||||||
job = myqueue(queuehigh,
|
_ = myqueue(queuehigh,
|
||||||
handle_send_email_failed_cancel,
|
handle_send_email_failed_cancel,
|
||||||
name, rower.user.email, rower.user.username, id)
|
name, rower.user.email, rower.user.username, id)
|
||||||
|
|
||||||
return False, themessages, errormessages
|
return False, themessages, errormessages
|
||||||
|
|
||||||
@@ -510,15 +487,13 @@ def get_transactions(start_date, end_date): # pragma: no cover
|
|||||||
dates = []
|
dates = []
|
||||||
currencies = []
|
currencies = []
|
||||||
statuses = []
|
statuses = []
|
||||||
ids = []
|
# ids = []
|
||||||
usernames = []
|
usernames = []
|
||||||
customerids = []
|
customerids = []
|
||||||
transactionids = []
|
transactionids = []
|
||||||
subscriptionids = []
|
subscriptionids = []
|
||||||
ownids = []
|
ownids = []
|
||||||
|
|
||||||
countlines = [1 for transaction in results]
|
|
||||||
|
|
||||||
for transaction in results:
|
for transaction in results:
|
||||||
r = None
|
r = None
|
||||||
rs = Rower.objects.filter(
|
rs = Rower.objects.filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user