aboutsummaryrefslogtreecommitdiff
path: root/management/commands/listtimetables.py
diff options
context:
space:
mode:
authorAlban Gruin2018-04-23 16:20:38 +0200
committerAlban Gruin2018-04-23 16:20:38 +0200
commit63ceb7ff232cd4015ae148bec31c6d72d9239c19 (patch)
tree9aee056480b5fae0c97f5e1c8be4ab1358602926 /management/commands/listtimetables.py
parentaf055dbf703af0eca03862194de1a0f34ac1fcc5 (diff)
parent9853d375d9e482c23f5fdbed9a3cf041029a92cb (diff)
Merge branch 'qsjps' into futur
Diffstat (limited to 'management/commands/listtimetables.py')
-rw-r--r--management/commands/listtimetables.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/management/commands/listtimetables.py b/management/commands/listtimetables.py
index 6df7ba5..bd27e92 100644
--- a/management/commands/listtimetables.py
+++ b/management/commands/listtimetables.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2017 Alban Gruin
+# Copyright (C) 2017-2018 Alban Gruin
#
# celcatsanitizer is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
@@ -14,24 +14,18 @@
# along with celcatsanitizer. If not, see <http://www.gnu.org/licenses/>.
from django.core.management.base import BaseCommand
-from edt.models import Timetable
+from ...models import Source
class Command(BaseCommand):
help = "List timetables in the database"
- def add_arguments(self, parser):
- parser.add_argument("--order-by-id", action="store_true")
-
def handle(self, *args, **options):
- timetables = Timetable.objects.all()
- if options["order_by_id"]:
- timetables = timetables.order_by("id")
- else:
- timetables = timetables.order_by("year__name", "name")
+ sources = Source.objects.all()
- 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(
+ source.formatted_timetables, source, source.id))
self.stdout.write("")
self.stdout.write(self.style.SUCCESS("Done."))