From f91316bfe6f16e7c048aa9ee7dd3c0921b8f9b44 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 12 Jan 2026 10:49:17 +0100 Subject: [PATCH] add CORS_ALLOWED_ORIGINS --- app/settings.py | 2 +- teleforma/exam/models.py | 4 ++++ .../commands/teleforma-cleanup-private-documents.py | 9 ++++++--- teleforma/models/core.py | 4 ++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/settings.py b/app/settings.py index 9df575d1..ac823019 100644 --- a/app/settings.py +++ b/app/settings.py @@ -677,7 +677,7 @@ BBB_BANNER_COLOR = "#003768" ######################## CORS_ALLOWED_ORIGINS = [ - "", + "https://e-learning.pre-barreau.com", ] CORS_ALLOW_ALL_ORIGINS = False diff --git a/teleforma/exam/models.py b/teleforma/exam/models.py index baf8b304..f6948459 100755 --- a/teleforma/exam/models.py +++ b/teleforma/exam/models.py @@ -383,6 +383,10 @@ class Script(BaseResource): def update(self, *args, **kwargs): super(Script, self).save(*args, **kwargs) + def delete(self): + self.file.delete(save=False) + super().delete() + def uuid_link(self): old_abs = self.file.path old_abs_list = old_abs.split(os.sep) diff --git a/teleforma/management/commands/teleforma-cleanup-private-documents.py b/teleforma/management/commands/teleforma-cleanup-private-documents.py index 20731066..8dd8f2ce 100644 --- a/teleforma/management/commands/teleforma-cleanup-private-documents.py +++ b/teleforma/management/commands/teleforma-cleanup-private-documents.py @@ -1,10 +1,13 @@ from django.core.management.base import BaseCommand -from teleforma.models import * +from teleforma.models import DocumentPrivate +from datetime import datetime, timedelta class Command(BaseCommand): - help = "Delete all private documents" + help = "Delete all private documents older than a number of days" def handle(self, *args, **options): - for document in DocumentPrivate.objects.all(): + days = args[0] + date_limit = datetime.today() - timedelta(days=days) + for document in DocumentPrivate.objects.filter(date_added__lte=date_limit): document.delete() diff --git a/teleforma/models/core.py b/teleforma/models/core.py index dc30244f..1da7abae 100644 --- a/teleforma/models/core.py +++ b/teleforma/models/core.py @@ -901,6 +901,10 @@ class DocumentPrivate(MediaBase): temp_file.close() del temp_file + def delete(self): + self.file.delete(save=False) + super().delete() + class DocumentSimple(MediaBase): -- 2.39.5