Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
upgrade: Control automatic / manual license management via URL.
Aman Agrawal2570f7ce23e7
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex 9f64a061e73..019510d14be 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -685,7 +685,7 @@ class StripeTest(StripeTestCase):user = self.example_user("hamlet")self.login_user(user)response = self.client_get("/upgrade/")- self.assert_in_success_response(["Pay annually"], response)+ self.assert_in_success_response(["Your subscription will renew automatically"], response)self.assertNotEqual(user.realm.plan_type, Realm.PLAN_TYPE_STANDARD)self.assertFalse(Customer.objects.filter(realm=user.realm).exists())@@ -996,7 +996,9 @@ class StripeTest(StripeTestCase):response = self.client_get("/upgrade/")free_trial_end_date = self.now + timedelta(days=60)- self.assert_in_success_response(["Pay annually", "Free Trial", "60 day"], response)+ self.assert_in_success_response(+ ["You won't be charged", "Free Trial", "60 day"], response+ )self.assertNotEqual(user.realm.plan_type, Realm.PLAN_TYPE_STANDARD)self.assertFalse(Customer.objects.filter(realm=user.realm).exists())@@ -1280,7 +1282,9 @@ class StripeTest(StripeTestCase):with self.settings(FREE_TRIAL_DAYS=60):response = self.client_get("/upgrade/")- self.assert_in_success_response(["Pay annually", "Free Trial", "60 day"], response)+ self.assert_in_success_response(+ ["You won't be charged", "Free Trial", "60 day"], response+ )self.assertNotEqual(user.realm.plan_type, Realm.PLAN_TYPE_STANDARD)self.assertFalse(Customer.objects.filter(realm=user.realm).exists())diff --git a/corporate/views/upgrade.py b/corporate/views/upgrade.pyindex efc784170d5..17079db6409 100644--- a/corporate/views/upgrade.py+++ b/corporate/views/upgrade.py@@ -173,7 +173,9 @@ def upgrade(@zulip_login_required@has_request_variablesdef initial_upgrade(- request: HttpRequest, onboarding: bool = REQ(default=False, json_validator=check_bool)+ request: HttpRequest,+ onboarding: bool = REQ(default=False, json_validator=check_bool),+ manual_license_management: bool = REQ(default=False, json_validator=check_bool),) -> HttpResponse:user = request.userassert user.is_authenticated@@ -223,6 +225,7 @@ def initial_upgrade("demo_organization_scheduled_deletion_date": user.realm.demo_organization_scheduled_deletion_date,},"is_demo_organization": user.realm.demo_organization_scheduled_deletion_date is not None,+ "manual_license_management": manual_license_management,}response = render(request, "corporate/upgrade.html", context=context)diff --git a/templates/corporate/upgrade.html b/templates/corporate/upgrade.htmlindex 8db24872d7e..43138ae1171 100644--- a/templates/corporate/upgrade.html+++ b/templates/corporate/upgrade.html@@ -18,7 +18,7 @@<div class="page-content"><div class="main">- <h1>🚀 {% trans %}Upgrade to {{ plan }}{% endtrans %}</h1>+ <h1>Upgrade {{ realm.name }} to {{ plan }}</h1>{% if free_trial_days %}<div id="free-trial-alert-message" class="alert alert-info">Upgrade now to start your {{ free_trial_days }} day free trial@@ -89,24 +89,7 @@</label></div>- <div class="license-management">- <h3>{{ _("License management") }}</h3>- <label>- <input type="radio" name="license_management" value="automatic" checked />- <div class="box">- <div class="management-type">{{ _("Automatic") }}</div>- <div class="management-type-text">{{ _("Most convenient") }}</div>- </div>- </label>- <label>- <input type="radio" name="license_management" value="manual" />- <div class="box">- <div class="management-type">{{ _("Manual") }}</div>- <div class="management-type-text">{{ _("Most control") }}</div>- </div>- </label>- </div>-+ {% if not manual_license_management %}<div id="license-automatic-section"><p>{% if free_trial_days %}@@ -118,34 +101,32 @@are added, and remove licenses not in use at the end of each billingperiod.{% else %}- You’ll initially be charged- <b>$<span id="charged_amount"></span></b> for <b>{{ seat_count }}</b>- users.<br />- We'll automatically charge you for additional licenses as users- are added, and remove licenses not in use at the end of each billing- period.+ Your subscription will renew automatically. Your bill will vary based on the number+ of active users in your organization. You can also+ <a href="/upgrade/?manual_license_management=true">purchase a fixed number of licenses</a> instead. See+ <a target="_blank" href="https://zulip.com/help/zulip-cloud-billing">here</a> for details.{% endif %}</p><input type="hidden" name="licenses" id="automatic_license_count" value="{{ seat_count }}" /></div>-+ {% else %}<div id="license-manual-section">-<p>{% if free_trial_days %}Enter the number of users you would like to pay for after the Free Trial.<br />You'll need to manually add licenses to add or inviteadditional users.{% else %}- Enter the number of users you would like to pay for.<br />- You'll need to manually add licenses to add or invite- additional users.+ Your subscription will renew automatically. You will be able to manage the number of licenses on+ your organization's billing page. You can also+ <a href="/upgrade/">choose automatic license management</a> instead. See+ <a href="https://zulip.com/help/zulip-cloud-billing">here</a> for details.{% endif %}</p>-<h4>Number of licenses {% if not exempt_from_license_number_check %}(minimum {{ seat_count }}){% endif %}</h4><input type="number" name="licenses" {% if not exempt_from_license_number_check %}min="{{ seat_count }}"{% endif %} autocomplete="off" id="manual_license_count" required/><br /></div>+ {% endif %}<!-- Disabled buttons do not fire any events, so we need a container div that isn't disabled for tippyjs to work --><div class="upgrade-button-container" {% if is_demo_organization %}data-tippy-content="{% trans %}Convert demo organization before upgrading.{% endtrans %}"{% endif %}><button id="add-card-button" class="stripe-button-el invoice-button" {% if is_demo_organization %}disabled{% endif %}>@@ -235,9 +216,7 @@</div><div class="support-link"><p>- We're happy to help!- Contact <a href="mailto:[email protected]">[email protected]</a>- for any billing-related questions.+ To pay by invoice or for any other questions, contact <a href="mailto:[email protected]">[email protected]</a>.</p></div></div>diff --git a/web/src/billing/helpers.ts b/web/src/billing/helpers.tsindex 0194ce7eee9..c83a5f5e7da 100644--- a/web/src/billing/helpers.ts+++ b/web/src/billing/helpers.ts@@ -139,19 +139,6 @@ export function update_discount_details(organization_type: string): void {$("#sponsorship-discount-details").text(discount_notice);}-export function show_license_section(license: string): void {- $("#license-automatic-section").hide();- $("#license-manual-section").hide();-- $("#automatic_license_count").prop("disabled", true);- $("#manual_license_count").prop("disabled", true);-- const section_id = `#license-${CSS.escape(license)}-section`;- $(section_id).show();- const input_id = `#${CSS.escape(license)}_license_count`;- $(input_id).prop("disabled", false);-}-let current_page: string;function handle_hashchange(): void {diff --git a/web/src/billing/upgrade.ts b/web/src/billing/upgrade.tsindex 1106d4e4a58..7c026561be7 100644--- a/web/src/billing/upgrade.ts+++ b/web/src/billing/upgrade.ts@@ -36,10 +36,6 @@ export const initialize = (): void => {monthly: page_params.monthly_price * (1 - page_params.percent_off / 100),};- $<HTMLInputElement>("input[type=radio][name=license_management]").on("change", function () {- helpers.show_license_section(this.value);- });-$<HTMLInputElement>("input[type=radio][name=schedule]").on("change", function () {helpers.update_charged_amount(prices, helpers.schedule_schema.parse(this.value));});@@ -50,9 +46,6 @@ export const initialize = (): void => {$("#invoice_annual_price").text(helpers.format_money(prices.annual));$("#invoice_annual_price_per_month").text(helpers.format_money(prices.annual / 12));- helpers.show_license_section(- $<HTMLInputElement>("input[type=radio][name=license_management]:checked").val()!,- );helpers.update_charged_amount(prices,helpers.schedule_schema.parse(diff --git a/web/styles/portico/billing.css b/web/styles/portico/billing.cssindex cca641646cf..a504c4609fc 100644--- a/web/styles/portico/billing.css+++ b/web/styles/portico/billing.css@@ -306,11 +306,6 @@margin-left: -25px;}- #license-automatic-section,- #license-manual-section {- display: none;- }-& select,input,textarea {