From e5d075978ef65f60e96dad9c2934464dcbc0d380 Mon Sep 17 00:00:00 2001 From: Rohan Moniz <60864468+rm03@users.noreply.github.com> Date: Fri, 27 Sep 2024 20:55:13 -0400 Subject: [PATCH] move grad_users script to cronjob --- backend/clubs/management/commands/graduate_users.py | 1 - backend/tests/clubs/test_views.py | 2 +- k8s/main.ts | 7 +++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/clubs/management/commands/graduate_users.py b/backend/clubs/management/commands/graduate_users.py index bf61ca50d..d6e000f63 100644 --- a/backend/clubs/management/commands/graduate_users.py +++ b/backend/clubs/management/commands/graduate_users.py @@ -9,7 +9,6 @@ class Command(BaseCommand): "Mark all memberships where the student has graduated as inactive. " "This script should be run at the beginning of each year." ) - web_execute = True def handle(self, *args, **kwargs): now = timezone.now() diff --git a/backend/tests/clubs/test_views.py b/backend/tests/clubs/test_views.py index fe55fa5ba..564bcdc70 100644 --- a/backend/tests/clubs/test_views.py +++ b/backend/tests/clubs/test_views.py @@ -2600,7 +2600,7 @@ def test_execute_script(self): self.assertIn(resp.status_code, [200], resp.content) self.assertIsInstance(resp.data, list, resp.content) - resp = self.client.post(reverse("scripts"), {"action": "graduate_users"}) + resp = self.client.post(reverse("scripts"), {"action": "find_broken_images"}) self.assertIn(resp.status_code, [200], resp.content) self.assertIn("output", resp.data, resp.content) diff --git a/k8s/main.ts b/k8s/main.ts index 086779086..1a592a5f7 100644 --- a/k8s/main.ts +++ b/k8s/main.ts @@ -95,6 +95,13 @@ export class MyChart extends PennLabsChart { secret: clubsSecret, cmd: ["python", "manage.py", "expire_membership_invites"], }); + + new CronJob(this, 'graduate-users', { + schedule: cronTime.everyYearIn(1, 1, 12, 0), + image: backendImage, + secret: clubsSecret, + cmd: ["python", "manage.py", "graduate_users"], + }); } }