From 36e634ca057e6aa55ffed41686a05df0883a1062 Mon Sep 17 00:00:00 2001 From: Zach Aysan Date: Tue, 13 Aug 2024 06:10:10 -0400 Subject: [PATCH] feat: Tweak email wording for grace periods (#4482) --- api/organisations/task_helpers.py | 1 + .../organisations/api_usage_notification.html | 4 ++-- .../organisations/api_usage_notification.txt | 4 ++-- .../organisations/api_usage_notification_limit.html | 4 ++-- .../organisations/api_usage_notification_limit.txt | 6 +++--- .../organisations/test_unit_organisations_tasks.py | 12 ++++++++++-- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/api/organisations/task_helpers.py b/api/organisations/task_helpers.py index daacfaf3d13a..65d382358615 100644 --- a/api/organisations/task_helpers.py +++ b/api/organisations/task_helpers.py @@ -69,6 +69,7 @@ def _send_api_usage_notification( context = { "organisation": organisation, "matched_threshold": matched_threshold, + "grace_period": not hasattr(organisation, "breached_grace_period"), } send_mail( diff --git a/api/organisations/templates/organisations/api_usage_notification.html b/api/organisations/templates/organisations/api_usage_notification.html index 19b14d13b1b1..74deaac7fc7d 100644 --- a/api/organisations/templates/organisations/api_usage_notification.html +++ b/api/organisations/templates/organisations/api_usage_notification.html @@ -19,8 +19,8 @@ for overages after our first grace period of 30 days. {% else %} Please note that once 100% use has been breached, the serving of feature flags and admin access may - be disabled after a 7-day grace period. Please reach out to support@flagsmith.com in order to upgrade - your account. + be disabled{% if grace_period %} after a 7-day grace period{% endif %}. Please reach out to + support@flagsmith.com in order to upgrade your account. {% endif %} diff --git a/api/organisations/templates/organisations/api_usage_notification.txt b/api/organisations/templates/organisations/api_usage_notification.txt index f5646e87abcd..e02fe3f967c5 100644 --- a/api/organisations/templates/organisations/api_usage_notification.txt +++ b/api/organisations/templates/organisations/api_usage_notification.txt @@ -8,8 +8,8 @@ If this is expected, no action is required. If you are expecting to go over, you limits by reaching out to support@flagsmith.com. We will automatically charge for overages after our first grace period of 30 days. {% else %} -Please note that once 100% use has been breached, the serving of feature flags and admin access may be disabled after a -7-day grace period. Please reach out to support@flagsmith.com in order to upgrade your account. +Please note that once 100% use has been breached, the serving of feature flags and admin access may be disabled{% if grace_period %} +after a 7-day grace period{% endif %}. Please reach out to support@flagsmith.com in order to upgrade your account. {% endif %} Thank you! diff --git a/api/organisations/templates/organisations/api_usage_notification_limit.html b/api/organisations/templates/organisations/api_usage_notification_limit.html index 15f4bf9ea3e5..fa79e1196f96 100644 --- a/api/organisations/templates/organisations/api_usage_notification_limit.html +++ b/api/organisations/templates/organisations/api_usage_notification_limit.html @@ -18,8 +18,8 @@ more information. You can reach out to support@flagsmith.com if you’d like to take advantage of better contracted rates. {% else %} - Please note that the serving of feature flags and admin access will be disabled after a 7 day grace - period until the next subscription period. If you’d like to continue service you can upgrade your + Please note that the serving of feature flags and admin access will be disabled{% if grace_period %} after a 7 day grace + period{% endif %} until the next subscription period. If you’d like to continue service you can upgrade your organisation’s account (see pricing page). {% endif %} diff --git a/api/organisations/templates/organisations/api_usage_notification_limit.txt b/api/organisations/templates/organisations/api_usage_notification_limit.txt index faf301b74c22..65c8d1eaa48c 100644 --- a/api/organisations/templates/organisations/api_usage_notification_limit.txt +++ b/api/organisations/templates/organisations/api_usage_notification_limit.txt @@ -7,9 +7,9 @@ has reached {{ matched_threshold }}% of your API usage within the current subscr We will charge for overages after our first grace period of 30 days. Please see the pricing page for more information. You can reach out to support@flagsmith.com if you’d like to take advantage of better contracted rates. {% else %} -Please note that the serving of feature flags and admin access will be disabled after a 7 day grace period until the -next subscription period. If you’d like to continue service you can upgrade your organisation’s account (see pricing -page). +Please note that the serving of feature flags and admin access will be disabled{% if grace_period %} after a 7 day +grace period{% endif %} until the next subscription period. If you’d like to continue service you can upgrade your +organisation’s account (see pricing page). {% endif %} Thank you! diff --git a/api/tests/unit/organisations/test_unit_organisations_tasks.py b/api/tests/unit/organisations/test_unit_organisations_tasks.py index 83d1bf006c97..4d1a38dd9520 100644 --- a/api/tests/unit/organisations/test_unit_organisations_tasks.py +++ b/api/tests/unit/organisations/test_unit_organisations_tasks.py @@ -664,7 +664,11 @@ def test_handle_api_usage_notifications_for_free_accounts( assert email.subject == "Flagsmith API use has reached 100%" assert email.body == render_to_string( "organisations/api_usage_notification_limit.txt", - context={"organisation": organisation, "matched_threshold": 100}, + context={ + "organisation": organisation, + "matched_threshold": 100, + "grace_period": True, + }, ) assert len(email.alternatives) == 1 @@ -673,7 +677,11 @@ def test_handle_api_usage_notifications_for_free_accounts( assert email.alternatives[0][0] == render_to_string( "organisations/api_usage_notification_limit.html", - context={"organisation": organisation, "matched_threshold": 100}, + context={ + "organisation": organisation, + "matched_threshold": 100, + "grace_period": True, + }, ) assert email.from_email == "noreply@flagsmith.com"