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)
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