From 2ca125053e753482d13f40da3c602c964b215626 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Tue, 28 Feb 2017 13:21:24 +0100 Subject: Modification de la gestion de la transaction dans la commande cleancourses --- management/commands/cleancourses.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/management/commands/cleancourses.py b/management/commands/cleancourses.py index bc14893..8bb1b97 100644 --- a/management/commands/cleancourses.py +++ b/management/commands/cleancourses.py @@ -25,15 +25,15 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument("--timetable", type=int, nargs="+") - @transaction.atomic def handle(self, *args, **options): - if options["timetable"] is None: - Course.objects.all().delete() - Group.objects.all().delete() - LastUpdate.objects.all().delete() - else: - Course.objects.filter(timetable__id__in=options["timetable"]).delete() - Group.objects.filter(timetable__id__in=options["timetable"]).delete() - LastUpdate.objects.filter(timetable__id__in=options["timetable"]).delete() + with transaction.atomic: + if options["timetable"] is None: + Course.objects.all().delete() + Group.objects.all().delete() + LastUpdate.objects.all().delete() + else: + Course.objects.filter(timetable__id__in=options["timetable"]).delete() + Group.objects.filter(timetable__id__in=options["timetable"]).delete() + LastUpdate.objects.filter(timetable__id__in=options["timetable"]).delete() self.stdout.write(self.style.SUCCESS("Done.")) -- cgit v1.2.1