From a5b0d082a728b06e5e02f4d64632ac0b0a572aec Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Mon, 27 Nov 2017 17:18:41 +0100 Subject: Adaptation des commandes cleancourses et listtimetables au changements --- management/commands/listtimetables.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'management/commands/listtimetables.py') diff --git a/management/commands/listtimetables.py b/management/commands/listtimetables.py index 6df7ba5..171fc2b 100644 --- a/management/commands/listtimetables.py +++ b/management/commands/listtimetables.py @@ -14,7 +14,7 @@ # along with celcatsanitizer. If not, see . from django.core.management.base import BaseCommand -from edt.models import Timetable +from edt.models import Source class Command(BaseCommand): @@ -24,14 +24,13 @@ class Command(BaseCommand): parser.add_argument("--order-by-id", action="store_true") def handle(self, *args, **options): - timetables = Timetable.objects.all() + sources = Source.objects.all() if options["order_by_id"]: - timetables = timetables.order_by("id") - else: - timetables = timetables.order_by("year__name", "name") + sources = sources.order_by("id") - for timetable in timetables: - self.stdout.write("{0} (id: {1})".format(timetable, timetable.id)) + for source in sources: + self.stdout.write("{0}\t: {1} (id: {2})".format(", ".join([str(timetable) for timetable in source.timetables.all()]), + source, source.id)) self.stdout.write("") self.stdout.write(self.style.SUCCESS("Done.")) -- cgit v1.2.1