demo-orgs: Set owner `email_address_visibility` on account creation.

Since an email address is not required to create a demo organization,
we need a Zulip API email address for the web-app to use until the
owner configures an email for their account.

Here, we set the owner's `email_address_visibility` to "Nobody" when
the owner's account is created so that the Zulip API email field in
their profile is a fake email address string.
This commit is contained in:
Lauryn Menard 2022-08-05 18:51:40 +02:00 committed by Tim Abbott
parent 5e33ae8adf
commit a9eb70ac68
2 changed files with 7 additions and 0 deletions

View File

@ -3957,6 +3957,11 @@ class UserSignUpTest(ZulipTestCase):
scheduled_email = ScheduledEmail.objects.filter(users=user_profile).last()
assert scheduled_email is None
self.assertIn(realm.string_id, user_profile.email)
self.assertEqual(
user_profile.email_address_visibility, UserProfile.EMAIL_ADDRESS_VISIBILITY_NOBODY
)
expected_deletion_date = realm.date_created + datetime.timedelta(
days=settings.DEMO_ORG_DEADLINE_DAYS
)

View File

@ -94,6 +94,7 @@ def register_demo_development_realm(request: HttpRequest) -> HttpResponse:
realm_name = generate_demo_realm_name()
realm_type = Realm.ORG_TYPES["business"]["id"]
realm_subdomain = realm_name
email_address_visibility = UserProfile.EMAIL_ADDRESS_VISIBILITY_NOBODY
prereg_realm = create_preregistration_realm(email, realm_name, realm_subdomain, realm_type)
activation_url = create_confirmation_link(
prereg_realm, Confirmation.REALM_CREATION, realm_creation=True
@ -105,6 +106,7 @@ def register_demo_development_realm(request: HttpRequest) -> HttpResponse:
key=key,
realm_name=realm_name,
realm_type=realm_type,
email_address_visibility=email_address_visibility,
full_name=name,
password="test",
realm_subdomain=realm_subdomain,