From 7ee945062db49db7bab8a2f43a0ffebb9985ef7a Mon Sep 17 00:00:00 2001 From: Luke Faraone Date: Thu, 13 Dec 2012 12:07:20 -0500 Subject: [PATCH] Add command to mark users as inactive. This is useful when testing the sigup workflow, as this script enables you to run through a MIT signup without manually creating a new inactive user in the database. (imported from commit c22649cc7c561c2fbe8682d1b17d7e5aba9ac04e) --- zephyr/management/commands/test_deactivate.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 zephyr/management/commands/test_deactivate.py diff --git a/zephyr/management/commands/test_deactivate.py b/zephyr/management/commands/test_deactivate.py new file mode 100644 index 0000000000..b7563acfd4 --- /dev/null +++ b/zephyr/management/commands/test_deactivate.py @@ -0,0 +1,20 @@ +from optparse import make_option +from django.core.management.base import BaseCommand +from confirmation.models import Confirmation +from zephyr.models import User, MitUser + +class Command(BaseCommand): + help = "Mark one or more users as inactive in the database." + + def handle(self, *args, **options): + for email in args: + try: + user = User.objects.get(email=email) + if user.is_active: + user.is_active = False + user.save() + print email + ": Deactivated." + else: + print email + ": Already inactive." + except User.DoesNotExist: + print email + ": User does not exist in database"