Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
billing: Don't redirect to sponsorship page for orgs on paid plan.
Aman Agrawal0012a52e88d8
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex 7914ffd045a..7591415f486 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -2353,11 +2353,29 @@ class StripeTest(StripeTestCase):user.realm.plan_type = Realm.PLAN_TYPE_LIMITEDuser.realm.save()- Customer.objects.create(realm=user.realm, stripe_customer_id="cus_123")+ 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"])+ # Check redirects for sponsorship pending+ customer.sponsorship_pending = True+ customer.save()+ response = self.client_get("/billing/")+ self.assertEqual(response.status_code, 302)+ self.assertEqual("/sponsorship/", response["Location"])++ # Don't redirect to sponsorship for paid plans.+ user.realm.plan_type = Realm.PLAN_TYPE_STANDARD+ user.realm.save()+ response = self.client_get("/billing/")+ self.assertNotEqual("/sponsorship/", response["Location"])++ user.realm.plan_type = Realm.PLAN_TYPE_PLUS+ user.realm.save()+ response = self.client_get("/billing/")+ self.assertNotEqual("/sponsorship/", response["Location"])+def test_upgrade_page_for_demo_organizations(self) -> None:user = self.example_user("hamlet")user.realm.demo_organization_scheduled_deletion_date = timezone_now() + timedelta(days=30)diff --git a/corporate/views/billing_page.py b/corporate/views/billing_page.pyindex 2c3b604d97e..47f9c593138 100644--- a/corporate/views/billing_page.py+++ b/corporate/views/billing_page.py@@ -113,11 +113,19 @@ def billing_home(context["is_sponsored"] = Truereturn HttpResponseRedirect(reverse("sponsorship_request"))+ PAID_PLANS = [+ Realm.PLAN_TYPE_STANDARD,+ Realm.PLAN_TYPE_PLUS,+ ]+customer = get_customer_by_realm(user.realm)- if (- customer is not None and customer.sponsorship_pending- ) or user.realm.plan_type == user.realm.PLAN_TYPE_STANDARD_FREE:- return HttpResponseRedirect(reverse("sponsorship_request"))+ if customer is not None and customer.sponsorship_pending:+ # Don't redirect to sponsorship page if the realm is on a paid plan+ if user.realm.plan_type not in PAID_PLANS:+ return HttpResponseRedirect(reverse("sponsorship_request"))+ # If the realm is on a paid plan, show the sponsorship pending message+ # TODO: Add a sponsorship pending message to the billing page+ context["sponsorship_pending"] = Trueif customer is None:from corporate.views.upgrade import initial_upgrade