FInal bank, stripe and paypal sandbox completed
This commit is contained in:
@@ -227,6 +227,8 @@ class Account(SoftDeletableModel):
|
||||
# Core (last due to dependencies)
|
||||
'sector_set',
|
||||
'site_set',
|
||||
# Users (delete after sites to avoid FK issues, owner is SET_NULL)
|
||||
'users',
|
||||
# Subscription (OneToOne)
|
||||
'subscription',
|
||||
]
|
||||
@@ -285,6 +287,12 @@ class Account(SoftDeletableModel):
|
||||
from django.core.exceptions import PermissionDenied
|
||||
raise PermissionDenied("System account cannot be deleted.")
|
||||
|
||||
# Clear owner reference first to avoid FK constraint issues
|
||||
# (owner is SET_NULL but we're deleting the user who is the owner)
|
||||
if self.owner:
|
||||
self.owner = None
|
||||
self.save(update_fields=['owner'])
|
||||
|
||||
# Cascade hard-delete all related objects first
|
||||
self._cascade_delete_related(hard_delete=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user