add squashemails command
This commit is contained in:
parent
51f7b75c48
commit
4eafac5953
|
@ -0,0 +1,25 @@
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from accounts.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Squash all users email'
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
answer = input("""You are about to squash all users email.
|
||||||
|
This action is IRREVERSIBLE!
|
||||||
|
Are you sure you want to do this?
|
||||||
|
|
||||||
|
Type 'yes' to continue, or 'no' to cancel: """)
|
||||||
|
|
||||||
|
self.stdout.write('\n')
|
||||||
|
|
||||||
|
if answer != "yes":
|
||||||
|
self.stdout.write(self.style.NOTICE('Action cancelled.'))
|
||||||
|
return
|
||||||
|
|
||||||
|
for user in User.objects.all():
|
||||||
|
user.email = ''
|
||||||
|
user.save()
|
||||||
|
|
||||||
|
self.stdout.write(self.style.SUCCESS('All emails squashed.'))
|
Loading…
Reference in New Issue