emails: Move support_email into a common context.

This commit is contained in:
Rishi Gupta 2017-06-10 01:25:44 -07:00
parent 056489c247
commit 15b967fc3e
8 changed files with 4 additions and 13 deletions

View File

@ -33,7 +33,6 @@ def confirm(request, confirmation_key):
'days': getattr(settings, 'EMAIL_CONFIRMATION_DAYS', 10), 'days': getattr(settings, 'EMAIL_CONFIRMATION_DAYS', 10),
'key': confirmation_key, 'key': confirmation_key,
'full_name': request.GET.get("full_name", None), 'full_name': request.GET.get("full_name", None),
'support_email': settings.ZULIP_ADMINISTRATOR,
} }
templates = [ templates = [
'confirmation/confirm.html', 'confirmation/confirm.html',

View File

@ -631,8 +631,7 @@ def do_start_email_change_process(user_profile, new_email):
old_email = user_profile.email old_email = user_profile.email
user_profile.email = new_email user_profile.email = new_email
context = {'support_email': settings.ZULIP_ADMINISTRATOR, context = {'realm': user_profile.realm,
'realm': user_profile.realm,
'old_email': old_email, 'old_email': old_email,
'new_email': new_email, 'new_email': new_email,
} }
@ -3053,8 +3052,7 @@ def do_send_confirmation_email(invitee, referrer, body):
`invitee` is a PreregistrationUser. `invitee` is a PreregistrationUser.
`referrer` is a UserProfile. `referrer` is a UserProfile.
""" """
context = {'referrer': referrer, context = {'referrer': referrer}
'support_email': settings.ZULIP_ADMINISTRATOR}
if referrer.realm.is_zephyr_mirror_realm: if referrer.realm.is_zephyr_mirror_realm:
template_prefix = 'zerver/emails/invitation_mit' template_prefix = 'zerver/emails/invitation_mit'

View File

@ -20,6 +20,7 @@ def display_email(user):
def build_email(template_prefix, to_email, from_email=None, reply_to_email=None, context={}): def build_email(template_prefix, to_email, from_email=None, reply_to_email=None, context={}):
# type: (str, Text, Optional[Text], Optional[Text], Dict[str, Any]) -> EmailMultiAlternatives # type: (str, Text, Optional[Text], Optional[Text], Dict[str, Any]) -> EmailMultiAlternatives
context.update({ context.update({
'support_email': settings.ZULIP_ADMINISTRATOR,
'verbose_support_offers': settings.VERBOSE_SUPPORT_OFFERS, 'verbose_support_offers': settings.VERBOSE_SUPPORT_OFFERS,
}) })
subject = loader.render_to_string(template_prefix + '.subject', subject = loader.render_to_string(template_prefix + '.subject',

View File

@ -739,7 +739,6 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
'referrer_name': referrer.full_name, 'referrer_name': referrer.full_name,
'referrer_email': referrer.email, 'referrer_email': referrer.email,
'referrer_realm_name': referrer.realm.name, 'referrer_realm_name': referrer.realm.name,
'support_email': settings.ZULIP_ADMINISTRATOR
}) })
with self.settings(EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend'): with self.settings(EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend'):
send_future_email( send_future_email(

View File

@ -308,9 +308,7 @@ def send_registration_completion_email(email, request, realm_creation=False):
template_prefix = 'zerver/emails/confirm_registration_mit' template_prefix = 'zerver/emails/confirm_registration_mit'
prereg_user = create_preregistration_user(email, request, realm_creation) prereg_user = create_preregistration_user(email, request, realm_creation)
context = {'support_email': settings.ZULIP_ADMINISTRATOR}
return Confirmation.objects.send_confirmation(prereg_user, template_prefix, email, return Confirmation.objects.send_confirmation(prereg_user, template_prefix, email,
additional_context=context,
host=request.get_host()) host=request.get_host())
def redirect_to_email_login_url(email): def redirect_to_email_login_url(email):

View File

@ -53,7 +53,6 @@ def email_page(request):
'old_email': 'old_address@acme.com', 'old_email': 'old_address@acme.com',
'new_email': 'new_address@acme.com', 'new_email': 'new_address@acme.com',
'activate_url': '%s/accounts/do_confirm/5348720e4af7d2e8f296cbbd04d439489917ddc0' % (settings.SERVER_URI,), 'activate_url': '%s/accounts/do_confirm/5348720e4af7d2e8f296cbbd04d439489917ddc0' % (settings.SERVER_URI,),
'support_email': 'support@' + settings.EXTERNAL_HOST,
'zulip_support': 'support@' + settings.EXTERNAL_HOST, 'zulip_support': 'support@' + settings.EXTERNAL_HOST,
'unsubscribe_link': '%s/accounts/unsubscribe/<type>/cf88931365ef1b0f12eae8d488bbc7af3563d7f0' % (settings.SERVER_URI,), 'unsubscribe_link': '%s/accounts/unsubscribe/<type>/cf88931365ef1b0f12eae8d488bbc7af3563d7f0' % (settings.SERVER_URI,),
} }

View File

@ -48,8 +48,7 @@ def confirm_email_change(request, confirmation_key):
do_change_user_email(obj.user_profile, obj.new_email) do_change_user_email(obj.user_profile, obj.new_email)
context = {'support_email': settings.ZULIP_ADMINISTRATOR, context = {'realm': obj.realm,
'realm': obj.realm,
'new_email': new_email, 'new_email': new_email,
} }
send_email('zerver/emails/notify_change_in_email', old_email, send_email('zerver/emails/notify_change_in_email', old_email,
@ -57,7 +56,6 @@ def confirm_email_change(request, confirmation_key):
ctx = { ctx = {
'confirmed': confirmed, 'confirmed': confirmed,
'support_email': settings.ZULIP_ADMINISTRATOR,
'new_email': new_email, 'new_email': new_email,
'old_email': old_email, 'old_email': old_email,
} }

View File

@ -174,7 +174,6 @@ class ConfirmationEmailWorker(QueueProcessingWorker):
'referrer_name': referrer.full_name, 'referrer_name': referrer.full_name,
'referrer_email': referrer.email, 'referrer_email': referrer.email,
'referrer_realm_name': referrer.realm.name, 'referrer_realm_name': referrer.realm.name,
'support_email': settings.ZULIP_ADMINISTRATOR
}) })
send_future_email( send_future_email(
"zerver/emails/invitation_reminder", "zerver/emails/invitation_reminder",