Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings: Show two-tier billing settings only in development.

Sahil Batraba936909352f
diff --git a/web/src/admin.ts b/web/src/admin.ts
index 924cd3fe83c..5599a32cfc2 100644
--- a/web/src/admin.ts
+++ b/web/src/admin.ts
@@ -315,7 +315,8 @@ export function build_page(): void {
),
default_avatar_source_values: settings_config.default_avatar_source_values,
realm_enable_two_tier_billing: settings_data.two_tier_billing_enabled(),
- show_two_tier_billing_settings: page_params.non_workplace_pricing_eligible,
+ show_two_tier_billing_settings:
+ page_params.development_environment && page_params.non_workplace_pricing_eligible,
};
const rendered_admin_tab = render_admin_tab(options);
diff --git a/web/src/settings_org.ts b/web/src/settings_org.ts
index 211fac44002..363066d03e0 100644
--- a/web/src/settings_org.ts
+++ b/web/src/settings_org.ts
@@ -466,6 +466,11 @@ function set_welcome_message_custom_text_visibility(): void {
}
export let set_two_tier_billing_settings_visibility = (): void => {
+ if (!page_params.development_environment) {
+ // Remove this when the feature is ready for production.
+ return;
+ }
+
if (!page_params.non_workplace_pricing_eligible) {
return;
}
@@ -1613,7 +1618,7 @@ export let initialize_group_setting_widgets = (): void => {
if (
setting_name === "workplace_users_group" &&
- !page_params.non_workplace_pricing_eligible
+ (!page_params.development_environment || !page_params.non_workplace_pricing_eligible)
) {
continue;
}
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index 3c0839fde75..cffa44b41cc 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -3296,6 +3296,31 @@ class RealmAPITest(ZulipTestCase):
realm.refresh_from_db()
self.assertEqual(realm.workplace_users_group_id, hamletcharacters_group.id)
+ def test_changing_workplace_users_group_requires_dev_environment(self) -> None:
+ realm = get_realm("zulip")
+ self.login("iago")
+ do_change_realm_plan_type(realm, Realm.PLAN_TYPE_LIMITED, acting_user=None)
+ moderators_group = NamedUserGroup.objects.get(
+ name=SystemGroups.MODERATORS, realm_for_sharding=realm
+ )
+ params = {"workplace_users_group": orjson.dumps({"new": moderators_group.id}).decode()}
+ with (
+ self.settings(DEVELOPMENT=False),
+ self.assertRaises(AssertionError),
+ self.assertLogs("django.request", "ERROR") as error_log,
+ ):
+ self.client_patch("/json/realm", params)
+ self.assertTrue(
+ "ERROR:django.request:Internal Server Error: /json/realm" in error_log.output[0]
+ )
+ self.assertTrue("AssertionError" in error_log.output[0])
+
+ with self.settings(DEVELOPMENT=True):
+ result = self.client_patch("/json/realm", params)
+ self.assert_json_success(result)
+ realm.refresh_from_db()
+ self.assertEqual(realm.workplace_users_group_id, moderators_group.id)
+
def test_updating_workplace_users_group_based_on_realm_plan(self) -> None:
realm = get_realm("zulip")
self.login("desdemona")
diff --git a/zerver/views/realm.py b/zerver/views/realm.py
index 71893905f09..6a75eba5dd7 100644
--- a/zerver/views/realm.py
+++ b/zerver/views/realm.py
@@ -393,6 +393,9 @@ def update_realm(
data["jitsi_server_url"] = jitsi_server_url
if workplace_users_group is not None:
+ # Remove this when the feature is ready for production.
+ assert settings.DEVELOPMENT
+
if not realm_eligible_for_non_workplace_pricing(realm):
raise JsonableError(
_("Organization is not eligible for discounted pricing for non workplace users.")