Skip to content

Commit

Permalink
Remove unnecessary email alert for cancelled organisations
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewelwell committed Aug 20, 2024
1 parent 3f561ee commit a54ad77
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 44 deletions.
12 changes: 0 additions & 12 deletions api/organisations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 0 additions & 11 deletions api/organisations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down
21 changes: 0 additions & 21 deletions api/tests/unit/organisations/test_unit_organisations_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a54ad77

Please sign in to comment.