Skip to content

Commit

Permalink
fix: add site deletion to delete_user script
Browse files Browse the repository at this point in the history
  • Loading branch information
paulschreiber committed Oct 2, 2024
1 parent 5ee0787 commit bcd624d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions terraso_backend/apps/core/management/commands/delete_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from apps.core.models import User
from apps.project_management.models import Project
from apps.project_management.models.sites import Site


class Command(BaseCommand):
Expand Down Expand Up @@ -50,6 +51,12 @@ def handle(self, *args, **options):
for project in projects:
project.delete()

# sites created by the user
sites = Site.objects.filter(owner_id=user.id)

for site in sites:
site.delete()

# NOTE: user deletion currently fails due to audit logs
try:
user.delete()
Expand Down

0 comments on commit bcd624d

Please sign in to comment.