billing_page: Redirect users on free plan to `/plans`.

Fixes #27379
This commit is contained in:
Aman Agrawal 2023-11-08 16:38:47 +00:00
parent 56eec2734c
commit 9a186ac8d5
3 changed files with 15 additions and 28 deletions

View File

@ -2333,7 +2333,7 @@ class StripeTest(StripeTestCase):
customer = Customer.objects.create(realm=user.realm, stripe_customer_id="cus_123")
response = self.client_get("/billing/")
self.assertEqual(response.status_code, 302)
self.assertEqual("/upgrade/", response["Location"])
self.assertEqual("/plans/", response["Location"])
# Check redirects for sponsorship pending
customer.sponsorship_pending = True
@ -3103,9 +3103,8 @@ class StripeTest(StripeTestCase):
self.login_user(user)
response = self.client_get("/billing/")
self.assert_in_success_response(
["Your organization is on the <b>Zulip Free</b>"], response
)
self.assertEqual(response.status_code, 302)
self.assertEqual("/plans/", response["Location"])
# The extra users added in the final month are not charged
with patch("corporate.lib.stripe.invoice_plan") as mocked:
@ -3151,7 +3150,8 @@ class StripeTest(StripeTestCase):
invoice_plans_as_needed(self.next_year)
response = self.client_get("/billing/")
self.assert_in_success_response(["Your organization is on the <b>Zulip Free</b>"], response)
self.assertEqual(response.status_code, 302)
self.assertEqual("/plans/", response["Location"])
with patch("corporate.lib.stripe.timezone_now", return_value=self.next_year):
self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, True, False)
@ -3462,7 +3462,8 @@ class StripeTest(StripeTestCase):
self.login_user(user)
response = self.client_get("/billing/")
self.assert_in_success_response(["Your organization is on the <b>Zulip Free</b>"], response)
self.assertEqual(response.status_code, 302)
self.assertEqual("/plans/", response["Location"])
# The extra users added in the final month are not charged
with patch("corporate.lib.stripe.invoice_plan") as mocked:
@ -3486,7 +3487,8 @@ class StripeTest(StripeTestCase):
self.login_user(user)
response = self.client_get("/billing/")
self.assert_in_success_response(["Your organization is on the <b>Zulip Free</b>"], response)
self.assertEqual(response.status_code, 302)
self.assertEqual("/plans/", response["Location"])
with patch("corporate.lib.stripe.timezone_now", return_value=self.now):
self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, True, False)

View File

@ -140,6 +140,9 @@ def billing_home(
# TODO: Add a sponsorship pending message to the billing page
context["sponsorship_pending"] = True
if user.realm.plan_type == user.realm.PLAN_TYPE_LIMITED:
return HttpResponseRedirect(reverse("plans"))
if customer is None:
from corporate.views.upgrade import initial_upgrade

View File

@ -198,27 +198,9 @@
To make changes to your plan or view your billing history <a href="mailto:support@zulip.com">contact Zulip support</a>.
</p>
</div>
{% elif admin_access and not has_active_plan %}
<!-- For sponsored or sponsorship pending organizations we already redirect to /sponsorship page. -->
<div class="tab-content">
<center>
<p>
<h2>Your organization is on the <b>Zulip Free</b> plan.</h2>
<a href="/upgrade/">
<button type="submit" class="button green">Upgrade to Standard</button>
</a>
<a href="/plans/">
<button type="submit">View all plans</button>
</a>
</p>
</center>
</div>
<div class="support-link">
<p>
<a href="mailto:support@zulip.com">Contact Zulip support</a> for billing history.
</p>
</div>
{% else %}
<!-- For sponsored or sponsorship pending organizations we redirect to /sponsorship page. -->
<!-- For organizations on free plan we redirect to /plans page. -->
<p>
You must be an organization owner or a billing administrator to view this page.
</p>
@ -294,7 +276,7 @@
</header>
<main class="modal__content">
<p>
Your organization will be downgraded to Zulip Cloud Free at the end of the current billing
Your organization will be downgraded to <strong>Zulip Cloud Free</strong> at the end of the current billing
period ({{ renewal_date }}). You will lose access to unlimited search history and
<a href="/plans/">other features</a>
of your current plan. Are you sure you want to continue?