aboutsummaryrefslogtreecommitdiff
path: root/management/commands/cleancourses.py
diff options
context:
space:
mode:
authorAlban Gruin2017-02-28 13:21:24 +0100
committerAlban Gruin2017-02-28 13:21:24 +0100
commit2ca125053e753482d13f40da3c602c964b215626 (patch)
treee5ff6e1a1a7d37c3e1d0ef6a360cf5f92959c4c3 /management/commands/cleancourses.py
parent1718988d65a9601a8d2d953da6c1fedc57a6a18c (diff)
Modification de la gestion de la transaction dans la commande cleancourses
Diffstat (limited to 'management/commands/cleancourses.py')
-rw-r--r--management/commands/cleancourses.py18
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."))