Access realm by string_id in management commands.

`Realm.string_id` replaces 'Realm.domain'
in the management commands.

Fixes #2325.
This commit is contained in:
reyha
2016-11-16 20:16:02 +00:00
committed by Tim Abbott
parent 7f8aef1a17
commit 82e32ad255
25 changed files with 119 additions and 116 deletions

View File

@@ -11,7 +11,7 @@ import pytz
from django.core.management.base import BaseCommand
from django.db.models import Count
from zerver.models import UserProfile, Realm, Stream, Message, Recipient, UserActivity, \
Subscription, UserMessage, get_realm
Subscription, UserMessage, get_realm_by_string_id
MOBILE_CLIENT_LIST = ["Android", "ios"]
HUMAN_CLIENT_LIST = MOBILE_CLIENT_LIST + ["website"]
@@ -86,7 +86,7 @@ class Command(BaseCommand):
# type: (*Any, **Any) -> None
if options['realms']:
try:
realms = [get_realm(domain) for domain in options['realms']]
realms = [get_realm_by_string_id(string_id) for string_id in options['realms']]
except Realm.DoesNotExist as e:
print(e)
exit(1)
@@ -94,7 +94,7 @@ class Command(BaseCommand):
realms = Realm.objects.all()
for realm in realms:
print(realm.domain)
print(realm.string_id)
user_profiles = UserProfile.objects.filter(realm=realm, is_active=True)
active_users = self.active_users(realm)