Add method to nuke all user related content

Specifically, all users that are not a superuser
This commit is contained in:
Ramon Wenger 2023-08-30 17:19:45 +02:00
parent fc59bf0b6d
commit 1c4c1a8494
1 changed files with 13 additions and 0 deletions

13
server/nuke_users.py Normal file
View File

@ -0,0 +1,13 @@
from wagtail.admin.forms.account import User
from assignments.models import Assignment
from objectives.models import Objective
from rooms.models import Comment
def nuke_users():
# todo: make sure the user confirms this when called from a django command
Objective.objects.exclude(owner=None).delete()
Comment.objects.all().delete()
Assignment.objects.exclude(owner=None).exclude(owner__username="guru").delete()
User.objects.filter(is_superuser=False).delete()