From cfd61669e0eecaf8fcea2ac65da60ca2bd5c94c5 Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Tue, 5 Dec 2023 13:09:33 +0100 Subject: [PATCH] support: Add plan type to remote server information. Updates `get_plan_type_string` for RemoteZulipServer plan types and capitalizes the strings used for Realm plan types. Also changes the string for Realm.PLAN_TYPE_STANDARD_FREE to be "Standard free" instead of "open source" as that is used for any 100% sponsored organization, which is not restricted to open-source projects. --- analytics/tests/test_support_views.py | 4 ++-- analytics/views/installation_activity.py | 4 ++-- analytics/views/support.py | 19 ++++++++++++------- .../analytics/remote_server_support.html | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/analytics/tests/test_support_views.py b/analytics/tests/test_support_views.py index 0edf07fcfd..1ad13d6c38 100644 --- a/analytics/tests/test_support_views.py +++ b/analytics/tests/test_support_views.py @@ -504,7 +504,7 @@ class TestSupportEndpoint(ZulipTestCase): ) m.assert_called_once_with(get_realm("zulip"), 2, acting_user=iago) self.assert_in_success_response( - ["Plan type of zulip changed from self-hosted to limited"], result + ["Plan type of zulip changed from Self-hosted to Limited"], result ) with mock.patch("analytics.views.support.do_change_realm_plan_type") as m: @@ -513,7 +513,7 @@ class TestSupportEndpoint(ZulipTestCase): ) m.assert_called_once_with(get_realm("zulip"), 10, acting_user=iago) self.assert_in_success_response( - ["Plan type of zulip changed from self-hosted to plus"], result + ["Plan type of zulip changed from Self-hosted to Plus"], result ) def test_change_org_type(self) -> None: diff --git a/analytics/views/installation_activity.py b/analytics/views/installation_activity.py index 337a122e31..5144e969c8 100644 --- a/analytics/views/installation_activity.py +++ b/analytics/views/installation_activity.py @@ -22,7 +22,7 @@ from analytics.views.activity_common import ( realm_support_link, realm_url_link, ) -from analytics.views.support import get_plan_name +from analytics.views.support import get_plan_type_string from zerver.decorator import require_server_admin from zerver.lib.request import has_request_variables from zerver.models import Realm, get_org_type_display_name @@ -204,7 +204,7 @@ def realm_summary_table() -> str: realms_with_default_discount = get_realms_with_default_discount_dict() for row in rows: - row["plan_type_string"] = get_plan_name(row["plan_type"]) + row["plan_type_string"] = get_plan_type_string(row["plan_type"]) string_id = row["string_id"] diff --git a/analytics/views/support.py b/analytics/views/support.py index 3005718951..be8f4e0f67 100644 --- a/analytics/views/support.py +++ b/analytics/views/support.py @@ -66,13 +66,17 @@ if settings.BILLING_ENABLED: from corporate.models import CustomerPlan -def get_plan_name(plan_type: int) -> str: +def get_plan_type_string(plan_type: int) -> str: return { - Realm.PLAN_TYPE_SELF_HOSTED: "self-hosted", - Realm.PLAN_TYPE_LIMITED: "limited", - Realm.PLAN_TYPE_STANDARD: "standard", - Realm.PLAN_TYPE_STANDARD_FREE: "open source", - Realm.PLAN_TYPE_PLUS: "plus", + Realm.PLAN_TYPE_SELF_HOSTED: "Self-hosted", + Realm.PLAN_TYPE_LIMITED: "Limited", + Realm.PLAN_TYPE_STANDARD: "Standard", + Realm.PLAN_TYPE_STANDARD_FREE: "Standard free", + Realm.PLAN_TYPE_PLUS: "Plus", + RemoteZulipServer.PLAN_TYPE_SELF_HOSTED: "Self-hosted", + RemoteZulipServer.PLAN_TYPE_COMMUNITY: "Community", + RemoteZulipServer.PLAN_TYPE_BUSINESS: "Business", + RemoteZulipServer.PLAN_TYPE_ENTERPRISE: "Enterprise", }[plan_type] @@ -210,7 +214,7 @@ def support( elif plan_type is not None: current_plan_type = realm.plan_type do_change_realm_plan_type(realm, plan_type, acting_user=acting_user) - msg = f"Plan type of {realm.string_id} changed from {get_plan_name(current_plan_type)} to {get_plan_name(plan_type)} " + msg = f"Plan type of {realm.string_id} changed from {get_plan_type_string(current_plan_type)} to {get_plan_type_string(plan_type)} " context["success_message"] = msg elif org_type is not None: current_realm_type = realm.org_type @@ -475,6 +479,7 @@ def remote_servers_support( context["remote_server_to_max_monthly_messages"] = remote_server_to_max_monthly_messages context["plan_data"] = plan_data context["get_discount"] = get_customer_discount_for_support_view + context["get_plan_type_name"] = get_plan_type_string return render( request, diff --git a/templates/analytics/remote_server_support.html b/templates/analytics/remote_server_support.html index 0feee3df8c..1b79940d82 100644 --- a/templates/analytics/remote_server_support.html +++ b/templates/analytics/remote_server_support.html @@ -45,6 +45,7 @@
Last updated: {{ remote_server.last_updated|timesince }} ago
Max monthly messages: {{ remote_server_to_max_monthly_messages[remote_server.id] }}
+ Plan type: {{ get_plan_type_name(remote_server.plan_type) }}
{% if remote_server.plan_type == 100 %}

On 100% sponsored Zulip Community plan.

{% endif %}