Commit 2b5942b1 authored by Birin Sanchez's avatar Birin Sanchez

Remove consumed invitations when deleting an invitee account so the

Family pack owner can create a new invitation.
Signed-off-by: Birin Sanchez's avatarBirin Sanchez <birin.sanchez@puri.sm>
parent 23b0bf18
Pipeline #36850 passed with stage
in 32 seconds
......@@ -8,6 +8,8 @@ from purist.limitmonitor import ServicesContainer
from limitmonitor.models import ExternalBundle, Limit
from limitmonitor.tunnel import TunnelManager
from limitmonitor.subscription import SubscriptionManager, SubscriptionStatus
from invitation.models import Invitation
logger = logging.getLogger(__name__)
......@@ -167,6 +169,14 @@ def delete_account(user, purge_n=0, purge=False):
# Remove WC PII
user.remove_woocommerce_pii()
# If the account is of type invitee free up that invitation slot
if user.account_type == AccountType.INVITED:
try:
inv = Invitation.objects.get(guest=user)
inv.delete()
except Invitation.DoesNotExist as e:
logger.error(repr(e))
if purge:
ldap_user = user.get_ldap()
ldap_user.delete()
......
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