Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
emails: Add organization details to confirm registration for new org.
Lauryn Menard276ceb46e2aa
diff --git a/templates/zerver/emails/confirm_registration.html b/templates/zerver/emails/confirm_registration.htmlindex e84e9fd6b22..15af7be0418 100644--- a/templates/zerver/emails/confirm_registration.html+++ b/templates/zerver/emails/confirm_registration.html@@ -7,18 +7,22 @@{% block content %}<p>{% if create_realm %}- {{ _('You have requested a new Zulip organization. Awesome!') }}+ {{ _("You have requested a new Zulip organization:") }}+ <ul>+ <li>{% trans %}Organization URL: {{ organization_url }}{% endtrans %}</li>+ <li>{% trans %}Organization type: {{ organization_type }}{% endtrans %}</li>+ </ul>{% else %}- {{ _('You recently signed up for Zulip. Awesome!') }}+ {{ _("You recently signed up for Zulip. Awesome!") }}{% endif %}</p><p>{% if create_realm %}- {{ _('Click the button below to create the organization and register your account.') }}+ {{ _("Click the button below to create the organization and register your account. You'll be able to update the information above if you like.") }}{% else %}- {{ _('Click the button below to complete registration.') }}+ {{ _("Click the button below to complete registration.") }}{% endif %}- <a class="button" href="{{ activate_url }}">{{ _('Complete registration') }}</a>+ <a class="button" href="{{ activate_url }}">{{ _("Complete registration") }}</a></p><p>{% if corporate_enabled %}diff --git a/templates/zerver/emails/confirm_registration.txt b/templates/zerver/emails/confirm_registration.txtindex 02d75bb3ffd..eb5ea41a98d 100644--- a/templates/zerver/emails/confirm_registration.txt+++ b/templates/zerver/emails/confirm_registration.txt@@ -1,13 +1,17 @@{% if create_realm %}-{{ _('You have requested a new Zulip organization. Awesome!') }}+{{ _("You have requested a new Zulip organization:") }}+* {% trans %}Organization URL: {{ organization_url }}{% endtrans %}++* {% trans %}Organization type: {{ organization_type }}{% endtrans %}{% else %}-{{ _('You recently signed up for Zulip. Awesome!') }}+{{ _("You recently signed up for Zulip. Awesome!") }}{% endif %}+{% if create_realm %}-{{ _('Click the link below to create the organization and register your account.') }}+{{ _("Click the button below to create the organization and register your account. You'll be able to update the information above if you like.") }}{% else %}-{{ _('Click the link below to complete registration.') }}+{{ _("Click the link below to complete registration.") }}{% endif %}<{{ activate_url }}>diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 94339fd28fa..857017b23a8 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -1406,7 +1406,9 @@ class RealmCreationTest(ZulipTestCase):self.assert_in_response("check your email", result)# Visit the confirmation link.- confirmation_url = self.get_confirmation_url_from_outbox(email)+ confirmation_url = self.get_confirmation_url_from_outbox(+ email, email_body_contains="Organization URL"+ )result = self.client_get(confirmation_url)self.assertEqual(result.status_code, 200)@@ -1779,7 +1781,9 @@ class RealmCreationTest(ZulipTestCase):result = self.client_get(result["Location"])self.assert_in_response("check your email", result)- confirmation_url = self.get_confirmation_url_from_outbox(email)+ confirmation_url = self.get_confirmation_url_from_outbox(+ email, email_body_contains="Organization URL"+ )result = self.client_get(confirmation_url)self.assertEqual(result.status_code, 200)@@ -1832,7 +1836,9 @@ class RealmCreationTest(ZulipTestCase):)result = self.client_get(result["Location"])self.assert_in_response("check your email", result)- first_confirmation_url = self.get_confirmation_url_from_outbox(email)+ first_confirmation_url = self.get_confirmation_url_from_outbox(+ email, email_body_contains="Organization URL"+ )self.assertEqual(PreregistrationRealm.objects.filter(email=email, status=0).count(), 1)result = self.submit_realm_creation_form(@@ -1846,7 +1852,9 @@ class RealmCreationTest(ZulipTestCase):)result = self.client_get(result["Location"])self.assert_in_response("check your email", result)- second_confirmation_url = self.get_confirmation_url_from_outbox(email)+ second_confirmation_url = self.get_confirmation_url_from_outbox(+ email, email_body_contains="Organization URL"+ )self.assertNotEqual(first_confirmation_url, second_confirmation_url)self.assertEqual(PreregistrationRealm.objects.filter(email=email, status=0).count(), 2)@@ -2119,7 +2127,9 @@ class UserSignUpTest(ZulipTestCase):self.assert_in_response("check your email", result)# Visit the confirmation link.- confirmation_url = self.get_confirmation_url_from_outbox(email)+ confirmation_url = self.get_confirmation_url_from_outbox(+ email, email_body_contains="You recently signed up for Zulip. Awesome!"+ )result = self.client_get(confirmation_url, **client_kwargs)self.assertEqual(result.status_code, 200)diff --git a/zerver/views/registration.py b/zerver/views/registration.pyindex 75a35b7e053..02594b7f297 100644--- a/zerver/views/registration.py+++ b/zerver/views/registration.py@@ -767,8 +767,17 @@ def send_confirm_registration_email(activation_url: str,*,realm: Optional[Realm] = None,+ realm_subdomain: Optional[str] = None,+ realm_type: Optional[int] = None,request: Optional[HttpRequest] = None,) -> None:+ org_url = ""+ org_type = ""+ if realm is None:+ assert realm_subdomain is not None+ org_url = f"{realm_subdomain}.{settings.EXTERNAL_HOST}"+ assert realm_type is not None+ org_type = get_org_type_display_name(realm_type)send_email("zerver/emails/confirm_registration",to_emails=[email],@@ -778,6 +787,8 @@ def send_confirm_registration_email("create_realm": realm is None,"activate_url": activation_url,"corporate_enabled": settings.CORPORATE_ENABLED,+ "organization_url": org_url,+ "organization_type": org_type,},realm=realm,request=request,@@ -845,7 +856,13 @@ def create_realm(request: HttpRequest, creation_key: Optional[str] = None) -> Htreturn HttpResponseRedirect(activation_url)try:- send_confirm_registration_email(email, activation_url, request=request)+ send_confirm_registration_email(+ email,+ activation_url,+ realm_subdomain=realm_subdomain,+ realm_type=realm_type,+ request=request,+ )except EmailNotDeliveredError:logging.exception("Failed to deliver email during realm creation")if settings.CORPORATE_ENABLED: