diff options
author | Alban Gruin | 2018-04-23 16:20:38 +0200 |
---|---|---|
committer | Alban Gruin | 2018-04-23 16:20:38 +0200 |
commit | 63ceb7ff232cd4015ae148bec31c6d72d9239c19 (patch) | |
tree | 9aee056480b5fae0c97f5e1c8be4ab1358602926 /management/commands/cleancourses.py | |
parent | af055dbf703af0eca03862194de1a0f34ac1fcc5 (diff) | |
parent | 9853d375d9e482c23f5fdbed9a3cf041029a92cb (diff) |
Merge branch 'qsjps' into futur
Diffstat (limited to 'management/commands/cleancourses.py')
-rw-r--r-- | management/commands/cleancourses.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/management/commands/cleancourses.py b/management/commands/cleancourses.py index f6041ef..246cfcc 100644 --- a/management/commands/cleancourses.py +++ b/management/commands/cleancourses.py @@ -15,22 +15,24 @@ from django.core.management.base import BaseCommand from django.db import transaction -from edt.models import Course, Group + +from ...models import Course, Group class Command(BaseCommand): help = "Remove all courses and groups from the database" def add_arguments(self, parser): - parser.add_argument("--timetable", type=int, nargs="+") + parser.add_argument("--source", type=int, nargs="+") def handle(self, *args, **options): with transaction.atomic(): - if options["timetable"] is None: + if options["source"] is None: Course.objects.all().delete() Group.objects.all().delete() else: - Course.objects.filter(timetable__id__in=options["timetable"]).delete() - Group.objects.filter(timetable__id__in=options["timetable"]).delete() + Course.objects.filter(source__id__in=options["source"]) \ + .delete() + Group.objects.filter(source__id__in=options["source"]).delete() self.stdout.write(self.style.SUCCESS("Done.")) |