Commit b383c5db authored by Birin Sanchez's avatar Birin Sanchez
Browse files

* When parsing subscriptions with no next_payment_date set


  Subscription attribute to None rather than 1900-01-01

* Do not cancel subscriptions already cancelled or expired when
  deleting a user account.
Signed-off-by: Birin Sanchez's avatarBirin Sanchez <birin.sanchez@puri.sm>
parent 7b387e0b
Pipeline #54864 failed with stages
in 1 minute and 34 seconds
......@@ -175,8 +175,12 @@ def delete_account(user, purge_n=0, purge=False):
# Cancell all user subscriptions
subs = SubscriptionManager.search_subscriptions(user)
for sub in subs:
sub.status = SubscriptionStatus.CANCELLED
sub.save()
if (
sub.status != SubscriptionStatus.CANCELLED
and sub.status != SubscriptionStatus.EXPIRED
):
sub.status = SubscriptionStatus.CANCELLED
sub.save()
# Remove WC PII
user.remove_woocommerce_pii()
......
......@@ -298,7 +298,7 @@ class Subscription:
json_entry["next_payment_date"], "%Y-%m-%dT%H:%M:%S")
next_renewal = timezone.make_aware(next_renewal_naive)
else:
next_renewal = timezone.datetime(1900, 1, 1, 0, 0)
next_renewal = None
# get User
if user is None:
......@@ -398,7 +398,10 @@ class Subscription:
b_period = 'month'
else:
b_period = ''
next_p_date = self.next_payment_date.strftime('%Y-%m-%d %H:%M:%S')
if self.next_payment_date is None:
next_p_date = ''
else:
next_p_date = self.next_payment_date.strftime('%Y-%m-%d %H:%M:%S')
data = {
'id': self.subscription_id,
'status': self.status.value,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment