Added CustomUser model reload code

This commit is contained in:
M.Ravi 2017-06-22 23:48:14 +05:30
parent 5caa79f199
commit d4e7eb9511

View file

@ -176,16 +176,14 @@ class StripeCustomer(models.Model):
return stripe_customer return stripe_customer
except StripeCustomer.DoesNotExist: except StripeCustomer.DoesNotExist:
CustomUser.refresh_from_db()
user = CustomUser.objects.get(email=email) user = CustomUser.objects.get(email=email)
stripe_utils = StripeUtils() stripe_utils = StripeUtils()
stripe_data = stripe_utils.create_customer(token, email) stripe_data = stripe_utils.create_customer(token, email)
if stripe_data.get('response_object'): if stripe_data.get('response_object'):
stripe_cus_id = stripe_data.get('response_object').get('id') stripe_cus_id = stripe_data.get('response_object').get('id')
stripe_customer = StripeCustomer.objects.\ stripe_customer = StripeCustomer.objects.\
create(user=user, stripe_id=stripe_cus_id) create(user=user, stripe_id=stripe_cus_id)
return stripe_customer return stripe_customer
else: else:
return None return None