From c913eafdf4b0f6d842296f4642e0f292b6f7d042 Mon Sep 17 00:00:00 2001 From: Vishnu Ks Date: Wed, 15 Aug 2018 16:05:07 +0000 Subject: [PATCH] portico: Change buttons on /plans to reflect current plan. --- static/styles/landing-page.scss | 7 +++++++ templates/zerver/plans.html | 23 +++++++++++++++++++++-- zerver/context_processors.py | 3 +++ zerver/tests/test_docs.py | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/static/styles/landing-page.scss b/static/styles/landing-page.scss index bb38662d13..f94afbdeee 100644 --- a/static/styles/landing-page.scss +++ b/static/styles/landing-page.scss @@ -183,6 +183,13 @@ button.green { border: 1px solid hsl(169, 45%, 43%); } +button.black-disabled { + cursor: default; + color: #333; + background-color: transparent; + border: 1px solid #888; +} + button.button.grey-transparent { display: block; margin: 0 auto; diff --git a/templates/zerver/plans.html b/templates/zerver/plans.html index ec1fef5be2..c951b2f884 100644 --- a/templates/zerver/plans.html +++ b/templates/zerver/plans.html @@ -38,6 +38,7 @@
+ {% if realm_plan_type == 0 %}
Free
@@ -46,6 +47,12 @@ Sign up now + {% elif realm_plan_type == 2 %} +
+ + {% endif %}
@@ -76,11 +83,23 @@ $8/month billed monthly - + {% if realm_plan_type in [3, 4] %} + + {% elif realm_plan_type == 2 %} + + {% else %} + + + + {% endif %} diff --git a/zerver/context_processors.py b/zerver/context_processors.py index 00d7807ba8..c7703da7ed 100644 --- a/zerver/context_processors.py +++ b/zerver/context_processors.py @@ -56,6 +56,7 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]: realm_icon = None realm_description = None realm_invite_required = False + realm_plan_type = 0 else: realm_uri = realm.uri realm_name = realm.name @@ -63,6 +64,7 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]: realm_description_raw = realm.description or "The coolest place in the universe." realm_description = convert(realm_description_raw, message_realm=realm) realm_invite_required = realm.invite_required + realm_plan_type = realm.plan_type register_link_disabled = settings.REGISTER_LINK_DISABLED login_link_disabled = settings.LOGIN_LINK_DISABLED @@ -114,6 +116,7 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]: 'realm_name': realm_name, 'realm_icon': realm_icon, 'realm_description': realm_description, + 'realm_plan_type': realm_plan_type, 'root_domain_uri': settings.ROOT_DOMAIN_URI, 'apps_page_url': apps_page_url, 'open_realm_creation': settings.OPEN_REALM_CREATION, diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py index 46e85f32b2..bcd2a73df8 100644 --- a/zerver/tests/test_docs.py +++ b/zerver/tests/test_docs.py @@ -323,9 +323,40 @@ class PlansPageTest(ZulipTestCase): realm.plan_type = Realm.PREMIUM_FREE realm.save(update_fields=["plan_type"]) result = self.client_get("/plans/", subdomain="zulip") - self.assert_in_success_response(["Sign up now"], result) + self.assert_in_success_response(["Current plan"], result) # Test root domain, with login on different domain result = self.client_get("/plans/", subdomain="") # TODO: works in manual testing, but I suspect something is funny in # the test environment # self.assert_in_success_response(["Sign up now"], result) + + def test_CTA_text_by_plan_type(self) -> None: + sign_up_now = "Sign up now" + buy_premium = "Buy Premium" + current_plan = "Current plan" + + # Root domain + result = self.client_get("/plans/", subdomain="") + self.assert_in_success_response([sign_up_now, buy_premium], result) + self.assert_not_in_success_response([current_plan], result) + + self.login(self.example_email("iago")) + realm = get_realm("zulip") + + realm.plan_type = Realm.LIMITED + realm.save(update_fields=["plan_type"]) + result = self.client_get("/plans/", subdomain="zulip") + self.assert_in_success_response([current_plan, buy_premium], result) + self.assert_not_in_success_response([sign_up_now], result) + + realm.plan_type = Realm.PREMIUM_FREE + realm.save(update_fields=["plan_type"]) + result = self.client_get("/plans/", subdomain="zulip") + self.assert_in_success_response([current_plan], result) + self.assert_not_in_success_response([sign_up_now, buy_premium], result) + + realm.plan_type = Realm.PREMIUM + realm.save(update_fields=["plan_type"]) + result = self.client_get("/plans/", subdomain="zulip") + self.assert_in_success_response([current_plan], result) + self.assert_not_in_success_response([sign_up_now, buy_premium], result)