From ccd60bc7e26ed02ef50582a0a3026b336f4e82bf Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Sat, 9 Dec 2023 17:31:27 +0000 Subject: [PATCH] settings: Use original FREE_TRIAL_DAYS for cloud free trials. * Renamed FREE_TRIAL_DAYS to CLOUD_FREE_TRIAL_DAYS. * Used `cloud_free_trial_days` to get free trial days secret. --- corporate/lib/stripe.py | 4 ++-- corporate/tests/test_stripe.py | 16 ++++++++-------- docs/subsystems/billing.md | 6 +++--- zerver/tests/test_docs.py | 2 +- zerver/tests/test_signup.py | 2 +- zproject/default_settings.py | 2 +- zproject/test_extra_settings.py | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py index 78a047b3d6..6656b3f99d 100644 --- a/corporate/lib/stripe.py +++ b/corporate/lib/stripe.py @@ -3628,11 +3628,11 @@ def compute_plan_parameters( def get_free_trial_days() -> Optional[int]: - return settings.FREE_TRIAL_DAYS + return settings.CLOUD_FREE_TRIAL_DAYS def is_free_trial_offer_enabled() -> bool: - return settings.FREE_TRIAL_DAYS not in (None, 0) + return settings.CLOUD_FREE_TRIAL_DAYS not in (None, 0) def ensure_customer_does_not_have_active_plan(customer: Customer) -> None: diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index 4d0369c2fc..0b3b4f0927 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -1033,7 +1033,7 @@ class StripeTest(StripeTestCase): user = self.example_user("hamlet") self.login_user(user) - with self.settings(FREE_TRIAL_DAYS=60): + with self.settings(CLOUD_FREE_TRIAL_DAYS=60): response = self.client_get("/upgrade/") free_trial_end_date = self.now + timedelta(days=60) @@ -1253,7 +1253,7 @@ class StripeTest(StripeTestCase): self.login_user(user) free_trial_end_date = self.now + timedelta(days=60) - with self.settings(FREE_TRIAL_DAYS=60): + with self.settings(CLOUD_FREE_TRIAL_DAYS=60): response = self.client_get("/upgrade/") self.assert_in_success_response( @@ -1992,7 +1992,7 @@ class StripeTest(StripeTestCase): self.assertEqual(response.status_code, 302) self.assertEqual(response["Location"], "http://zulip.testserver/billing") - with self.settings(FREE_TRIAL_DAYS=30): + with self.settings(CLOUD_FREE_TRIAL_DAYS=30): response = self.client_get("/upgrade/") self.assertEqual(response.status_code, 302) self.assertEqual(response["Location"], "http://zulip.testserver/billing") @@ -2889,7 +2889,7 @@ class StripeTest(StripeTestCase): self.login_user(user) free_trial_end_date = self.now + timedelta(days=60) - with self.settings(FREE_TRIAL_DAYS=60): + with self.settings(CLOUD_FREE_TRIAL_DAYS=60): with time_machine.travel(self.now, tick=False): self.add_card_and_upgrade(user, schedule="monthly") plan = CustomerPlan.objects.get() @@ -2944,7 +2944,7 @@ class StripeTest(StripeTestCase): self.login_user(user) free_trial_end_date = self.now + timedelta(days=60) - with self.settings(FREE_TRIAL_DAYS=60): + with self.settings(CLOUD_FREE_TRIAL_DAYS=60): with time_machine.travel(self.now, tick=False): self.add_card_and_upgrade(user, schedule="annual") plan = CustomerPlan.objects.get() @@ -2996,7 +2996,7 @@ class StripeTest(StripeTestCase): user = self.example_user("hamlet") free_trial_end_date = self.now + timedelta(days=60) - with self.settings(FREE_TRIAL_DAYS=60): + with self.settings(CLOUD_FREE_TRIAL_DAYS=60): with time_machine.travel(self.now, tick=False): self.local_upgrade( self.seat_count, True, CustomerPlan.BILLING_SCHEDULE_ANNUAL, False, True @@ -3048,7 +3048,7 @@ class StripeTest(StripeTestCase): self.login_user(user) free_trial_end_date = self.now + timedelta(days=60) - with self.settings(FREE_TRIAL_DAYS=60): + with self.settings(CLOUD_FREE_TRIAL_DAYS=60): with time_machine.travel(self.now, tick=False): self.local_upgrade( self.seat_count, True, CustomerPlan.BILLING_SCHEDULE_ANNUAL, False, True @@ -3159,7 +3159,7 @@ class StripeTest(StripeTestCase): self.login_user(user) free_trial_end_date = self.now + timedelta(days=60) - with self.settings(FREE_TRIAL_DAYS=60): + with self.settings(CLOUD_FREE_TRIAL_DAYS=60): with time_machine.travel(self.now, tick=False): self.local_upgrade( self.seat_count, True, CustomerPlan.BILLING_SCHEDULE_ANNUAL, False, True diff --git a/docs/subsystems/billing.md b/docs/subsystems/billing.md index 1b476c66be..4f8383c624 100644 --- a/docs/subsystems/billing.md +++ b/docs/subsystems/billing.md @@ -69,10 +69,10 @@ a few things to keep in mind while conducting these tests manually: Here are some flows to test when upgrading a Zulip organization: -- When free trials are not enabled, i.e. `FREE_TRIAL_DAYS` is not set +- When free trials are not enabled, i.e. `CLOUD_FREE_TRIAL_DAYS` is not set to any value in `dev_settings.py` (aka the default). You can double-check that the setting is disabled by verifying - `./scripts/get-django-setting FREE_TRIAL_DAYS` returns 0. + `./scripts/get-django-setting CLOUD_FREE_TRIAL_DAYS` returns 0. - Using a valid card number like `4242 4242 4242 4242`. - Using an invalid card number like `4000000000000341`, which will add the card @@ -84,7 +84,7 @@ Here are some flows to test when upgrading a Zulip organization: - Upgrade an organization when free trials are enabled. The free trials setting has been (possibly permanently) disabled in production for some time now, so testing this code path is not a - priority. You can set `FREE_TRIAL_DAYS` to any number greater than + priority. You can set `CLOUD_FREE_TRIAL_DAYS` to any number greater than `0` in `dev_settings.py` to enable free trials. There are two different flows to test here: - Right after the organization is created by following the instructions in the diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py index d2c1b21648..4a869de14b 100644 --- a/zerver/tests/test_docs.py +++ b/zerver/tests/test_docs.py @@ -575,7 +575,7 @@ class PlansPageTest(ZulipTestCase): self.assert_in_success_response([current_plan, upgrade_to_standard], result) self.assert_not_in_success_response([sign_up_now, sponsorship_pending], result) - with self.settings(FREE_TRIAL_DAYS=60): + with self.settings(CLOUD_FREE_TRIAL_DAYS=60): result = self.client_get("/plans/", subdomain="zulip") self.assert_in_success_response([current_plan, "Start 60-day free trial"], result) self.assert_not_in_success_response( diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index 7989853187..e4a600bb6e 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -1754,7 +1754,7 @@ class RealmCreationTest(ZulipTestCase): self.assert_length(messages, message_count) self.assertIn(text, messages[0].content) - @override_settings(OPEN_REALM_CREATION=True, FREE_TRIAL_DAYS=30) + @override_settings(OPEN_REALM_CREATION=True, CLOUD_FREE_TRIAL_DAYS=30) def test_create_realm_during_free_trial(self) -> None: password = "test" string_id = "custom-test" diff --git a/zproject/default_settings.py b/zproject/default_settings.py index c279139123..76bd50accc 100644 --- a/zproject/default_settings.py +++ b/zproject/default_settings.py @@ -546,7 +546,7 @@ ARCHIVED_DATA_VACUUMING_DELAY_DAYS = 30 # are available to all realms. BILLING_ENABLED = False -FREE_TRIAL_DAYS: Optional[int] = int(get_secret("free_trial_days", "0")) +CLOUD_FREE_TRIAL_DAYS: Optional[int] = int(get_secret("cloud_free_trial_days", "0")) # Custom message (supports HTML) to be shown in the navbar of landing pages. Used mainly for # making announcements. diff --git a/zproject/test_extra_settings.py b/zproject/test_extra_settings.py index 1028ce58f9..e7846ff1ec 100644 --- a/zproject/test_extra_settings.py +++ b/zproject/test_extra_settings.py @@ -257,7 +257,7 @@ RATE_LIMITING_RULES: Dict[str, List[Tuple[int, int]]] = { "password_reset_form_by_email": [], } -FREE_TRIAL_DAYS: Optional[int] = None +CLOUD_FREE_TRIAL_DAYS: Optional[int] = None SCIM_CONFIG: Dict[str, SCIMConfigDict] = { "zulip": {