remote_billing_page: Redirect servers to correct URL after login.

This commit is contained in:
Aman Agrawal 2023-12-03 11:52:27 +00:00 committed by Tim Abbott
parent ff368e3240
commit 8a1630ee42
2 changed files with 16 additions and 7 deletions

View File

@ -328,7 +328,7 @@ class LegacyServerLoginTest(BouncerTestCase):
)
self.assertEqual(result.status_code, 302)
self.assertEqual(result["Location"], f"/server/{self.uuid}/billing/")
self.assertEqual(result["Location"], f"/server/{self.uuid}/upgrade")
# Verify the authed data that should have been stored in the session.
identity_dict = LegacyServerIdentityDict(
@ -340,7 +340,7 @@ class LegacyServerLoginTest(BouncerTestCase):
identity_dict,
)
result = self.client_get(result["Location"], subdomain="selfhosting")
result = self.client_get(f"/server/{self.uuid}/billing/", subdomain="selfhosting")
# The server has no plan, so the /billing page redirects to /upgrade
self.assertEqual(result.status_code, 302)
self.assertEqual(result["Location"], f"/server/{self.uuid}/upgrade")

View File

@ -272,11 +272,20 @@ def remote_billing_legacy_server_login(
)
assert next_page in VALID_NEXT_PAGES
if next_page is None:
return HttpResponseRedirect(
reverse("remote_server_billing_page", args=(remote_server_uuid,))
)
else:
if next_page is not None:
return HttpResponseRedirect(
reverse(f"remote_server_{next_page}_page", args=(remote_server_uuid,))
)
elif remote_server.plan_type == RemoteZulipServer.PLAN_TYPE_SELF_HOSTED:
# TODO: Take user to plans page once that is available.
return HttpResponseRedirect(
reverse("remote_server_upgrade_page", args=(remote_server_uuid,))
)
elif remote_server.plan_type == RemoteZulipServer.PLAN_TYPE_COMMUNITY:
return HttpResponseRedirect(
reverse("remote_server_sponsorship_page", args=(remote_server_uuid,))
)
else:
return HttpResponseRedirect(
reverse("remote_server_billing_page", args=(remote_server_uuid,))
)