emails: Make it obvious when registering creates new realm.

Checked the email looked OK in `/emails` for both creating realm and
registering within an existing one.

Not sure zerver/tests/test_i18n.py test has been suppressed correctly.

Fixes #17786.
This commit is contained in:
Gilbert Bishop-White
2021-05-26 18:40:12 +01:00
committed by Tim Abbott
parent bf179b7d2f
commit e4d9e58c7d
6 changed files with 41 additions and 4 deletions

View File

@@ -6,10 +6,18 @@
{% block content %}
<p>
{% if create_realm %}
{{ _('You have requested a new Zulip organization. Awesome!') }}
{% else %}
{{ _('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.') }}
{% else %}
{{ _('Click the button below to complete registration.') }}
{% endif %}
<a class="button" href="{{ activate_url }}">{{ _('Complete registration') }}</a>
</p>
<p>{% trans support_email=macros.email_tag(support_email) %}Contact us any time at {{ support_email }} if you run into trouble, have any feedback, or just want to chat!{% endtrans %}</p>

View File

@@ -1 +1,5 @@
{% if create_realm %}
{{ _("Create your Zulip organization") }}
{% else %}
{{ _("Activate your Zulip account") }}
{% endif %}

View File

@@ -1,6 +1,14 @@
{% if create_realm %}
{{ _('You have requested a new Zulip organization. Awesome!') }}
{% else %}
{{ _('You recently signed up for Zulip. Awesome!') }}
{% endif %}
{{ _('Click the link below to complete registration.') }}
{% if create_realm %}
{{ _('Click the button below to create the organization and register your account.') }}
{% else %}
{{ _('Click the button below to complete registration.') }}
{% endif %}
<{{ activate_url }}>
{% trans %}Contact us any time at {{ support_email }} if you run into trouble,have any feedback, or just want to chat!{% endtrans %}

View File

@@ -649,6 +649,8 @@ Output:
email_address: str,
*,
url_pattern: Optional[str] = None,
email_subject_contains: Optional[str] = None,
email_body_contains: Optional[str] = None,
) -> str:
from django.core.mail import outbox
@@ -661,6 +663,13 @@ Output:
):
match = re.search(url_pattern, message.body)
assert match is not None
if email_subject_contains:
self.assertIn(email_subject_contains, message.subject)
if email_body_contains:
self.assertIn(email_body_contains, message.body)
[confirmation_url] = match.groups()
return confirmation_url
else:

View File

@@ -2769,8 +2769,13 @@ class RealmCreationTest(ZulipTestCase):
result = self.client_get(result["Location"])
self.assert_in_response("Check your email so we can get started.", result)
# Visit the confirmation link.
confirmation_url = self.get_confirmation_url_from_outbox(email)
# Check confirmation email has the correct subject and body, extract
# confirmation link and visit it
confirmation_url = self.get_confirmation_url_from_outbox(
email,
email_subject_contains="Create your Zulip organization",
email_body_contains="You have requested a new Zulip organization",
)
result = self.client_get(confirmation_url)
self.assertEqual(result.status_code, 200)

View File

@@ -534,7 +534,10 @@ def send_confirm_registration_email(
to_emails=[email],
from_address=FromAddress.tokenized_no_reply_address(),
language=language,
context={"activate_url": activation_url},
context={
"create_realm": (realm is None),
"activate_url": activation_url,
},
realm=realm,
)