aboutsummaryrefslogtreecommitdiff
path: root/management/commands
diff options
context:
space:
mode:
Diffstat (limited to 'management/commands')
-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."))