models: Rename Realm.restricted_to_domain field.

This renames Realm.restricted_to_domain field to
emails_restricted_to_domains, for greater clarity as to what it does
just from seeing the setting name, without having to look it up.

Fixes part of #10042.
This commit is contained in:
Roman Godov
2018-07-28 00:26:29 +03:00
committed by Tim Abbott
parent 28d04f6960
commit c0806917ec
16 changed files with 82 additions and 62 deletions

View File

@@ -170,7 +170,7 @@ boolean field, `mandatory_topics`, to the Realm model in
class Realm(models.Model): class Realm(models.Model):
# ... # ...
restricted_to_domain = models.BooleanField(default=True) # type: bool emails_restricted_to_domains = models.BooleanField(default=True) # type: bool
invite_required = models.BooleanField(default=False) # type: bool invite_required = models.BooleanField(default=False) # type: bool
+ mandatory_topics = models.BooleanField(default=False) # type: bool + mandatory_topics = models.BooleanField(default=False) # type: bool
``` ```
@@ -498,7 +498,7 @@ function _setup_page() {
var options = { var options = {
realm_name: page_params.realm_name, realm_name: page_params.realm_name,
realm_description: page_params.realm_description, realm_description: page_params.realm_description,
realm_restricted_to_domain: page_params.realm_restricted_to_domain, realm_emails_restricted_to_domains: page_params.realm_emails_restricted_to_domains,
realm_invite_required: page_params.realm_invite_required, realm_invite_required: page_params.realm_invite_required,
// ... // ...
+ realm_mandatory_topics: page_params.mandatory_topics, + realm_mandatory_topics: page_params.mandatory_topics,

View File

@@ -191,10 +191,10 @@ var event_fixtures = {
value: 'new_realm_name', value: 'new_realm_name',
}, },
realm__update__restricted_to_domain: { realm__update__emails_restricted_to_domains: {
type: 'realm', type: 'realm',
op: 'update', op: 'update',
property: 'restricted_to_domain', property: 'emails_restricted_to_domains',
value: false, value: false,
}, },
@@ -688,8 +688,8 @@ with_overrides(function (override) {
dispatch(event); dispatch(event);
assert_same(page_params.realm_name, 'new_realm_name'); assert_same(page_params.realm_name, 'new_realm_name');
event = event_fixtures.realm__update__restricted_to_domain; event = event_fixtures.realm__update__emails_restricted_to_domains;
test_realm_boolean(event, 'realm_restricted_to_domain'); test_realm_boolean(event, 'realm_emails_restricted_to_domains');
event = event_fixtures.realm__update__disallow_disposable_email_addresses; event = event_fixtures.realm__update__disallow_disposable_email_addresses;
test_realm_boolean(event, 'realm_disallow_disposable_email_addresses'); test_realm_boolean(event, 'realm_disallow_disposable_email_addresses');

View File

@@ -531,19 +531,19 @@ function test_sync_realm_settings() {
property_elem.length = 1; property_elem.length = 1;
property_elem.attr('id', 'id_realm_org_join_restrictions'); property_elem.attr('id', 'id_realm_org_join_restrictions');
page_params.realm_restricted_to_domain = true; page_params.realm_emails_restricted_to_domains = true;
page_params.realm_disallow_disposable_email_addresses = false; page_params.realm_disallow_disposable_email_addresses = false;
settings_org.sync_realm_settings('restricted_to_domain'); settings_org.sync_realm_settings('emails_restricted_to_domains');
assert.equal($("#id_realm_org_join_restrictions").val(), "only_selected_domain"); assert.equal($("#id_realm_org_join_restrictions").val(), "only_selected_domain");
page_params.realm_restricted_to_domain = false; page_params.realm_emails_restricted_to_domains = false;
page_params.realm_disallow_disposable_email_addresses = true; page_params.realm_disallow_disposable_email_addresses = true;
settings_org.sync_realm_settings('restricted_to_domain'); settings_org.sync_realm_settings('emails_restricted_to_domains');
assert.equal($("#id_realm_org_join_restrictions").val(), "no_disposable_email"); assert.equal($("#id_realm_org_join_restrictions").val(), "no_disposable_email");
page_params.realm_disallow_disposable_email_addresses = false; page_params.realm_disallow_disposable_email_addresses = false;
settings_org.sync_realm_settings('restricted_to_domain'); settings_org.sync_realm_settings('emails_restricted_to_domains');
assert.equal($("#id_realm_org_join_restrictions").val(), "no_restriction"); assert.equal($("#id_realm_org_join_restrictions").val(), "no_restriction");
} }
} }

View File

@@ -89,7 +89,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
notifications_stream_id: noop, notifications_stream_id: noop,
send_welcome_emails: noop, send_welcome_emails: noop,
signup_notifications_stream_id: noop, signup_notifications_stream_id: noop,
restricted_to_domain: noop, emails_restricted_to_domains: noop,
video_chat_provider: noop, video_chat_provider: noop,
waiting_period_threshold: noop, waiting_period_threshold: noop,
}; };

View File

@@ -155,7 +155,7 @@ function get_property_value(property_name) {
} }
if (property_name === 'realm_org_join_restrictions') { if (property_name === 'realm_org_join_restrictions') {
if (page_params.realm_restricted_to_domain) { if (page_params.realm_emails_restricted_to_domains) {
return "only_selected_domain"; return "only_selected_domain";
} }
if (page_params.realm_disallow_disposable_email_addresses) { if (page_params.realm_disallow_disposable_email_addresses) {
@@ -450,7 +450,7 @@ exports.sync_realm_settings = function (property) {
property = 'create_stream_permission'; property = 'create_stream_permission';
} else if (property === 'allow_message_editing') { } else if (property === 'allow_message_editing') {
property = 'msg_edit_limit_setting'; property = 'msg_edit_limit_setting';
} else if (property === 'restricted_to_domain' || property === 'disallow_disposable_email_addresses') { } else if (property === 'emails_restricted_to_domains' || property === 'disallow_disposable_email_addresses') {
property = 'org_join_restrictions'; property = 'org_join_restrictions';
} else if (property === 'message_content_delete_limit_seconds') { } else if (property === 'message_content_delete_limit_seconds') {
property = 'message_content_delete_limit_minutes'; property = 'message_content_delete_limit_minutes';
@@ -707,14 +707,14 @@ exports.set_up = function () {
var org_join_restrictions = $('#id_realm_org_join_restrictions').val(); var org_join_restrictions = $('#id_realm_org_join_restrictions').val();
if (org_join_restrictions === "only_selected_domain") { if (org_join_restrictions === "only_selected_domain") {
opts.data.restricted_to_domain = true; opts.data.emails_restricted_to_domains = true;
opts.data.disallow_disposable_email_addresses = false; opts.data.disallow_disposable_email_addresses = false;
} else if (org_join_restrictions === "no_disposable_email") { } else if (org_join_restrictions === "no_disposable_email") {
opts.data.restricted_to_domain = false; opts.data.emails_restricted_to_domains = false;
opts.data.disallow_disposable_email_addresses = true; opts.data.disallow_disposable_email_addresses = true;
} else if (org_join_restrictions === "no_restriction") { } else if (org_join_restrictions === "no_restriction") {
opts.data.disallow_disposable_email_addresses = false; opts.data.disallow_disposable_email_addresses = false;
opts.data.restricted_to_domain = false; opts.data.emails_restricted_to_domains = false;
} }
var user_invite_restriction = $('#id_realm_user_invite_restriction').val(); var user_invite_restriction = $('#id_realm_user_invite_restriction').val();

View File

@@ -3167,14 +3167,15 @@ def do_change_stream_description(stream: Stream, new_description: str) -> None:
) )
send_event(event, can_access_stream_user_ids(stream)) send_event(event, can_access_stream_user_ids(stream))
def do_create_realm(string_id: str, name: str, restricted_to_domain: Optional[bool]=None) -> Realm: def do_create_realm(string_id: str, name: str,
emails_restricted_to_domains: Optional[bool]=None) -> Realm:
existing_realm = get_realm(string_id) existing_realm = get_realm(string_id)
if existing_realm is not None: if existing_realm is not None:
raise AssertionError("Realm %s already exists!" % (string_id,)) raise AssertionError("Realm %s already exists!" % (string_id,))
kwargs = {} # type: Dict[str, Any] kwargs = {} # type: Dict[str, Any]
if restricted_to_domain is not None: if emails_restricted_to_domains is not None:
kwargs['restricted_to_domain'] = restricted_to_domain kwargs['emails_restricted_to_domains'] = emails_restricted_to_domains
realm = Realm(string_id=string_id, name=name, **kwargs) realm = Realm(string_id=string_id, name=name, **kwargs)
realm.save() realm.save()
@@ -3192,7 +3193,7 @@ def do_create_realm(string_id: str, name: str, restricted_to_domain: Optional[bo
# Log the event # Log the event
log_event({"type": "realm_created", log_event({"type": "realm_created",
"string_id": string_id, "string_id": string_id,
"restricted_to_domain": restricted_to_domain}) "emails_restricted_to_domains": emails_restricted_to_domains})
# Send a notification to the admin realm (if configured) # Send a notification to the admin realm (if configured)
if settings.NOTIFICATION_BOT is not None: if settings.NOTIFICATION_BOT is not None:
@@ -4634,12 +4635,12 @@ def do_remove_realm_domain(realm_domain: RealmDomain) -> None:
realm = realm_domain.realm realm = realm_domain.realm
domain = realm_domain.domain domain = realm_domain.domain
realm_domain.delete() realm_domain.delete()
if RealmDomain.objects.filter(realm=realm).count() == 0 and realm.restricted_to_domain: if RealmDomain.objects.filter(realm=realm).count() == 0 and realm.emails_restricted_to_domains:
# If this was the last realm domain, we mark the realm as no # If this was the last realm domain, we mark the realm as no
# longer restricted to domain, because the feature doesn't do # longer restricted to domain, because the feature doesn't do
# anything if there are no domains, and this is probably less # anything if there are no domains, and this is probably less
# confusing than the alternative. # confusing than the alternative.
do_set_realm_property(realm, 'restricted_to_domain', False) do_set_realm_property(realm, 'emails_restricted_to_domains', False)
event = dict(type="realm_domains", op="remove", domain=domain) event = dict(type="realm_domains", op="remove", domain=domain)
send_event(event, active_user_ids(realm.id)) send_event(event, active_user_ids(realm.id))

View File

@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-07-27 21:47
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('zerver', '0177_user_message_add_and_index_is_private_flag'),
]
operations = [
migrations.RenameField(
model_name='realm',
old_name='restricted_to_domain',
new_name='emails_restricted_to_domains',
),
]

View File

@@ -159,9 +159,8 @@ class Realm(models.Model):
date_created = models.DateTimeField(default=timezone_now) # type: datetime.datetime date_created = models.DateTimeField(default=timezone_now) # type: datetime.datetime
deactivated = models.BooleanField(default=False) # type: bool deactivated = models.BooleanField(default=False) # type: bool
# Whether email addresses are restricted to a given domain or domains.
# See RealmDomain for the domains that apply for a given organization. # See RealmDomain for the domains that apply for a given organization.
restricted_to_domain = models.BooleanField(default=False) # type: bool emails_restricted_to_domains = models.BooleanField(default=False) # type: bool
invite_required = models.BooleanField(default=True) # type: bool invite_required = models.BooleanField(default=True) # type: bool
invite_by_admins_only = models.BooleanField(default=False) # type: bool invite_by_admins_only = models.BooleanField(default=False) # type: bool
@@ -258,7 +257,7 @@ class Realm(models.Model):
message_retention_days=(int, type(None)), message_retention_days=(int, type(None)),
name=str, name=str,
name_changes_disabled=bool, name_changes_disabled=bool,
restricted_to_domain=bool, emails_restricted_to_domains=bool,
send_welcome_emails=bool, send_welcome_emails=bool,
video_chat_provider=str, video_chat_provider=str,
waiting_period_threshold=int, waiting_period_threshold=int,
@@ -406,7 +405,7 @@ def name_changes_disabled(realm: Optional[Realm]) -> bool:
return settings.NAME_CHANGES_DISABLED or realm.name_changes_disabled return settings.NAME_CHANGES_DISABLED or realm.name_changes_disabled
class RealmDomain(models.Model): class RealmDomain(models.Model):
"""For an organization with restricted_to_domain enabled, the list of """For an organization with emails_restricted_to_domains enabled, the list of
allowed domains""" allowed domains"""
realm = models.ForeignKey(Realm, on_delete=CASCADE) # type: Realm realm = models.ForeignKey(Realm, on_delete=CASCADE) # type: Realm
# should always be stored lowercase # should always be stored lowercase
@@ -443,7 +442,7 @@ class EmailContainsPlusError(Exception):
# So for invite-only realms, this is the test for whether a user can be invited, # So for invite-only realms, this is the test for whether a user can be invited,
# not whether the user can sign up currently.) # not whether the user can sign up currently.)
def email_allowed_for_realm(email: str, realm: Realm) -> None: def email_allowed_for_realm(email: str, realm: Realm) -> None:
if not realm.restricted_to_domain: if not realm.emails_restricted_to_domains:
if realm.disallow_disposable_email_addresses and \ if realm.disallow_disposable_email_addresses and \
is_disposable_domain(email_to_domain(email)): is_disposable_domain(email_to_domain(email)):
raise DisposableEmailError raise DisposableEmailError

View File

@@ -479,7 +479,7 @@ paths:
* `realm_name`: * `realm_name`:
* `realm_restricted_to_domain`: * `realm_emails_restricted_to_domains`:
* `realm_users`: * `realm_users`:
@@ -1016,7 +1016,7 @@ definitions:
format: int64 format: int64
realm_name: realm_name:
type: string type: string
realm_restricted_to_domain: realm_emails_restricted_to_domains:
type: boolean type: boolean
realm_users: realm_users:
type: array type: array

View File

@@ -129,6 +129,7 @@ class HomeTest(ZulipTestCase):
"realm_domains", "realm_domains",
"realm_email_auth_enabled", "realm_email_auth_enabled",
"realm_email_changes_disabled", "realm_email_changes_disabled",
"realm_emails_restricted_to_domains",
"realm_embedded_bots", "realm_embedded_bots",
"realm_emoji", "realm_emoji",
"realm_filters", "realm_filters",
@@ -152,7 +153,6 @@ class HomeTest(ZulipTestCase):
"realm_password_auth_enabled", "realm_password_auth_enabled",
"realm_presence_disabled", "realm_presence_disabled",
"realm_push_notifications_enabled", "realm_push_notifications_enabled",
"realm_restricted_to_domain",
"realm_send_welcome_emails", "realm_send_welcome_emails",
"realm_show_digest_email", "realm_show_digest_email",
"realm_signup_notifications_stream_id", "realm_signup_notifications_stream_id",

View File

@@ -93,25 +93,25 @@ class RealmDomainTest(ZulipTestCase):
result = self.client_delete("/json/realm/domains/acme.com") result = self.client_delete("/json/realm/domains/acme.com")
self.assert_json_success(result) self.assert_json_success(result)
self.assertFalse(RealmDomain.objects.filter(domain='acme.com').exists()) self.assertFalse(RealmDomain.objects.filter(domain='acme.com').exists())
self.assertTrue(realm.restricted_to_domain) self.assertTrue(realm.emails_restricted_to_domains)
def test_delete_all_realm_domains(self) -> None: def test_delete_all_realm_domains(self) -> None:
self.login(self.example_email("iago")) self.login(self.example_email("iago"))
realm = get_realm('zulip') realm = get_realm('zulip')
query = RealmDomain.objects.filter(realm=realm) query = RealmDomain.objects.filter(realm=realm)
self.assertTrue(realm.restricted_to_domain) self.assertTrue(realm.emails_restricted_to_domains)
for realm_domain in query.all(): for realm_domain in query.all():
do_remove_realm_domain(realm_domain) do_remove_realm_domain(realm_domain)
self.assertEqual(query.count(), 0) self.assertEqual(query.count(), 0)
# Deleting last realm_domain should set `restricted_to_domain` to False. # Deleting last realm_domain should set `emails_restricted_to_domains` to False.
# This should be tested on a fresh instance, since the cached objects # This should be tested on a fresh instance, since the cached objects
# would not be updated. # would not be updated.
self.assertFalse(get_realm('zulip').restricted_to_domain) self.assertFalse(get_realm('zulip').emails_restricted_to_domains)
def test_email_allowed_for_realm(self) -> None: def test_email_allowed_for_realm(self) -> None:
realm1 = do_create_realm('testrealm1', 'Test Realm 1', restricted_to_domain=True) realm1 = do_create_realm('testrealm1', 'Test Realm 1', emails_restricted_to_domains=True)
realm2 = do_create_realm('testrealm2', 'Test Realm 2', restricted_to_domain=True) realm2 = do_create_realm('testrealm2', 'Test Realm 2', emails_restricted_to_domains=True)
realm_domain = RealmDomain.objects.create(realm=realm1, domain='test1.com', allow_subdomains=False) realm_domain = RealmDomain.objects.create(realm=realm1, domain='test1.com', allow_subdomains=False)
RealmDomain.objects.create(realm=realm2, domain='test2.test1.com', allow_subdomains=True) RealmDomain.objects.create(realm=realm2, domain='test2.test1.com', allow_subdomains=True)

View File

@@ -120,7 +120,7 @@ class ChangeSettingsTest(ZulipTestCase):
self.login(email) self.login(email)
realm = get_realm("zulip") realm = get_realm("zulip")
realm.disallow_disposable_email_addresses = True realm.disallow_disposable_email_addresses = True
realm.restricted_to_domain = False realm.emails_restricted_to_domains = False
realm.save() realm.save()
json_result = self.client_patch("/json/settings", json_result = self.client_patch("/json/settings",

View File

@@ -893,11 +893,11 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
def test_invite_outside_domain_in_closed_realm(self) -> None: def test_invite_outside_domain_in_closed_realm(self) -> None:
""" """
In a realm with `restricted_to_domain = True`, you can't invite people In a realm with `emails_restricted_to_domains = True`, you can't invite people
with a different domain from that of the realm or your e-mail address. with a different domain from that of the realm or your e-mail address.
""" """
zulip_realm = get_realm("zulip") zulip_realm = get_realm("zulip")
zulip_realm.restricted_to_domain = True zulip_realm.emails_restricted_to_domains = True
zulip_realm.save() zulip_realm.save()
self.login(self.example_email("hamlet")) self.login(self.example_email("hamlet"))
@@ -909,11 +909,11 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
def test_invite_using_disposable_email(self) -> None: def test_invite_using_disposable_email(self) -> None:
""" """
In a realm with `restricted_to_domain = True`, you can't invite people In a realm with `emails_restricted_to_domains = True`, you can't invite people
with a different domain from that of the realm or your e-mail address. with a different domain from that of the realm or your e-mail address.
""" """
zulip_realm = get_realm("zulip") zulip_realm = get_realm("zulip")
zulip_realm.restricted_to_domain = False zulip_realm.emails_restricted_to_domains = False
zulip_realm.disallow_disposable_email_addresses = True zulip_realm.disallow_disposable_email_addresses = True
zulip_realm.save() zulip_realm.save()
@@ -926,11 +926,11 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
def test_invite_outside_domain_in_open_realm(self) -> None: def test_invite_outside_domain_in_open_realm(self) -> None:
""" """
In a realm with `restricted_to_domain = False`, you can invite people In a realm with `emails_restricted_to_domains = False`, you can invite people
with a different domain from that of the realm or your e-mail address. with a different domain from that of the realm or your e-mail address.
""" """
zulip_realm = get_realm("zulip") zulip_realm = get_realm("zulip")
zulip_realm.restricted_to_domain = False zulip_realm.emails_restricted_to_domains = False
zulip_realm.save() zulip_realm.save()
self.login(self.example_email("hamlet")) self.login(self.example_email("hamlet"))
@@ -942,12 +942,12 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
def test_invite_outside_domain_before_closing(self) -> None: def test_invite_outside_domain_before_closing(self) -> None:
""" """
If you invite someone with a different domain from that of the realm If you invite someone with a different domain from that of the realm
when `restricted_to_domain = False`, but `restricted_to_domain` later when `emails_restricted_to_domains = False`, but `emails_restricted_to_domains` later
changes to true, the invitation should succeed but the invitee's signup changes to true, the invitation should succeed but the invitee's signup
attempt should fail. attempt should fail.
""" """
zulip_realm = get_realm("zulip") zulip_realm = get_realm("zulip")
zulip_realm.restricted_to_domain = False zulip_realm.emails_restricted_to_domains = False
zulip_realm.save() zulip_realm.save()
self.login(self.example_email("hamlet")) self.login(self.example_email("hamlet"))
@@ -956,7 +956,7 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
self.assert_json_success(self.invite(external_address, ["Denmark"])) self.assert_json_success(self.invite(external_address, ["Denmark"]))
self.check_sent_emails([external_address]) self.check_sent_emails([external_address])
zulip_realm.restricted_to_domain = True zulip_realm.emails_restricted_to_domains = True
zulip_realm.save() zulip_realm.save()
result = self.submit_reg_form_for_user("foo@example.com", "password") result = self.submit_reg_form_for_user("foo@example.com", "password")
@@ -971,7 +971,7 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
but the invitee's signup attempt should fail. but the invitee's signup attempt should fail.
""" """
zulip_realm = get_realm("zulip") zulip_realm = get_realm("zulip")
zulip_realm.restricted_to_domain = False zulip_realm.emails_restricted_to_domains = False
zulip_realm.disallow_disposable_email_addresses = False zulip_realm.disallow_disposable_email_addresses = False
zulip_realm.save() zulip_realm.save()
@@ -991,14 +991,14 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
def test_invite_with_email_containing_plus_before_closing(self) -> None: def test_invite_with_email_containing_plus_before_closing(self) -> None:
""" """
If you invite someone with an email containing plus when If you invite someone with an email containing plus when
`restricted_to_domain = False`, but later change `emails_restricted_to_domains = False`, but later change
`restricted_to_domain = True`, the invitation should `emails_restricted_to_domains = True`, the invitation should
succeed but the invitee's signup attempt should fail as succeed but the invitee's signup attempt should fail as
users are not allowed to signup using email containing + users are not allowed to signup using email containing +
when the realm is restricted to domain. when the realm is restricted to domain.
""" """
zulip_realm = get_realm("zulip") zulip_realm = get_realm("zulip")
zulip_realm.restricted_to_domain = False zulip_realm.emails_restricted_to_domains = False
zulip_realm.save() zulip_realm.save()
self.login(self.example_email("hamlet")) self.login(self.example_email("hamlet"))
@@ -1007,7 +1007,7 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
self.assert_json_success(self.invite(external_address, ["Denmark"])) self.assert_json_success(self.invite(external_address, ["Denmark"]))
self.check_sent_emails([external_address]) self.check_sent_emails([external_address])
zulip_realm.restricted_to_domain = True zulip_realm.emails_restricted_to_domains = True
zulip_realm.save() zulip_realm.save()
result = self.submit_reg_form_for_user(external_address, "password") result = self.submit_reg_form_for_user(external_address, "password")
@@ -1511,7 +1511,7 @@ class RealmCreationTest(ZulipTestCase):
# Check defaults # Check defaults
self.assertEqual(realm.org_type, Realm.CORPORATE) self.assertEqual(realm.org_type, Realm.CORPORATE)
self.assertEqual(realm.restricted_to_domain, False) self.assertEqual(realm.emails_restricted_to_domains, False)
self.assertEqual(realm.invite_required, True) self.assertEqual(realm.invite_required, True)
# Check welcome messages # Check welcome messages
@@ -2192,7 +2192,7 @@ class UserSignUpTest(ZulipTestCase):
def test_failed_signup_due_to_disposable_email(self) -> None: def test_failed_signup_due_to_disposable_email(self) -> None:
realm = get_realm('zulip') realm = get_realm('zulip')
realm.restricted_to_domain = False realm.emails_restricted_to_domains = False
realm.disallow_disposable_email_addresses = True realm.disallow_disposable_email_addresses = True
realm.save() realm.save()
@@ -2204,7 +2204,7 @@ class UserSignUpTest(ZulipTestCase):
def test_failed_signup_due_to_email_containing_plus(self) -> None: def test_failed_signup_due_to_email_containing_plus(self) -> None:
realm = get_realm('zulip') realm = get_realm('zulip')
realm.restricted_to_domain = True realm.emails_restricted_to_domains = True
realm.save() realm.save()
request = HostRequestMock(host = realm.host) request = HostRequestMock(host = realm.host)

View File

@@ -299,7 +299,7 @@ class AdminCreateUserTest(ZulipTestCase):
"Email 'romeo@zulip.net' already in use") "Email 'romeo@zulip.net' already in use")
# Don't allow user to sign up with disposable email. # Don't allow user to sign up with disposable email.
realm.restricted_to_domain = False realm.emails_restricted_to_domains = False
realm.disallow_disposable_email_addresses = True realm.disallow_disposable_email_addresses = True
realm.save() realm.save()
@@ -309,7 +309,7 @@ class AdminCreateUserTest(ZulipTestCase):
# Don't allow creating a user with + in their email address when realm # Don't allow creating a user with + in their email address when realm
# is restricted to a domain. # is restricted to a domain.
realm.restricted_to_domain = True realm.emails_restricted_to_domains = True
realm.save() realm.save()
valid_params["email"] = "iago+label@zulip.com" valid_params["email"] = "iago+label@zulip.com"
@@ -318,7 +318,7 @@ class AdminCreateUserTest(ZulipTestCase):
# Users can be created with + in their email address when realm # Users can be created with + in their email address when realm
# is not restricted to a domain. # is not restricted to a domain.
realm.restricted_to_domain = False realm.emails_restricted_to_domains = False
realm.save() realm.save()
valid_params["email"] = "iago+label@zulip.com" valid_params["email"] = "iago+label@zulip.com"

View File

@@ -31,7 +31,7 @@ def update_realm(
request: HttpRequest, user_profile: UserProfile, request: HttpRequest, user_profile: UserProfile,
name: Optional[str]=REQ(validator=check_string, default=None), name: Optional[str]=REQ(validator=check_string, default=None),
description: Optional[str]=REQ(validator=check_string, default=None), description: Optional[str]=REQ(validator=check_string, default=None),
restricted_to_domain: Optional[bool]=REQ(validator=check_bool, default=None), emails_restricted_to_domains: Optional[bool]=REQ(validator=check_bool, default=None),
disallow_disposable_email_addresses: Optional[bool]=REQ(validator=check_bool, default=None), disallow_disposable_email_addresses: Optional[bool]=REQ(validator=check_bool, default=None),
invite_required: Optional[bool]=REQ(validator=check_bool, default=None), invite_required: Optional[bool]=REQ(validator=check_bool, default=None),
invite_by_admins_only: Optional[bool]=REQ(validator=check_bool, default=None), invite_by_admins_only: Optional[bool]=REQ(validator=check_bool, default=None),

View File

@@ -140,19 +140,19 @@ class Command(BaseCommand):
# Could in theory be done via zerver.lib.actions.do_create_realm, but # Could in theory be done via zerver.lib.actions.do_create_realm, but
# welcome-bot (needed for do_create_realm) hasn't been created yet # welcome-bot (needed for do_create_realm) hasn't been created yet
zulip_realm = Realm.objects.create( zulip_realm = Realm.objects.create(
string_id="zulip", name="Zulip Dev", restricted_to_domain=True, string_id="zulip", name="Zulip Dev", emails_restricted_to_domains=True,
description="The Zulip development environment default organization." description="The Zulip development environment default organization."
" It's great for testing!", " It's great for testing!",
invite_required=False, org_type=Realm.CORPORATE) invite_required=False, org_type=Realm.CORPORATE)
RealmDomain.objects.create(realm=zulip_realm, domain="zulip.com") RealmDomain.objects.create(realm=zulip_realm, domain="zulip.com")
if options["test_suite"]: if options["test_suite"]:
mit_realm = Realm.objects.create( mit_realm = Realm.objects.create(
string_id="zephyr", name="MIT", restricted_to_domain=True, string_id="zephyr", name="MIT", emails_restricted_to_domains=True,
invite_required=False, org_type=Realm.CORPORATE) invite_required=False, org_type=Realm.CORPORATE)
RealmDomain.objects.create(realm=mit_realm, domain="mit.edu") RealmDomain.objects.create(realm=mit_realm, domain="mit.edu")
lear_realm = Realm.objects.create( lear_realm = Realm.objects.create(
string_id="lear", name="Lear & Co.", restricted_to_domain=False, string_id="lear", name="Lear & Co.", emails_restricted_to_domains=False,
invite_required=False, org_type=Realm.CORPORATE) invite_required=False, org_type=Realm.CORPORATE)
# Create test Users (UserProfiles are automatically created, # Create test Users (UserProfiles are automatically created,