From 77a4b75431cfab7348db73b563dd005ce64be14a Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 28 Jan 2018 11:14:34 +0100 Subject: Changements dans le formatage du code pour le rendre plus lisible --- admin.py | 6 ++++-- management/commands/listtimetables.py | 7 +++---- management/commands/timetables.py | 6 +++--- models.py | 9 +++++---- tests.py | 7 +++---- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/admin.py b/admin.py index dcac794..def84f0 100644 --- a/admin.py +++ b/admin.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 @@ -19,11 +19,13 @@ from .models import Course, Group, Room, Source, Timetable, Year def make_hidden(modeladmin, request, queryset): queryset.update(hidden=True) -make_hidden.short_description = "Cacher les groupes sélectionnés" def make_visible(modeladmin, request, queryset): queryset.update(hidden=False) + + +make_hidden.short_description = "Cacher les groupes sélectionnés" make_visible.short_description = "Afficher les groupes sélectionnés" diff --git a/management/commands/listtimetables.py b/management/commands/listtimetables.py index 7892855..a3ef223 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 @@ -29,9 +29,8 @@ class Command(BaseCommand): sources = sources.order_by("id") for source in sources: - self.stdout.write("{0}\t: {1} (id: {2})" - .format(source.formatted_timetables, - source, source.id)) + 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.")) diff --git a/management/commands/timetables.py b/management/commands/timetables.py index cf48af6..2c299de 100644 --- a/management/commands/timetables.py +++ b/management/commands/timetables.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 @@ -58,8 +58,8 @@ def process_timetable_week(source, soup, weeks_in_soup, force, # traitement et la fin de la semaine last_update_date = last_update_date.filter(begin__lt=end) - last_update_date = last_update_date \ - .aggregate(Min("last_update"))["last_update__min"] + last_update_date = last_update_date.aggregate( + Min("last_update"))["last_update__min"] # Date de mise à jour de Celcat, utilisée à des fins de statistiques new_update_date = get_update_date(soup) diff --git a/models.py b/models.py index ba4ebaf..b762215 100644 --- a/models.py +++ b/models.py @@ -195,11 +195,12 @@ class CourseManager(Manager): def get_courses(self, obj, **criteria): qs = self.get_queryset() if isinstance(obj, Group): - qs = qs.filter(groups__in=Group.objects.get_parents(obj), - **criteria).prefetch_related("rooms") + qs = qs.filter( + groups__in=Group.objects.get_parents(obj), **criteria) \ + .prefetch_related("rooms") elif isinstance(obj, Room): - qs = qs.filter(rooms=obj, **criteria).prefetch_related("rooms", - "groups") + qs = qs.filter(rooms=obj, **criteria) \ + .prefetch_related("rooms", "groups") else: raise(TypeError, "obj must be a Group or a Room") diff --git a/tests.py b/tests.py index d19203e..13c8725 100644 --- a/tests.py +++ b/tests.py @@ -49,10 +49,9 @@ class CourseTestCase(TestCase): source=source) for group in (cma, tda2, self.tpa21, cmb, tdb2, self.tpb21,): - course = Course.objects.create(name="{0} course" - .format(group.name), - type="cours", source=source, - begin=dt, end=dt) + course = Course.objects.create( + name="{0} course".format(group.name), type="cours", + source=source, begin=dt, end=dt) course.groups.add(group) def test_get_courses_for_group(self): -- cgit v1.2.1