Deactivate bots in deactivate_user.py

Closes trac #1434.

(imported from commit d60e338f77b5ee38a43c6cd3edb9b3de0cd0cacf)
This commit is contained in:
Luke Faraone
2013-06-28 17:45:33 -04:00
parent 29cb701444
commit 6a49e8aa1b

View File

@@ -5,7 +5,7 @@ from optparse import make_option
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from zephyr.lib.actions import do_deactivate, user_sessions from zephyr.lib.actions import do_deactivate, user_sessions
from zephyr.models import get_user_profile_by_email from zephyr.models import get_user_profile_by_email, UserProfile
class Command(BaseCommand): class Command(BaseCommand):
help = "Deactivate a user, including forcibly logging them out." help = "Deactivate a user, including forcibly logging them out."
@@ -32,6 +32,12 @@ class Command(BaseCommand):
for session in user_sessions(user_profile): for session in user_sessions(user_profile):
print session.expire_date, session.get_decoded() print session.expire_date, session.get_decoded()
print "" print ""
print "%s has %s active bots that will also be deactivated." % (
user_profile.email,
UserProfile.objects.filter(
is_bot=True, is_active=True, bot_owner=user_profile
).count()
)
if not options["for_real"]: if not options["for_real"]:
print "This was a dry run. Pass -f to actually deactivate." print "This was a dry run. Pass -f to actually deactivate."