diff --git a/api/organisations/templates/organisations/api_usage_notification.html b/api/organisations/templates/organisations/api_usage_notification.html index d82eaaea38c9..ebbd06837f37 100644 --- a/api/organisations/templates/organisations/api_usage_notification.html +++ b/api/organisations/templates/organisations/api_usage_notification.html @@ -12,6 +12,12 @@ The API usage for {{ organisation.name }} has reached {{ matched_threshold }}% within the current subscription period. Please consider upgrading your organisation's account limits. + {% if organisation.is_paid %} + Please note that once the 100% use has been breached automated charges for your account may apply. + {% else %} + Please note that once the 100% use has been breached the serving of feature flags and admin access may be disabled after a grace period. + {% endif %} + diff --git a/api/organisations/templates/organisations/api_usage_notification.txt b/api/organisations/templates/organisations/api_usage_notification.txt index cce88fcce54e..3cdd6e2c80cf 100644 --- a/api/organisations/templates/organisations/api_usage_notification.txt +++ b/api/organisations/templates/organisations/api_usage_notification.txt @@ -2,6 +2,11 @@ Hi there, The API usage for {{ organisation.name }} has reached {{ matched_threshold }}% within the current subscription period. Please consider upgrading your organisation's account limits. +{% if organisation.is_paid %} +Please note that once the 100% use has been breached automated charges for your account may apply. +{% else %} +Please note that once the 100% use has been breached the serving of feature flags and admin access may be disabled after a grace period. +{% endif %} Thank you! The Flagsmith Team diff --git a/api/organisations/templates/organisations/api_usage_notification_limit.html b/api/organisations/templates/organisations/api_usage_notification_limit.html index b5f25ebb1f94..b5083d0f71b8 100644 --- a/api/organisations/templates/organisations/api_usage_notification_limit.html +++ b/api/organisations/templates/organisations/api_usage_notification_limit.html @@ -11,7 +11,11 @@ The API usage for {{ organisation.name }} has breached {{ matched_threshold }}% within the current subscription period. - Please upgrade your organisation's account to ensure continued service. + {% if organisation.is_paid %} + Please note that automated charges for your account may apply. + {% else %} + Please note that the serving of feature flags and admin access may be disabled after a grace period, so please upgrade your organisation's account to ensure continued service. + {% endif %} diff --git a/api/organisations/templates/organisations/api_usage_notification_limit.txt b/api/organisations/templates/organisations/api_usage_notification_limit.txt index 11a0816bca4c..116914d1a620 100644 --- a/api/organisations/templates/organisations/api_usage_notification_limit.txt +++ b/api/organisations/templates/organisations/api_usage_notification_limit.txt @@ -1,6 +1,12 @@ Hi there, -The API usage for {{ organisation.name }} has breached {{ matched_threshold }}% within the current subscription period. Please upgrade your organisation's account to ensure continued service. +The API usage for {{ organisation.name }} has breached {{ matched_threshold }}% within the current subscription period. + +{% if organisation.is_paid %} +Please note that automated charges for your account may apply. +{% else %} +Please note that the serving of feature flags and admin access may be disabled after a grace period, so please upgrade your organisation's account to ensure continued service. +{% 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 f50009037126..375b55b773c8 100644 --- a/api/tests/unit/organisations/test_unit_organisations_tasks.py +++ b/api/tests/unit/organisations/test_unit_organisations_tasks.py @@ -293,6 +293,7 @@ def test_handle_api_usage_notifications_below_100( # Given now = timezone.now() organisation.subscription.plan = SCALE_UP + organisation.subscription.subscription_id = "fancy_id" organisation.subscription.save() OrganisationSubscriptionInformationCache.objects.create( organisation=organisation, @@ -328,7 +329,9 @@ def test_handle_api_usage_notifications_below_100( assert email.body == ( "Hi there,\n\nThe API usage for Test Org has reached " "90% within the current subscription period. Please " - "consider upgrading your organisation's account limits.\n\n" + "consider upgrading your organisation's account limits.\n\n\n" + "Please note that once the 100% use has been breached " + "automated charges for your account may apply.\n\n" "Thank you!\n\nThe Flagsmith Team\n" ) @@ -337,16 +340,18 @@ def test_handle_api_usage_notifications_below_100( assert email.alternatives[0][1] == "text/html" assert email.alternatives[0][0] == ( - "\n\n \n\n " - "\n\n \n\n " - "\n\n \n\n\n \n\n " - "\n\n \n\n " - " \n\n \n\n " - "\n\n " + "
Hi there,
\n " - "The API usage for Test Org has reached\n " - "90% within the current subscription period.\n " - "Please consider upgrading your organisation's account limits.\n" - "
Thank you!
The Flagsmith Team
\n\n \n\n \n\n \n\n \n\n " + " \n\n" + "\n \n\n \n\n \n\n \n\n \n\n " + " \n\n " "\n\n
Hi " + "there,
\n The API usage for Test " + "Org has reached\n 90% within the current " + "subscription period.\n Please consider " + "upgrading your organisation's account limits.\n " + " \n Please note that once the 100%" + " use has been breached automated charges for your account " + "may apply.\n \n\n
" + "Thank you!
The Flagsmith Team
\n" ) @@ -387,6 +392,7 @@ def test_handle_api_usage_notifications_above_100( # Given now = timezone.now() organisation.subscription.plan = SCALE_UP + organisation.subscription.subscription_id = "fancy_id" organisation.subscription.save() OrganisationSubscriptionInformationCache.objects.create( organisation=organisation, @@ -421,11 +427,10 @@ def test_handle_api_usage_notifications_above_100( email = mailoutbox[0] assert email.subject == "Flagsmith API use has reached 100%" assert email.body == ( - "Hi there,\n\nThe API usage for Test Org has breached " - "100% within the current subscription period. Please " - "upgrade your organisation's account to ensure " - "continued service.\n\nThank you!\n\n" - "The Flagsmith Team\n" + "Hi there,\n\nThe API usage for Test Org has breached 100% " + "within the current subscription period.\n\n\nPlease note " + "that automated charges for your account may apply.\n\n\n" + "Thank you!\n\nThe Flagsmith Team\n" ) assert len(email.alternatives) == 1 @@ -433,17 +438,16 @@ def test_handle_api_usage_notifications_above_100( assert email.alternatives[0][1] == "text/html" assert email.alternatives[0][0] == ( - "\n\n \n\n \n\n \n\n \n\n " - " \n\n\n " - " \n\n \n\n \n\n \n\n \n\n" - " \n\n " - "\n\n
Hi " - "there,
\n The API usage for Test Org " - "has breached\n 100% within the " - "current subscription period.\n " - "Please upgrade your organisation's account to ensure " - "continued service.\n
" - "Thank you!
The Flagsmith Team
\n" + "\n\n \n\n \n\n \n\n \n\n \n\n\n \n\n " + "\n\n \n\n " + "\n\n \n\n \n\n \n\n
Hi there," + "
" + "\n The API usage for Test Org has breached" + "\n 100% within the current subscription period." + "\n \n Please note that " + "automated charges for your account may apply.\n " + "\n
Thank you!
The Flagsmith " + "Team
\n" ) assert email.from_email == "noreply@flagsmith.com" @@ -482,7 +486,8 @@ def test_handle_api_usage_notifications_for_free_accounts( mailoutbox: list[EmailMultiAlternatives], ) -> None: # Given - assert organisation.subscription.is_free_plan + assert organisation.is_paid is False + assert organisation.subscription.is_free_plan is True assert organisation.subscription.max_api_calls == MAX_API_CALLS_IN_FREE_PLAN mock_api_usage = mocker.patch( @@ -510,10 +515,11 @@ def test_handle_api_usage_notifications_for_free_accounts( assert email.subject == "Flagsmith API use has reached 100%" assert email.body == ( "Hi there,\n\nThe API usage for Test Org has breached " - "100% within the current subscription period. Please " - "upgrade your organisation's account to ensure " - "continued service.\n\nThank you!\n\n" - "The Flagsmith Team\n" + "100% within the current subscription period.\n\n\nPlease " + "note that the serving of feature flags and admin access " + "may be disabled after a grace period, so please upgrade " + "your organisation's account to ensure continued service." + "\n\n\nThank you!\n\nThe Flagsmith Team\n" ) assert len(email.alternatives) == 1 @@ -521,17 +527,19 @@ def test_handle_api_usage_notifications_for_free_accounts( assert email.alternatives[0][1] == "text/html" assert email.alternatives[0][0] == ( - "\n\n \n\n \n\n \n\n \n\n " - " \n\n\n " - " \n\n \n\n \n\n \n\n \n\n" - " \n\n " - "\n\n
Hi " - "there,
\n The API usage for Test Org " - "has breached\n 100% within the " - "current subscription period.\n " - "Please upgrade your organisation's account to ensure " - "continued service.\n
" - "Thank you!
The Flagsmith Team
\n" + "\n\n \n\n \n\n \n\n \n\n " + " \n\n\n \n\n \n\n " + " \n\n \n\n " + "\n\n " + "\n\n \n\n
Hi there," + "
\n The API usage for Test Org has" + " breached\n 100% within the current " + "subscription period.\n \n " + " Please note that the serving of feature flags and " + "admin access may be disabled after a grace period, so " + "please upgrade your organisation's account to ensure " + "continued service.\n \n " + "
Thank you!
The Flagsmith Team
\n" ) assert email.from_email == "noreply@flagsmith.com"