mirror of https://github.com/zulip/zulip.git
billing: Hide /plans if Realm.plan_type=SELF_HOSTED.
This commit is contained in:
parent
c913eafdf4
commit
2a0523cbe5
|
@ -314,14 +314,14 @@ class PlansPageTest(ZulipTestCase):
|
||||||
result = self.client_get("/plans/", subdomain="moo")
|
result = self.client_get("/plans/", subdomain="moo")
|
||||||
self.assert_in_success_response(["does not exist"], result)
|
self.assert_in_success_response(["does not exist"], result)
|
||||||
# Test valid domain, no login
|
# Test valid domain, no login
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
realm.plan_type = Realm.PREMIUM_FREE
|
||||||
|
realm.save(update_fields=["plan_type"])
|
||||||
result = self.client_get("/plans/", subdomain="zulip")
|
result = self.client_get("/plans/", subdomain="zulip")
|
||||||
self.assertEqual(result.status_code, 302)
|
self.assertEqual(result.status_code, 302)
|
||||||
self.assertEqual(result["Location"], "/accounts/login?next=plans")
|
self.assertEqual(result["Location"], "/accounts/login?next=plans")
|
||||||
# Test valid domain, with login
|
# Test valid domain, with login
|
||||||
self.login(self.example_email('hamlet'))
|
self.login(self.example_email('hamlet'))
|
||||||
realm = get_realm("zulip")
|
|
||||||
realm.plan_type = Realm.PREMIUM_FREE
|
|
||||||
realm.save(update_fields=["plan_type"])
|
|
||||||
result = self.client_get("/plans/", subdomain="zulip")
|
result = self.client_get("/plans/", subdomain="zulip")
|
||||||
self.assert_in_success_response(["Current plan"], result)
|
self.assert_in_success_response(["Current plan"], result)
|
||||||
# Test root domain, with login on different domain
|
# Test root domain, with login on different domain
|
||||||
|
@ -340,8 +340,19 @@ class PlansPageTest(ZulipTestCase):
|
||||||
self.assert_in_success_response([sign_up_now, buy_premium], result)
|
self.assert_in_success_response([sign_up_now, buy_premium], result)
|
||||||
self.assert_not_in_success_response([current_plan], result)
|
self.assert_not_in_success_response([current_plan], result)
|
||||||
|
|
||||||
self.login(self.example_email("iago"))
|
|
||||||
realm = get_realm("zulip")
|
realm = get_realm("zulip")
|
||||||
|
realm.plan_type = Realm.SELF_HOSTED
|
||||||
|
realm.save(update_fields=["plan_type"])
|
||||||
|
result = self.client_get("/plans/", subdomain="zulip")
|
||||||
|
self.assertEqual(result.status_code, 302)
|
||||||
|
self.assertEqual(result["Location"], "/")
|
||||||
|
|
||||||
|
self.login(self.example_email("iago"))
|
||||||
|
|
||||||
|
# SELF_HOSTED should hide plans, even if logged in
|
||||||
|
result = self.client_get("/plans/", subdomain="zulip")
|
||||||
|
self.assertEqual(result.status_code, 302)
|
||||||
|
self.assertEqual(result["Location"], "/")
|
||||||
|
|
||||||
realm.plan_type = Realm.LIMITED
|
realm.plan_type = Realm.LIMITED
|
||||||
realm.save(update_fields=["plan_type"])
|
realm.save(update_fields=["plan_type"])
|
||||||
|
|
|
@ -294,6 +294,8 @@ def apps_view(request: HttpRequest, _: str) -> HttpResponse:
|
||||||
def plans_view(request: HttpRequest) -> HttpResponse:
|
def plans_view(request: HttpRequest) -> HttpResponse:
|
||||||
realm = get_realm_from_request(request)
|
realm = get_realm_from_request(request)
|
||||||
if realm is not None:
|
if realm is not None:
|
||||||
|
if realm.plan_type == Realm.SELF_HOSTED:
|
||||||
|
return HttpResponseRedirect(reverse('zerver.views.home.home'))
|
||||||
if not request.user.is_authenticated():
|
if not request.user.is_authenticated():
|
||||||
return redirect_to_login(next="plans")
|
return redirect_to_login(next="plans")
|
||||||
return render(request, "zerver/plans.html")
|
return render(request, "zerver/plans.html")
|
||||||
|
|
Loading…
Reference in New Issue