Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
demo-orgs: Disable corporate upgrade and sponsorship pages.
Lauryn Menard4d1bfe6537e7
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex d758d4e4665..27d9dd49843 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -643,7 +643,6 @@ class UpgradePageParams(TypedDict):class UpgradePageSessionTypeSpecificContext(TypedDict):customer_name: stremail: str- is_demo_organization: boolis_self_hosting: bool@@ -666,7 +665,6 @@ class UpgradePageContext(TypedDict):stripe_email: strexempt_from_license_number_check: boolfree_trial_end_date: str | None- is_demo_organization: boolmanual_license_management: boolusing_min_licenses_for_plan: boolmin_licenses_for_plan: int@@ -2823,7 +2821,6 @@ class BillingSession(ABC):"stripe_email": stripe_email,"exempt_from_license_number_check": exempt_from_license_number_check,"free_trial_end_date": free_trial_end_date,- "is_demo_organization": customer_specific_context["is_demo_organization"],"complimentary_access_plan_end_date": complimentary_access_plan_end_date,"manual_license_management": initial_upgrade_request.manual_license_management,"page_params": {@@ -4192,7 +4189,6 @@ class RealmBillingSession(BillingSession):return UpgradePageSessionTypeSpecificContext(customer_name=self.realm.name,email=self.get_email(),- is_demo_organization=self.realm.demo_organization_scheduled_deletion_date is not None,is_self_hosting=False,)@@ -4590,7 +4586,6 @@ class RemoteRealmBillingSession(BillingSession):return UpgradePageSessionTypeSpecificContext(customer_name=self.remote_realm.host,email=self.get_email(),- is_demo_organization=False,is_self_hosting=True,)@@ -5056,7 +5051,6 @@ class RemoteServerBillingSession(BillingSession):return UpgradePageSessionTypeSpecificContext(customer_name=self.remote_server.hostname,email=self.get_email(),- is_demo_organization=False,is_self_hosting=True,)diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex 7e5281b9a56..f4938562d8a 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -2845,7 +2845,20 @@ class StripeTest(StripeTestCase):self.login_user(user)response = self.client_get("/billing/", follow=True)- self.assert_in_success_response(["cannot be directly upgraded"], response)+ self.assert_in_success_response(+ ["Demo organizations cannot be directly upgraded to a paid plan."], response+ )++ def test_sponsorship_page_for_demo_organizations(self) -> None:+ user = self.example_user("hamlet")+ user.realm.demo_organization_scheduled_deletion_date = timezone_now() + timedelta(days=30)+ user.realm.save()+ self.login_user(user)++ response = self.client_get("/sponsorship/", follow=True)+ self.assert_in_success_response(+ ["Demo organizations cannot apply for sponsorship."], response+ )def test_redirect_for_upgrade_page(self) -> None:user = self.example_user("iago")diff --git a/corporate/views/sponsorship.py b/corporate/views/sponsorship.pyindex 6a5dee89c9c..86f49eb4cbb 100644--- a/corporate/views/sponsorship.py+++ b/corporate/views/sponsorship.py@@ -24,6 +24,14 @@ def sponsorship_page(request: HttpRequest) -> HttpResponse:assert user.is_authenticatedbilling_session = RealmBillingSession(user)+ if billing_session.realm.demo_organization_scheduled_deletion_date is not None:+ return render(+ request,+ "corporate/billing/demo_organization_billing_disabled.html",+ context={+ "sponsorship_request": True,+ },+ )context = billing_session.get_sponsorship_request_context()if context is None or not user.has_billing_access:return HttpResponseRedirect(reverse("billing_page"))diff --git a/corporate/views/upgrade.py b/corporate/views/upgrade.pyindex e3db7d22273..470ea58cf22 100644--- a/corporate/views/upgrade.py+++ b/corporate/views/upgrade.py@@ -203,8 +203,16 @@ def upgrade_page(billing_modality=billing_modality,)billing_session = RealmBillingSession(user)- redirect_url, context = billing_session.get_initial_upgrade_context(initial_upgrade_request)+ if billing_session.realm.demo_organization_scheduled_deletion_date is not None:+ return render(+ request,+ "corporate/billing/demo_organization_billing_disabled.html",+ context={+ "upgrade_request": True,+ },+ )+ redirect_url, context = billing_session.get_initial_upgrade_context(initial_upgrade_request)if redirect_url:return HttpResponseRedirect(redirect_url)diff --git a/templates/corporate/billing/demo_organization_billing_disabled.html b/templates/corporate/billing/demo_organization_billing_disabled.htmlnew file mode 100644index 00000000000..57cd466bd2a--- /dev/null+++ b/templates/corporate/billing/demo_organization_billing_disabled.html@@ -0,0 +1,31 @@+{% extends "zerver/portico.html" %}++{% block title %}+<title>Not available for demo organizations | Zulip</title>+{% endblock %}++{% block portico_content %}+<div class="app portico-page">+ <div class="app-main portico-page-container center-block flex full-page account-creation new-style">+ <div class="inline-block">+ <div class="get-started">+ <h1>Not available for demo organizations</h1>+ </div>+ <div class="white-box">+ <p>+ {% if upgrade_request %}+ Demo organizations cannot be directly upgraded to a paid plan.+ {% elif sponsorship_request %}+ Demo organizations cannot apply for sponsorship.+ {% endif %}+ Please start by+ <a href="/help/demo-organizations#convert-a-demo-organization-to-a-permanent-organization">+ converting your demo organization+ </a>+ to a permanent Zulip Cloud organization.+ </p>+ </div>+ </div>+ </div>+</div>+{% endblock %}diff --git a/templates/corporate/billing/sponsorship.html b/templates/corporate/billing/sponsorship.htmlindex 97d01cc067e..adf5583ca28 100644--- a/templates/corporate/billing/sponsorship.html+++ b/templates/corporate/billing/sponsorship.html@@ -172,9 +172,8 @@<textarea id="paid-users-description" name="paid_users_description" cols="100" rows="2"></textarea><div id="sponsorship-paid-users-description-error" class="alert alert-danger sponsorship-field-error"></div></div>- <!-- 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="Convert demo organization before upgrading."{% endif %}>- <button type="submit" id="sponsorship-button" class="stripe-button-el invoice-button" {% if is_demo_organization %}disabled{% endif %}>+ <div class="upgrade-button-container">+ <button type="submit" id="sponsorship-button" class="stripe-button-el invoice-button"><span class="sponsorship-button-text">Submit</span><object class="loader sponsorship-button-loader" type="image/svg+xml" data="{{ static('images/loading/loader-white.svg') }}"></object></button>diff --git a/templates/corporate/billing/upgrade.html b/templates/corporate/billing/upgrade.htmlindex d57932d168f..cdc1b54eec9 100644--- a/templates/corporate/billing/upgrade.html+++ b/templates/corporate/billing/upgrade.html@@ -84,16 +84,6 @@{% endif %}</div>{% endif %}-- {% if is_demo_organization %}- <div class="demo-organization-warning">- Demo organizations cannot be directly upgraded to a paid plan. Please start by- <a href="/help/demo-organizations#convert-a-demo-organization-to-a-permanent-organization">- converting your demo organization- </a>- to a permanent organization.- </div>- {% endif %}</div>{% if page_params.free_trial_days and not page_params.setup_payment_by_invoice %}@@ -236,7 +226,6 @@</div>{% endif %}- {% if not is_demo_organization %}<div {% if page_params.setup_payment_by_invoice %} id="update-invoice-billing-info" {% elif payment_method %} id="upgrade-payment-info"{% endif %}>{% if page_params.setup_payment_by_invoice %}{% elif payment_method %}@@ -281,10 +270,8 @@{% endif %}<div id="upgrade-cardchange-error" class="alert alert-danger upgrade-page-error"></div></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 input-box upgrade-page-field" {% if is_demo_organization %}data-tippy-content="{% trans %}Convert demo organization before upgrading.{% endtrans %}"{% endif %}>- <button id="org-upgrade-button{% if is_demo_organization %} permanent-disabled{% endif %}" {% if not page_params.setup_payment_by_invoice and not payment_method %}disabled{% endif %}>+ <div class="upgrade-button-container input-box upgrade-page-field" >+ <button id="org-upgrade-button" {% if not page_params.setup_payment_by_invoice and not payment_method %}disabled{% endif %}><span id="org-upgrade-button-text">{% if complimentary_access_plan_end_date %}<span id="org-future-upgrade-button-text-remote-server">diff --git a/web/styles/portico/portico_signin.css b/web/styles/portico/portico_signin.cssindex 3e262a95062..92f086f2e54 100644--- a/web/styles/portico/portico_signin.css+++ b/web/styles/portico/portico_signin.css@@ -448,33 +448,6 @@ html {font-weight: 400;}- .demo-organization-warning {- position: relative;- display: block;- background-color: hsl(360deg 100% 93%);- border: 1px solid hsl(0deg 0% 80%);- border-radius: 4px;- padding: 10px;- margin: 10px 0;- font-size: 1rem;- font-weight: 400;- line-height: 1.5;- color: hsl(0deg 0% 27%);-- & a {- text-decoration: none;- }-- &::before {- display: inline;- margin-right: 8px;-- font-family: FontAwesome;- font-weight: 600;- content: "\f071";- }- }-.alert {&:not(#server-deactivate-error,