aboutsummaryrefslogtreecommitdiff
path: root/management/commands
diff options
context:
space:
mode:
authorAlban Gruin2017-11-27 17:18:41 +0100
committerAlban Gruin2017-11-27 17:18:41 +0100
commita5b0d082a728b06e5e02f4d64632ac0b0a572aec (patch)
tree7ad6449000f57b2baa021ad1e8c7f1898c2e55fe /management/commands
parent90414449f9f74b675d3793c2c48a796f9bfe4b29 (diff)
Adaptation des commandes cleancourses et listtimetables au changements
Diffstat (limited to 'management/commands')
-rw-r--r--management/commands/cleancourses.py8
-rw-r--r--management/commands/listtimetables.py13
2 files changed, 10 insertions, 11 deletions
diff --git a/management/commands/cleancourses.py b/management/commands/cleancourses.py
index f6041ef..310c843 100644
--- a/management/commands/cleancourses.py
+++ b/management/commands/cleancourses.py
@@ -22,15 +22,15 @@ 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."))
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 <http://www.gnu.org/licenses/>.
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."))