From: Guillaume Pellerin Date: Mon, 12 Jan 2026 09:59:44 +0000 (+0100) Subject: add scripts cleanup script X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=0b949b430da25ca0f27aa026fd6dca3d757c99b3;p=teleforma.git add scripts cleanup script --- 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()