diff --git a/breathecode/assignments/management/commands/send_deletion_order_notifications.py b/breathecode/assignments/management/commands/send_deletion_order_notifications.py index 2cb65f25e..ceb3ffb5e 100644 --- a/breathecode/assignments/management/commands/send_deletion_order_notifications.py +++ b/breathecode/assignments/management/commands/send_deletion_order_notifications.py @@ -18,6 +18,7 @@ def handle(self, *args, **options): def github(self): ids = [] + allowed_users = ["breatheco-de", "4GeeksAcademy", "4geeksacademy"] processed = set() for settings in AcademyAuthSettings.objects.filter( github_owner__isnull=False, github_owner__credentialsgithub__isnull=False @@ -31,13 +32,13 @@ def github(self): continue processed.add(key) - allowed_users = ["breatheco-de", "4GeeksAcademy", "4geeksacademy"] while True: items = RepositoryDeletionOrder.objects.filter( provider=RepositoryDeletionOrder.Provider.GITHUB, notified_at=None, status=RepositoryDeletionOrder.Status.TRANSFERRING, + repository_user__in=allowed_users, ).exclude(id__in=ids)[:100] if len(items) == 0: @@ -45,8 +46,6 @@ def github(self): for deletion_order in items: ids.append(deletion_order.id) - if deletion_order.repository_user not in allowed_users: - continue if deletion_order.repository_name.endswith(".git"): deletion_order.repository_name = deletion_order.repository_name[:-4] diff --git a/breathecode/assignments/tests/management/commands/tests_schedule_repository_deletions.py b/breathecode/assignments/tests/management/commands/tests_schedule_repository_deletions.py index be17f0259..6ea65a9c5 100644 --- a/breathecode/assignments/tests/management/commands/tests_schedule_repository_deletions.py +++ b/breathecode/assignments/tests/management/commands/tests_schedule_repository_deletions.py @@ -505,7 +505,7 @@ def test_one_repo__pending__user_not_found(database: capyc.Database, patch_get, }, { "method": "GET", - "url": f"https://api.github.com/orgs/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30", + "url": f"https://api.github.com/repos/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30", "expected": [], "code": 200, "headers": {}, @@ -598,7 +598,7 @@ def test_one_repo__pending__user_found( }, { "method": "GET", - "url": f"https://api.github.com/orgs/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks-{parsed_name}/events?page=1&per_page=30", + "url": f"https://api.github.com/repos/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks-{parsed_name}/events?page=1&per_page=30", "expected": [event], "code": 200, "headers": {}, @@ -679,7 +679,7 @@ def test_one_repo__pending__user_found__inferred(database: capyc.Database, patch }, { "method": "GET", - "url": f"https://api.github.com/orgs/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30", + "url": f"https://api.github.com/repos/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30", "expected": [event], "code": 200, "headers": {}, diff --git a/breathecode/assignments/tests/management/commands/tests_send_deletion_order_notifications.py b/breathecode/assignments/tests/management/commands/tests_send_deletion_order_notifications.py index 51eaf6ea9..9a05bc6fd 100644 --- a/breathecode/assignments/tests/management/commands/tests_send_deletion_order_notifications.py +++ b/breathecode/assignments/tests/management/commands/tests_send_deletion_order_notifications.py @@ -126,8 +126,9 @@ def test_one_repo__pending__user_found( "provider": "GITHUB", "repository_name": f"curso-nodejs-4geeks-{parsed_name}", "repository_user": github_username, - "status": "PENDING", + "status": "TRANSFERRING", "status_text": None, + "notified_at": None, }, ], ) @@ -137,7 +138,7 @@ def test_one_repo__pending__user_found( [ { "method": "GET", - "url": f"https://api.github.com/orgs/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks-{parsed_name}/events?page=1&per_page=30", + "url": f"https://api.github.com/repos/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks-{parsed_name}/events?page=1&per_page=30", "expected": [event], "code": 200, "headers": {}, @@ -174,8 +175,9 @@ def test_one_repo__pending__user_found__inferred( "provider": "GITHUB", "repository_name": "curso-nodejs-4geeks", "repository_user": github_username, - "status": "PENDING", + "status": "TRANSFERRING", "status_text": None, + "notified_at": None, }, ], ) @@ -185,7 +187,7 @@ def test_one_repo__pending__user_found__inferred( [ { "method": "GET", - "url": f"https://api.github.com/orgs/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30", + "url": f"https://api.github.com/repos/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30", "expected": [event], "code": 200, "headers": {},