mirror of https://github.com/zulip/zulip.git
Remove calls to get_realm in preparation for its deprecation.
Also removes two calls to email_to_domain.
This commit is contained in:
parent
e9a6bd1986
commit
717afcb408
|
@ -10,7 +10,7 @@ from django.http import HttpResponseNotFound, HttpRequest, HttpResponse
|
|||
from jinja2 import Markup as mark_safe
|
||||
|
||||
from zerver.decorator import has_request_variables, REQ, zulip_internal
|
||||
from zerver.models import get_realm, UserActivity, UserActivityInterval, Realm
|
||||
from zerver.models import UserActivity, UserActivityInterval, Realm
|
||||
from zerver.lib.timestamp import timestamp_to_datetime
|
||||
|
||||
from collections import defaultdict
|
||||
|
|
|
@ -14,7 +14,7 @@ from zerver.lib.actions import do_change_password, is_inactive, user_email_is_un
|
|||
from zerver.lib.name_restrictions import is_reserved_subdomain, is_disposable_domain
|
||||
from zerver.lib.utils import get_subdomain, check_subdomain
|
||||
from zerver.models import Realm, get_user_profile_by_email, UserProfile, \
|
||||
get_realm, get_realm_by_email_domain, get_realm_by_string_id, \
|
||||
get_realm_by_email_domain, get_realm_by_string_id, \
|
||||
get_unique_open_realm, email_to_domain, email_allowed_for_realm
|
||||
from zproject.backends import password_auth_enabled
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from typing import Any, Iterable, Mapping, Optional, Set, Tuple, Text
|
|||
|
||||
from zerver.lib.initial_password import initial_password
|
||||
from zerver.models import Realm, Stream, UserProfile, Huddle, \
|
||||
Subscription, Recipient, Client, get_huddle_hash, email_to_domain
|
||||
Subscription, Recipient, Client, get_huddle_hash
|
||||
from zerver.lib.create_user import create_user_profile
|
||||
|
||||
def bulk_create_realms(realm_list):
|
||||
|
|
|
@ -32,7 +32,6 @@ from zerver.lib.test_helpers import (
|
|||
)
|
||||
|
||||
from zerver.models import (
|
||||
get_realm,
|
||||
get_stream,
|
||||
get_user_profile_by_email,
|
||||
get_realm_by_email_domain,
|
||||
|
|
|
@ -30,7 +30,6 @@ from zerver.lib.actions import (
|
|||
)
|
||||
|
||||
from zerver.models import (
|
||||
get_realm,
|
||||
get_stream,
|
||||
get_user_profile_by_email,
|
||||
Client,
|
||||
|
|
|
@ -241,6 +241,8 @@ class Realm(ModelReprMixin, models.Model):
|
|||
|
||||
post_save.connect(flush_realm, sender=Realm)
|
||||
|
||||
# This function is about to be deprecated. Consider using
|
||||
# get_realm_by_string_id instead.
|
||||
def get_realm(domain):
|
||||
# type: (Text) -> Optional[Realm]
|
||||
if not domain:
|
||||
|
|
|
@ -31,7 +31,7 @@ from zerver.lib.test_classes import (
|
|||
from zerver.models import (
|
||||
MAX_MESSAGE_LENGTH, MAX_SUBJECT_LENGTH,
|
||||
Message, Realm, Recipient, Stream, UserMessage, UserProfile, Attachment, RealmAlias,
|
||||
get_realm_by_string_id, get_realm, get_stream, get_user_profile_by_email,
|
||||
get_realm_by_string_id, get_stream, get_user_profile_by_email,
|
||||
Reaction, sew_messages_and_reactions
|
||||
)
|
||||
|
||||
|
@ -383,7 +383,7 @@ class StreamMessagesTest(ZulipTestCase):
|
|||
"""
|
||||
Check that messages sent to a stream reach all subscribers to that stream.
|
||||
"""
|
||||
realm = get_realm('zulip.com')
|
||||
realm = get_realm_by_string_id('zulip')
|
||||
subscribers = self.users_subscribed_to_stream(stream_name, realm)
|
||||
old_subscriber_messages = []
|
||||
for subscriber in subscribers:
|
||||
|
|
|
@ -40,7 +40,7 @@ from zerver.lib.actions import (
|
|||
gather_subscriptions_helper, bulk_add_subscriptions, bulk_remove_subscriptions,
|
||||
gather_subscriptions, get_default_streams_for_realm, get_realm_by_string_id, get_stream,
|
||||
get_user_profile_by_email, set_default_streams, get_subscription,
|
||||
create_streams_if_needed, active_user_ids, get_realm
|
||||
create_streams_if_needed, active_user_ids
|
||||
)
|
||||
|
||||
from zerver.views.streams import (
|
||||
|
@ -2033,8 +2033,8 @@ class GetSubscribersTest(ZulipTestCase):
|
|||
self.user_profile = get_user_profile_by_email(self.email)
|
||||
self.login(self.email)
|
||||
|
||||
def check_well_formed_result(self, result, stream_name, realm_domain):
|
||||
# type: (Dict[str, Any], Text, Text) -> None
|
||||
def check_well_formed_result(self, result, stream_name, realm):
|
||||
# type: (Dict[str, Any], Text, Realm) -> None
|
||||
"""
|
||||
A successful call to get_subscribers returns the list of subscribers in
|
||||
the form:
|
||||
|
@ -2043,7 +2043,6 @@ class GetSubscribersTest(ZulipTestCase):
|
|||
"result": "success",
|
||||
"subscribers": ["hamlet@zulip.com", "prospero@zulip.com"]}
|
||||
"""
|
||||
realm = get_realm(realm_domain)
|
||||
self.assertIn("subscribers", result)
|
||||
self.assertIsInstance(result["subscribers"], list)
|
||||
true_subscribers = [user_profile.email for user_profile in self.users_subscribed_to_stream(
|
||||
|
@ -2062,7 +2061,7 @@ class GetSubscribersTest(ZulipTestCase):
|
|||
result = self.make_subscriber_request(stream_name)
|
||||
self.assert_json_success(result)
|
||||
self.check_well_formed_result(ujson.loads(result.content),
|
||||
stream_name, self.user_profile.realm.domain)
|
||||
stream_name, self.user_profile.realm)
|
||||
|
||||
def test_subscriber(self):
|
||||
# type: () -> None
|
||||
|
|
|
@ -19,8 +19,7 @@ from zerver.models import Message, UserProfile, Stream, Subscription, Huddle, \
|
|||
Recipient, Realm, UserMessage, DefaultStream, RealmEmoji, RealmAlias, \
|
||||
RealmFilter, \
|
||||
PreregistrationUser, get_client, UserActivity, \
|
||||
get_stream, UserPresence, get_recipient, name_changes_disabled, \
|
||||
email_to_domain, email_to_username, get_realm, \
|
||||
get_stream, UserPresence, get_recipient, name_changes_disabled, email_to_username, \
|
||||
completely_open, get_unique_open_realm, email_allowed_for_realm, \
|
||||
get_realm_by_string_id, get_realm_by_email_domain, list_of_domains_for_realm
|
||||
from zerver.lib.actions import do_change_password, do_change_full_name, do_change_is_admin, \
|
||||
|
|
|
@ -13,7 +13,7 @@ from zerver.lib.actions import do_create_user
|
|||
|
||||
from zerver.models import UserProfile, Realm, get_user_profile_by_id, \
|
||||
get_user_profile_by_email, remote_user_to_email, email_to_username, \
|
||||
get_realm, get_realm_by_email_domain
|
||||
get_realm_by_email_domain
|
||||
|
||||
from apiclient.sample_tools import client as googleapiclient
|
||||
from oauth2client.crypt import AppIdentityError
|
||||
|
|
Loading…
Reference in New Issue