Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
corporate: Send email community plan sponsorship approved.
Lauryn Menardc94c194ea783
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex 3ba783cf441..37271e073ad 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -58,6 +58,7 @@ from zerver.models import (from zilencer.models import (RemoteRealm,RemoteRealmAuditLog,+ RemoteRealmBillingUser,RemoteZulipServer,RemoteZulipServerAuditLog,)@@ -2873,9 +2874,28 @@ class RemoteRealmBillingSession(BillingSession): # nocoverageself.write_to_audit_log(event_type=AuditLogEventType.SPONSORSHIP_APPROVED, event_time=timezone_now())- # TODO: Add something (probably email) to let remote realm- # organization know that the sponsorship request was approved.- return f"Sponsorship approved for {self.billing_entity_display_name}"+ emailed_string = ""+ billing_emails = list(+ RemoteRealmBillingUser.objects.filter(remote_realm_id=self.remote_realm.id).values_list(+ "email", flat=True+ )+ )+ if len(billing_emails) > 0:+ send_email(+ "zerver/emails/sponsorship_approved_community_plan",+ to_emails=billing_emails,+ from_address="[email protected]",+ context={+ "billing_entity": self.billing_entity_display_name,+ "plans_link": "https://zulip.com/plans/#self-hosted",+ "link_to_zulip": "https://zulip.com/help/linking-to-zulip-website",+ },+ )+ emailed_string = "Emailed existing billing users."+ else:+ emailed_string = "No billing users exist to email."++ return f"Sponsorship approved for {self.billing_entity_display_name}; " + emailed_string@overridedef is_sponsored(self) -> bool:@@ -3162,8 +3182,17 @@ class RemoteServerBillingSession(BillingSession): # nocoverageself.write_to_audit_log(event_type=AuditLogEventType.SPONSORSHIP_APPROVED, event_time=timezone_now())- # TODO: Add something (probably email) to let remote server- # organization know that the sponsorship request was approved.+ # TODO: Use the emails in RemoteZulipServerBillingUser for this email.+ send_email(+ "zerver/emails/sponsorship_approved_community_plan",+ to_emails=[self.remote_server.contact_email],+ from_address="[email protected]",+ context={+ "billing_entity": self.billing_entity_display_name,+ "plans_link": "https://zulip.com/plans/#self-hosted",+ "link_to_zulip": "https://zulip.com/help/linking-to-zulip-website",+ },+ )return f"Sponsorship approved for {self.billing_entity_display_name}"@overridediff --git a/templates/zerver/emails/sponsorship_approved_community_plan.html b/templates/zerver/emails/sponsorship_approved_community_plan.htmlnew file mode 100644index 00000000000..d4ea320a33a--- /dev/null+++ b/templates/zerver/emails/sponsorship_approved_community_plan.html@@ -0,0 +1,15 @@+{% extends "zerver/emails/email_base_default.html" %}++{% block illustration %}+<img src="{{ email_images_base_url }}/email_logo.png" alt=""/>+{% endblock %}++{% block content %}+<p>+ {% trans %}Your request for Zulip sponsorship has been approved! Your organization has been upgraded to the <a href="{{ plans_link }}">Zulip Community plan</a>.{% endtrans %}+</p>+<p>+ {% trans %}If you could <a href="{{ link_to_zulip }}">list Zulip as a sponsor on your website</a>, we would really appreciate it!{% endtrans %}+</p>++{% endblock %}diff --git a/templates/zerver/emails/sponsorship_approved_community_plan.subject.txt b/templates/zerver/emails/sponsorship_approved_community_plan.subject.txtnew file mode 100644index 00000000000..13f02282ded--- /dev/null+++ b/templates/zerver/emails/sponsorship_approved_community_plan.subject.txt@@ -0,0 +1 @@+{% trans %}Community plan sponsorship approved for {{ billing_entity }}!{% endtrans %}diff --git a/templates/zerver/emails/sponsorship_approved_community_plan.txt b/templates/zerver/emails/sponsorship_approved_community_plan.txtnew file mode 100644index 00000000000..9946abcfb46--- /dev/null+++ b/templates/zerver/emails/sponsorship_approved_community_plan.txt@@ -0,0 +1,5 @@+{{ _("Your request for Zulip sponsorship has been approved! Your organization has been upgraded to the Zulip Community plan.") }}+{{ plans_link }}++{{ _("If you could list Zulip as a sponsor on your website, we would really appreciate it!.") }}+{{ link_to_zulip }}