From 4eafac595320e9f5fbe8f8db1020fbe58c7fb9c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Thu, 29 Sep 2016 00:33:05 +0200 Subject: [PATCH] add squashemails command --- ponyconf/management/__init__.py | 0 ponyconf/management/commands/__init__.py | 0 ponyconf/management/commands/squashemails.py | 25 ++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 ponyconf/management/__init__.py create mode 100644 ponyconf/management/commands/__init__.py create mode 100644 ponyconf/management/commands/squashemails.py diff --git a/ponyconf/management/__init__.py b/ponyconf/management/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ponyconf/management/commands/__init__.py b/ponyconf/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ponyconf/management/commands/squashemails.py b/ponyconf/management/commands/squashemails.py new file mode 100644 index 0000000..3a5a456 --- /dev/null +++ b/ponyconf/management/commands/squashemails.py @@ -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.'))