From 5925ce16b1fc4d92576b9f6d56d359d9b8ef2bc4 Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Mon, 27 Dec 2021 15:25:38 -0500 Subject: [PATCH] demo-orgs: Disable billing and upgrade for demo organizations. Disables submit buttons on billing / upgrade page for demo organizations since they will need to become permanent organizations before upgrading to Zulip Cloud Standard. Also creates an alert banner on the same page that links to the help center article on demo organizations. Updates sub-headers on demo organizations help center article to match link text and to follow general convention of using imperative verb forms in help center subheaders. Part of #19523. Co-authored by: Lauryn Menard --- corporate/tests/test_stripe.py | 9 ++++++ corporate/views/upgrade.py | 2 ++ static/styles/portico/billing.css | 13 ++++++++ static/styles/portico/portico_signin.css | 27 ++++++++++++++++ templates/corporate/upgrade.html | 36 +++++++++++++++++---- templates/zerver/help/demo-organizations.md | 4 +-- 6 files changed, 83 insertions(+), 8 deletions(-) diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index 8095f43b72..cff986ef81 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -2329,6 +2329,15 @@ class StripeTest(StripeTestCase): self.assertEqual(response.status_code, 302) self.assertEqual("/upgrade/", response["Location"]) + def test_upgrade_page_for_demo_organizations(self) -> None: + user = self.example_user("iago") + user.realm.demo_organization_scheduled_deletion_date = timezone_now() + timedelta(days=30) + user.realm.save() + self.login_user(user) + + response = self.client_get("/billing/", follow=True) + self.assert_in_success_response(["cannot be upgraded"], response) + def test_redirect_for_upgrade_page(self) -> None: user = self.example_user("iago") self.login_user(user) diff --git a/corporate/views/upgrade.py b/corporate/views/upgrade.py index f5ee4028e2..c7dd058166 100644 --- a/corporate/views/upgrade.py +++ b/corporate/views/upgrade.py @@ -276,6 +276,7 @@ def initial_upgrade( "annual_price": 8000, "monthly_price": 800, "percent_off": float(percent_off), + "demo_organization_scheduled_deletion_date": user.realm.demo_organization_scheduled_deletion_date, }, "realm_org_type": user.realm.org_type, "sorted_org_types": sorted( @@ -286,6 +287,7 @@ def initial_upgrade( ), key=lambda d: d[1]["display_order"], ), + "is_demo_organization": user.realm.demo_organization_scheduled_deletion_date is not None, } response = render(request, "corporate/upgrade.html", context=context) return response diff --git a/static/styles/portico/billing.css b/static/styles/portico/billing.css index 0718ba3f05..b47f78ef03 100644 --- a/static/styles/portico/billing.css +++ b/static/styles/portico/billing.css @@ -177,6 +177,19 @@ .invoice-button { font-size: 19px; + + &:disabled { + opacity: 0.5; + cursor: not-allowed; + + &:hover { + pointer-events: all; + } + } + } + + .upgrade-button-container { + display: inline-block; } #manual_license_count, diff --git a/static/styles/portico/portico_signin.css b/static/styles/portico/portico_signin.css index 14d1bf948d..69b7c45c69 100644 --- a/static/styles/portico/portico_signin.css +++ b/static/styles/portico/portico_signin.css @@ -401,6 +401,33 @@ html { font-weight: 400; } + .demo-organization-warning { + position: relative; + display: block; + background-color: hsl(360, 100%, 93%); + border: 1px solid hsl(0, 0%, 80%); + border-radius: 4px; + padding: 10px; + margin: 10px 0; + font-size: 1rem; + font-weight: 500; + line-height: 1.5; + color: hsl(0, 0%, 27%); + + a { + text-decoration: none; + } + + &::before { + display: inline; + margin-right: 8px; + + font-family: FontAwesome; + font-weight: 600; + content: "\f071"; + } + } + .alert { &:not(.alert-info) { padding: 0; diff --git a/templates/corporate/upgrade.html b/templates/corporate/upgrade.html index c10a658ed9..e7131ca29c 100644 --- a/templates/corporate/upgrade.html +++ b/templates/corporate/upgrade.html @@ -24,6 +24,16 @@ {% endif %} + {% if is_demo_organization %} +
+ Demo organizations cannot be directly upgraded to a paid plan. Please start by + + converting your demo organization + + to a permanent organization. +
+ {% endif %} + {% if error_message %}
{{ error_message }} @@ -140,10 +150,14 @@

Number of licenses (minimum {{ seat_count }})


- - + +
+ +
@@ -201,7 +215,12 @@

Number of licenses (minimum {{ min_invoiced_licenses }})


- + +
+ +
@@ -247,7 +266,12 @@

- + +
+ +
diff --git a/templates/zerver/help/demo-organizations.md b/templates/zerver/help/demo-organizations.md index 70bfc30c8b..c878d4cc73 100644 --- a/templates/zerver/help/demo-organizations.md +++ b/templates/zerver/help/demo-organizations.md @@ -25,7 +25,7 @@ Other than those limitations, they work exactly like a normal Zulip organization; you can invite additional users, connect the mobile apps, etc. -## Creating demo organizations +## Create a demo organization {start_tabs} @@ -39,7 +39,7 @@ apps, etc. {end_tabs} -## Converting a demo organization to a regular organization +## Convert a demo organization to a permanent organization {start_tabs}