diff options
author | Alban Gruin | 2017-02-28 13:21:24 +0100 |
---|---|---|
committer | Alban Gruin | 2017-02-28 13:21:24 +0100 |
commit | 2ca125053e753482d13f40da3c602c964b215626 (patch) | |
tree | e5ff6e1a1a7d37c3e1d0ef6a360cf5f92959c4c3 /management | |
parent | 1718988d65a9601a8d2d953da6c1fedc57a6a18c (diff) |
Modification de la gestion de la transaction dans la commande cleancourses
Diffstat (limited to 'management')
-rw-r--r-- | management/commands/cleancourses.py | 18 |
1 files 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.")) |