mirror of https://github.com/zulip/zulip.git
management: Use self.get_realm in logout_all_users.
This commit is contained in:
parent
e28a007487
commit
cf61349563
|
@ -3,31 +3,25 @@ from __future__ import absolute_import
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from zerver.lib.management import ZulipBaseCommand
|
||||||
|
|
||||||
from zerver.lib.sessions import delete_all_user_sessions, \
|
from zerver.lib.sessions import delete_all_user_sessions, \
|
||||||
delete_realm_user_sessions, delete_all_deactivated_user_sessions
|
delete_realm_user_sessions, delete_all_deactivated_user_sessions
|
||||||
from zerver.models import get_realm
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(ZulipBaseCommand):
|
||||||
help = "Log out all users."
|
help = "Log out all users."
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
# type: (ArgumentParser) -> None
|
# type: (ArgumentParser) -> None
|
||||||
parser.add_argument('--realm',
|
|
||||||
dest='realm',
|
|
||||||
action='store',
|
|
||||||
default=None,
|
|
||||||
help="Only logout all users in a particular realm")
|
|
||||||
parser.add_argument('--deactivated-only',
|
parser.add_argument('--deactivated-only',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
default=False,
|
default=False,
|
||||||
help="Only logout all users who are deactivated")
|
help="Only logout all users who are deactivated")
|
||||||
|
self.add_realm_args(parser, help="Only logout all users in a particular realm")
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **Any) -> None
|
# type: (*Any, **Any) -> None
|
||||||
if options["realm"]:
|
realm = self.get_realm(options)
|
||||||
realm = get_realm(options["realm"])
|
if realm:
|
||||||
delete_realm_user_sessions(realm)
|
delete_realm_user_sessions(realm)
|
||||||
elif options["deactivated_only"]:
|
elif options["deactivated_only"]:
|
||||||
delete_all_deactivated_user_sessions()
|
delete_all_deactivated_user_sessions()
|
||||||
|
|
Loading…
Reference in New Issue