Add additional None checks
This commit is contained in:
parent
0f777e66d8
commit
3f01145cd1
1 changed files with 67 additions and 7 deletions
|
@ -86,12 +86,39 @@ class Command(BaseCommand):
|
||||||
vm_ids = []
|
vm_ids = []
|
||||||
for order in hosting_orders:
|
for order in hosting_orders:
|
||||||
vm_ids.append(order.vm_id)
|
vm_ids.append(order.vm_id)
|
||||||
|
|
||||||
# Delete Billing Address
|
# Delete Billing Address
|
||||||
order.billing_address.delete()
|
if order.billing_address is not None:
|
||||||
|
order.billing_address.delete()
|
||||||
|
logger.debug(
|
||||||
|
"Billing Address {} associated with {} deleted"
|
||||||
|
"".format(order.billing_address.id, email)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.error(
|
||||||
|
"Error while deleting the billing_address")
|
||||||
|
|
||||||
# Delete Order Detail
|
# Delete Order Detail
|
||||||
order.order_detail.delete()
|
if order.order_detail is not None:
|
||||||
|
order.order_detail.delete()
|
||||||
|
logger.debug(
|
||||||
|
"Order Detail {} associated with {} deleted"
|
||||||
|
"".format(order.order_detail.id, email)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.error(
|
||||||
|
"Error while deleting the order_detail. None")
|
||||||
|
|
||||||
# Delete order
|
# Delete order
|
||||||
order.delete()
|
if order is not None:
|
||||||
|
order.delete()
|
||||||
|
logger.debug(
|
||||||
|
"Order {} associated with {} deleted"
|
||||||
|
"".format(order.id, email)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.error(
|
||||||
|
"Error while deleting the Order")
|
||||||
|
|
||||||
hosting_bills = HostingBill.objects.filter(
|
hosting_bills = HostingBill.objects.filter(
|
||||||
customer=stripe_customer.id
|
customer=stripe_customer.id
|
||||||
|
@ -99,20 +126,53 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
# delete hosting bills
|
# delete hosting bills
|
||||||
for bill in hosting_bills:
|
for bill in hosting_bills:
|
||||||
bill.billing_address.delete()
|
if bill.billing_address is not None:
|
||||||
bill.delete()
|
bill.billing_address.delete()
|
||||||
|
logger.debug(
|
||||||
|
"HostingBills billing address {} associated with {} deleted"
|
||||||
|
"".format(bill.billing_address.id, email)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.error(
|
||||||
|
"Error while deleting the HostingBill's Billing address")
|
||||||
|
|
||||||
|
if bill is not None:
|
||||||
|
bill.delete()
|
||||||
|
logger.debug(
|
||||||
|
"HostingBill {} associated with {} deleted"
|
||||||
|
"".format(bill.id, email)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.error(
|
||||||
|
"Error while deleting the HostingBill")
|
||||||
|
|
||||||
# delete VMDetail
|
# delete VMDetail
|
||||||
for vm_id in vm_ids:
|
for vm_id in vm_ids:
|
||||||
vm_detail = VMDetail.objects.get(vm_id=vm_id)
|
vm_detail = VMDetail.objects.get(vm_id=vm_id)
|
||||||
vm_detail.delete()
|
if vm_detail is not None:
|
||||||
|
vm_detail.delete()
|
||||||
|
logger.debug(
|
||||||
|
"vm_detail {} associated with {} deleted"
|
||||||
|
"".format(vm_detail.id, email)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.error(
|
||||||
|
"Error while deleting the vm_detail")
|
||||||
|
|
||||||
# delete UserCardDetail
|
# delete UserCardDetail
|
||||||
ucds = UserCardDetail.objects.filter(
|
ucds = UserCardDetail.objects.filter(
|
||||||
stripe_customer=stripe_customer
|
stripe_customer=stripe_customer
|
||||||
)
|
)
|
||||||
for ucd in ucds:
|
for ucd in ucds:
|
||||||
ucd.delete()
|
if ucd is not None:
|
||||||
|
ucd.delete()
|
||||||
|
logger.debug(
|
||||||
|
"User Card Detail {} associated with {} deleted"
|
||||||
|
"".format(ucd.id, email)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.error(
|
||||||
|
"Error while deleting the User Card Detail")
|
||||||
|
|
||||||
# delete UserHostingKey
|
# delete UserHostingKey
|
||||||
uhks = UserHostingKey.objects.filter(
|
uhks = UserHostingKey.objects.filter(
|
||||||
|
|
Loading…
Reference in a new issue