From 0b949b430da25ca0f27aa026fd6dca3d757c99b3 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 12 Jan 2026 10:59:44 +0100 Subject: [PATCH] add scripts cleanup script --- .../commands/teleforma-cleanup-scripts.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 teleforma/management/commands/teleforma-cleanup-scripts.py diff --git a/teleforma/management/commands/teleforma-cleanup-scripts.py b/teleforma/management/commands/teleforma-cleanup-scripts.py new file mode 100644 index 00000000..3e4ddc9d --- /dev/null +++ b/teleforma/management/commands/teleforma-cleanup-scripts.py @@ -0,0 +1,13 @@ +from django.core.management.base import BaseCommand +from teleforma.exam.models import Script +from datetime import datetime, timedelta + + +class Command(BaseCommand): + help = "Delete all exam scripts older than a number of days" + + def handle(self, *args, **options): + days = args[0] + date_limit = datetime.today() - timedelta(days=days) + for script in Script.objects.filter(date_added__lte=date_limit): + script.delete() -- 2.39.5