diff --git a/analytics/views.py b/analytics/views.py index e1d8b0bc6a..9e4945e8fc 100644 --- a/analytics/views.py +++ b/analytics/views.py @@ -868,7 +868,7 @@ def get_realm_activity(request, realm): all_user_records = {} # type: Dict[str, Any] try: - admins = get_realm(realm).get_admin_users() + admins = Realm.objects.get(domain=realm).get_admin_users() except Realm.DoesNotExist: return HttpResponseNotFound("Realm %s does not exist" % (realm,)) diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index 0867f51c25..1fc0d21739 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -80,7 +80,7 @@ class ZulipTestCase(TestCase): django_client to fool the regext. ''' - DEFAULT_REALM_NAME = 'zulip.com' + DEFAULT_REALM = Realm.objects.get(string_id='zulip') @instrument_url def client_patch(self, url, info={}, **kwargs): @@ -336,7 +336,7 @@ class ZulipTestCase(TestCase): def make_stream(self, stream_name, realm=None, invite_only=False): # type: (text_type, Optional[Realm], Optional[bool]) -> Stream if realm is None: - realm = get_realm(self.DEFAULT_REALM_NAME) + realm = self.DEFAULT_REALM try: stream = Stream.objects.create( diff --git a/zilencer/views.py b/zilencer/views.py index b723126c24..9bced3d0e8 100644 --- a/zilencer/views.py +++ b/zilencer/views.py @@ -13,8 +13,8 @@ from zerver.lib.actions import internal_send_message from zerver.lib.redis_utils import get_redis_client from zerver.lib.response import json_success, json_error, json_response from zerver.lib.validator import check_dict -from zerver.models import get_realm, get_user_profile_by_email, get_realm_by_email_domain, \ - UserProfile, Realm +from zerver.models import get_realm_by_string_id, get_user_profile_by_email, \ + get_realm_by_email_domain, UserProfile, Realm from .error_notify import notify_server_error, notify_browser_error import time @@ -50,7 +50,7 @@ def get_ticket_number(): def submit_feedback(request, deployment, message=REQ(validator=check_dict([]))): # type: (HttpRequest, Deployment, Dict[str, text_type]) -> HttpResponse domainish = message["sender_domain"] - if get_realm("zulip.com") not in deployment.realms.all(): + if get_realm_by_string_id("zulip") not in deployment.realms.all(): domainish += u" via " + deployment.name subject = "%s" % (message["sender_email"],)