Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async team deletion with email #1169

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

stephherbers
Copy link
Contributor

Description

first part of this ticket: #1097

Please especially provide feedback on email wording and other things that are helpful to add for context in the email

User Impact

All teams admins will receive emails and it will be more clear to the deletee when the team is actually finished deleted rather than seemingly instant

Demo

Docs and Changelog

will add 👍

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files

📢 Thoughts on this report? Let us know!

Copy link
Collaborator

@snopoke snopoke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few small comments but looks good

apps/utils/deletion.py Outdated Show resolved Hide resolved
@@ -548,6 +548,7 @@
"account_reset_password_from_key",
"teams:signup_after_invite",
"account_login",
"single_team:delete_team",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this necessary?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

templates/teams/email/domain_deleted_notification.html Outdated Show resolved Hide resolved
templates/teams/email/domain_deleted_notification.txt Outdated Show resolved Hide resolved
apps/utils/deletion.py Outdated Show resolved Hide resolved
@@ -218,3 +222,27 @@ def get_related_pipelines_queryset(instance, pipeline_param_key: str = None):
Q(**{f"params__{pipeline_param_key}": instance.id}) | Q(**{f"params__{pipeline_param_key}": str(instance.id)})
)
return pipelines


def get_admin_emails(team):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good candidate for a test


# get required info for emails prior to deleting team info
team_name = team.name
admin_emails = get_admin_emails_with_delete_permission(team)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should all users maybe be notified instead of only those that can delete the team? It might be a bit surprising for someone to find their team is gone. Probably an edge case, but still

@SmittieC
Copy link
Collaborator

I realize you are still busy with this PR, but just flagging that we are not removing assistants from OpenAI yet? A test for delete_team_async might also be a good idea to check that 1. assistants are removed from OpenAI and 2. that any archived objects are also removed. I think number 2 is being done already, but might be good to test..up to you


@pytest.mark.django_db()
def test_get_admin_emails_can_delete_team(team_with_users):
set_current_team(team_with_users)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use the current_team context manager to ensure that it is unset


@shared_task
def delete_team_async(team_id):
team = Team.objects.get(id=team_id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use with current_team(team) to set the team for auditing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants