domain migration: Remove several instances of get_realm.

Remove the easy to remove instances of get_realm.
This commit is contained in:
Rishi Gupta 2016-11-17 16:51:13 -08:00 committed by Tim Abbott
parent 0536aeba4d
commit 4b183cd526
3 changed files with 6 additions and 6 deletions

View File

@ -868,7 +868,7 @@ def get_realm_activity(request, realm):
all_user_records = {} # type: Dict[str, Any] all_user_records = {} # type: Dict[str, Any]
try: try:
admins = get_realm(realm).get_admin_users() admins = Realm.objects.get(domain=realm).get_admin_users()
except Realm.DoesNotExist: except Realm.DoesNotExist:
return HttpResponseNotFound("Realm %s does not exist" % (realm,)) return HttpResponseNotFound("Realm %s does not exist" % (realm,))

View File

@ -80,7 +80,7 @@ class ZulipTestCase(TestCase):
django_client to fool the regext. django_client to fool the regext.
''' '''
DEFAULT_REALM_NAME = 'zulip.com' DEFAULT_REALM = Realm.objects.get(string_id='zulip')
@instrument_url @instrument_url
def client_patch(self, url, info={}, **kwargs): 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): def make_stream(self, stream_name, realm=None, invite_only=False):
# type: (text_type, Optional[Realm], Optional[bool]) -> Stream # type: (text_type, Optional[Realm], Optional[bool]) -> Stream
if realm is None: if realm is None:
realm = get_realm(self.DEFAULT_REALM_NAME) realm = self.DEFAULT_REALM
try: try:
stream = Stream.objects.create( stream = Stream.objects.create(

View File

@ -13,8 +13,8 @@ from zerver.lib.actions import internal_send_message
from zerver.lib.redis_utils import get_redis_client from zerver.lib.redis_utils import get_redis_client
from zerver.lib.response import json_success, json_error, json_response from zerver.lib.response import json_success, json_error, json_response
from zerver.lib.validator import check_dict from zerver.lib.validator import check_dict
from zerver.models import get_realm, get_user_profile_by_email, get_realm_by_email_domain, \ from zerver.models import get_realm_by_string_id, get_user_profile_by_email, \
UserProfile, Realm get_realm_by_email_domain, UserProfile, Realm
from .error_notify import notify_server_error, notify_browser_error from .error_notify import notify_server_error, notify_browser_error
import time import time
@ -50,7 +50,7 @@ def get_ticket_number():
def submit_feedback(request, deployment, message=REQ(validator=check_dict([]))): def submit_feedback(request, deployment, message=REQ(validator=check_dict([]))):
# type: (HttpRequest, Deployment, Dict[str, text_type]) -> HttpResponse # type: (HttpRequest, Deployment, Dict[str, text_type]) -> HttpResponse
domainish = message["sender_domain"] 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 domainish += u" via " + deployment.name
subject = "%s" % (message["sender_email"],) subject = "%s" % (message["sender_email"],)