From: Guillaume Pellerin Date: Tue, 22 Jun 2021 11:59:58 +0000 (+0200) Subject: full annotation delete X-Git-Tag: 2.1~66^2^2~11^2~1 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=ada8ce9ffc23fb7c9f6855929023fdd3dfa0c507;p=teleforma.git full annotation delete --- diff --git a/teleforma/management/commands/teleforma-delete-annotations.py b/teleforma/management/commands/teleforma-delete-annotations.py index 81088ce6..47eede5f 100644 --- a/teleforma/management/commands/teleforma-delete-annotations.py +++ b/teleforma/management/commands/teleforma-delete-annotations.py @@ -13,7 +13,7 @@ class Command(BaseCommand): help = "Delete script annotations from previous year" def handle(self, *args, **options): - date = datetime.datetime.now() + date_now = datetime.datetime.now() date_old = date_now.replace(year=date_now.year-1, month=12, day=31) print(date_old) scripts = Script.objects.filter(date_submitted__lte=date_old) @@ -28,4 +28,13 @@ class Command(BaseCommand): annotation_comment.delete() script.delete() + scripts = Script.objects.all() + for annotation_comment in AnnotationComment.objects.all(): + if not scripts.objects.filter(uuid=annotation_comment.uuid): + annotation_comment.delete() + for annotation in Annotation.objects.all(): + if not scripts.objects.filter(uuid=annotation.uuid): + annotation.delete() + + \ No newline at end of file