emails: Add corporate_enabled to context for emails.

In commit fc58c35c0, we added a check in various emails for the
settings.CORPORATE_ENABLED value, but that context is only always
included for views/templates with a request.

Here we add that to common_context, which is often used when there
is not a request (like with emails). And we manually add it to the
email context in various cases when there is not a user account to
call with common_context: new user invitations, registration emails,
and realm reactivation emails.
This commit is contained in:
Lauryn Menard 2023-05-01 12:47:38 +02:00 committed by Tim Abbott
parent 663170f0d3
commit 06dd7a3a68
4 changed files with 9 additions and 1 deletions

View File

@ -59,6 +59,7 @@ def do_send_confirmation_email(
"referrer_email": referrer.delivery_email,
"activate_url": activation_url,
"referrer_realm_name": referrer.realm.name,
"corporate_enabled": settings.CORPORATE_ENABLED,
}
send_email(
"zerver/emails/invitation",

View File

@ -481,7 +481,12 @@ def do_send_realm_reactivation_email(realm: Realm, *, acting_user: Optional[User
event_type=RealmAuditLog.REALM_REACTIVATION_EMAIL_SENT,
event_time=timezone_now(),
)
context = {"confirmation_url": url, "realm_uri": realm.uri, "realm_name": realm.name}
context = {
"confirmation_url": url,
"realm_uri": realm.uri,
"realm_name": realm.name,
"corporate_enabled": settings.CORPORATE_ENABLED,
}
language = realm.default_language
send_email_to_admins(
"zerver/emails/realm_reactivation",

View File

@ -47,6 +47,7 @@ def common_context(user: UserProfile) -> Dict[str, Any]:
"external_url_scheme": settings.EXTERNAL_URI_SCHEME,
"external_host": settings.EXTERNAL_HOST,
"user_name": user.full_name,
"corporate_enabled": settings.CORPORATE_ENABLED,
}

View File

@ -692,6 +692,7 @@ def send_confirm_registration_email(
context={
"create_realm": (realm is None),
"activate_url": activation_url,
"corporate_enabled": settings.CORPORATE_ENABLED,
},
realm=realm,
request=request,