]> git.parisson.com Git - teleforma.git/commitdiff
full annotation delete
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 22 Jun 2021 11:59:58 +0000 (13:59 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 22 Jun 2021 11:59:58 +0000 (13:59 +0200)
teleforma/management/commands/teleforma-delete-annotations.py

index 81088ce6ee8dcc4d9539b1c624fcd5cd9fed767c..47eede5f5961e2fa67cc16657f60e617b75b7773 100644 (file)
@@ -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