realm-create: Update default user email visibility for org_type.

When creating a new organization, the new user default for email
address visibility is now limited to admins for most organization
types. The exceptions are education organizations, which have the
default set to moderators, and business organizations, which have
the default set to all users.

Fixes #34859.
This commit is contained in:
Lauryn Menard
2025-07-07 12:20:05 -04:00
committed by Tim Abbott
parent 4e97a6d80e
commit ca48ffccb8

View File

@@ -239,14 +239,21 @@ def do_create_realm(
},
)
realm_default_email_address_visibility = RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_EVERYONE
# For the majority of organization types, the default email address visibility
# setting for new users should initially be admins only.
realm_default_email_address_visibility = RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_ADMINS
if realm.org_type in (
Realm.ORG_TYPES["education_nonprofit"]["id"],
Realm.ORG_TYPES["education"]["id"],
):
# Email address of users should be initially visible to admins only.
# Email address of users should be initially visible to moderators and admins.
realm_default_email_address_visibility = (
RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_ADMINS
RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_MODERATORS
)
if realm.org_type == Realm.ORG_TYPES["business"]["id"]:
# Email address of users can be visible to all users for business organizations.
realm_default_email_address_visibility = (
RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_EVERYONE
)
RealmUserDefault.objects.create(