From 018c3b5bba95c2c4ad435c62aa839dc39d985e90 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 27 May 2025 10:58:33 +0530 Subject: [PATCH] More debugging --- datacenterlight/views.py | 6 ++++-- hosting/models.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 1e486242..331e0fc9 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -1219,6 +1219,7 @@ def get_or_create_custom_user(request, stripe_api_cus_id): def set_user_card(card_id, stripe_api_cus_id, custom_user, card_details_response): + logger.debug(":: set_user_card") if card_id: logger.debug("card_id %s was in request" % card_id) user_card_detail = UserCardDetail.get_ucd_from_card_id(card_id=card_id) @@ -1233,17 +1234,18 @@ def set_user_card(card_id, stripe_api_cus_id, custom_user, stripe_source_id=user_card_detail.card_id ) else: - logger.debug("card_id was NOT in request, using " + logger.debug(" card_id was NOT in request, using " "card_details_response") ucd = UserCardDetail.get_or_create_user_card_detail( stripe_customer=custom_user.stripecustomer, card_details=card_details_response ) - logger.debug("ucd = %s" % ucd) + logger.debug(" ucd = %s" % ucd) UserCardDetail.save_default_card_local( custom_user.stripecustomer.stripe_id, ucd.card_id ) + logger.debug(" after save_default_card_local") card_details_dict = { 'last4': ucd.last4, 'brand': ucd.brand, diff --git a/hosting/models.py b/hosting/models.py index 4c039fef..f17d8a57 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -699,15 +699,19 @@ class UserCardDetail(AssignPermissionsMixin, models.Model): @staticmethod def save_default_card_local(stripe_api_cus_id, card_id): + print("save_default_card_local {}, {}".format(stripe_api_cus_id, card_id)) stripe_cust = StripeCustomer.objects.get(stripe_id=stripe_api_cus_id) + print(" stripe_cust={}".format(stripe_cust)) user_card_detail = UserCardDetail.get_ucd_from_stripe_cust_n_card_id( stripe_customer=stripe_cust, card_id=card_id ) + print(" user_card_detail={}".format(user_card_detail)) for card in stripe_cust.usercarddetail_set.all(): card.preferred = False card.save() user_card_detail.preferred = True user_card_detail.save() + print(" save_default_card_local DONE") @staticmethod def get_ucd_from_card_id(card_id):