emails: Add html versions of emails that do not have them.

Fixes #4691.
This commit is contained in:
Aditya Ramesh 2017-05-14 18:32:49 +05:30 committed by Tim Abbott
parent f8bab945d8
commit a77aa79da9
4 changed files with 33 additions and 6 deletions

View File

@ -0,0 +1,12 @@
{% extends "zerver/emails/email_base.html" %}
{% block content %}
<p>Hi,</p>
<p>
We just wanted to let you know that the email associated with your Zulip account was recently changed to <a href="{{ new_email }}" style="color:#08c">{{ new_email }}</a>. If you did not request this change, please contact us immediately at <a href="mailto:{{ support_email }}" style="color:#08c">{{ support_email }}</a>.
</p>
<p>
Best,<br />
The Zulip Team
</p>
{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends "zerver/emails/email_base.html" %}
{% block content %}
<p>
{% if attempted_realm %}
Someone (possibly you) requested a password reset email for {{ email }} on {{ attempted_realm.uri }}, but {{ email }} does not have an active account in {{ attempted_realm.uri }}. However, {{ email }} does have an active account in {{ user.realm.uri }} organization; you can try logging in or resetting your password there.
{% else %}
Psst. Word on the street is that you forgot your password, {{ email }}.<br />
It's all good. Follow the link below and we'll take care of the rest:<br />
{{ protocol }}://{{ user.realm.host }}{{ url('django.contrib.auth.views.password_reset_confirm', kwargs=dict(uidb64=uid, token=token)) }}
{% endif %}
</p>
<p>
Thanks,<br />
Your friends at Zulip HQ
</p>
{% endblock %}

View File

@ -1,6 +1,6 @@
from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.template import loader, TemplateDoesNotExist
from django.template import loader
from django.utils.timezone import now as timezone_now
from zerver.models import UserProfile, ScheduledJob
@ -27,11 +27,7 @@ def build_email(template_prefix, to_email, from_email=None, reply_to_email=None,
context=context, using='Jinja2_plaintext').strip()
message = loader.render_to_string(template_prefix + '.txt',
context=context, using='Jinja2_plaintext')
# Remove try/expect once https://github.com/zulip/zulip/issues/4691 is resolved.
try:
html_message = loader.render_to_string(template_prefix + '.html', context)
except TemplateDoesNotExist:
html_message = None
html_message = loader.render_to_string(template_prefix + '.html', context)
if from_email is None:
from_email = settings.NOREPLY_EMAIL_ADDRESS
reply_to = None

View File

@ -90,6 +90,7 @@ class TemplateTestCase(ZulipTestCase):
'zerver/emails/confirm_new_email.html',
'zerver/emails/confirm_new_email.txt',
'zerver/emails/notify_change_in_email.subject',
'zerver/emails/notify_change_in_email.html',
'zerver/emails/digest.subject',
'zerver/emails/digest.html',
'zerver/emails/digest.txt',
@ -99,6 +100,7 @@ class TemplateTestCase(ZulipTestCase):
'zerver/emails/followup_day2.subject',
'zerver/emails/followup_day2.txt',
'zerver/emails/followup_day2.html',
'zerver/emails/password_reset.html',
'corporate/mit.html',
'corporate/zephyr.html',
'corporate/zephyr-mirror.html',