From a54ad77206d5ecdf91a634cb99f09c1af5f26a5d Mon Sep 17 00:00:00 2001 From: Matthew Elwell Date: Tue, 20 Aug 2024 14:52:14 +0100 Subject: [PATCH] Remove unnecessary email alert for cancelled organisations --- api/organisations/models.py | 12 ----------- api/organisations/tasks.py | 11 ---------- .../test_unit_organisations_tasks.py | 21 ------------------- 3 files changed, 44 deletions(-) diff --git a/api/organisations/models.py b/api/organisations/models.py index 4665ad668742a..8b995d824d58f 100644 --- a/api/organisations/models.py +++ b/api/organisations/models.py @@ -315,21 +315,9 @@ def prepare_for_cancel( If cancellation_date is in the future some aspects are reserved for a task after the date has passed. """ - # Avoid circular import. - from organisations.tasks import send_org_subscription_cancelled_alert - if self.payment_method == CHARGEBEE and update_chargebee: cancel_chargebee_subscription(self.subscription_id) - send_org_subscription_cancelled_alert.delay( - kwargs={ - "organisation_name": self.organisation.name, - "formatted_cancellation_date": cancellation_date.strftime( - "%Y-%m-%d %H:%M:%S" - ), - } - ) - if cancellation_date <= timezone.now(): # Since the date is immediate, wipe data right away. self.organisation.cancel_users() diff --git a/api/organisations/tasks.py b/api/organisations/tasks.py index 0b3b9267f7c23..6ce500362616e 100644 --- a/api/organisations/tasks.py +++ b/api/organisations/tasks.py @@ -68,17 +68,6 @@ def send_org_over_limit_alert(organisation_id: int) -> None: ) -@register_task_handler() -def send_org_subscription_cancelled_alert( - organisation_name: str, - formatted_cancellation_date: str, -) -> None: - FFAdminUser.send_alert_to_admin_users( - subject=f"Organisation {organisation_name} has cancelled their subscription", - message=f"Organisation {organisation_name} has cancelled their subscription on {formatted_cancellation_date}", - ) - - @register_recurring_task( run_every=timedelta(hours=6), ) diff --git a/api/tests/unit/organisations/test_unit_organisations_tasks.py b/api/tests/unit/organisations/test_unit_organisations_tasks.py index 6b0d6231c747a..df4add498df7d 100644 --- a/api/tests/unit/organisations/test_unit_organisations_tasks.py +++ b/api/tests/unit/organisations/test_unit_organisations_tasks.py @@ -46,7 +46,6 @@ register_recurring_tasks, restrict_use_due_to_api_limit_grace_period_over, send_org_over_limit_alert, - send_org_subscription_cancelled_alert, unrestrict_after_api_limit_grace_period_is_stale, ) from users.models import FFAdminUser @@ -253,26 +252,6 @@ def test_finish_subscription_cancellation(db: None, mocker: MockerFixture) -> No assert organisation4.num_seats == organisation_user_count -def test_send_org_subscription_cancelled_alert(db: None, mocker: MockerFixture) -> None: - # Given - send_mail_mock = mocker.patch("users.models.send_mail") - - # When - send_org_subscription_cancelled_alert( - organisation_name="TestCorp", - formatted_cancellation_date="2023-02-08 09:12:34", - ) - - # Then - send_mail_mock.assert_called_once_with( - subject="Organisation TestCorp has cancelled their subscription", - message="Organisation TestCorp has cancelled their subscription on 2023-02-08 09:12:34", - from_email="noreply@flagsmith.com", - recipient_list=[], - fail_silently=True, - ) - - def test_handle_api_usage_notification_for_organisation_when_billing_starts_at_is_none( organisation: Organisation, inspecting_handler: logging.Handler,