From 9f86eeed1eadb0e6c6fdc97fba1b7b0c55d3a284 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 26 Mar 2017 15:54:55 +0200 Subject: Oui --- management/commands/listtimetables.py | 1 - 1 file changed, 1 deletion(-) (limited to 'management/commands') diff --git a/management/commands/listtimetables.py b/management/commands/listtimetables.py index c5ef41f..e4b782f 100644 --- a/management/commands/listtimetables.py +++ b/management/commands/listtimetables.py @@ -27,7 +27,6 @@ class Command(BaseCommand): def handle(self, *args, **options): timetables = Timetable.objects.all() if options["order_by_id"]: - print("oui") timetables = timetables.order_by("id") else: timetables = timetables.order_by("name") -- cgit v1.2.1 From df8f43e5af448a7d635e762e15ff906ab76565f1 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 26 Mar 2017 17:50:14 +0200 Subject: Affichage d'un compteur d'erreurs de traitement --- management/commands/timetables.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'management/commands') diff --git a/management/commands/timetables.py b/management/commands/timetables.py index d39075d..d596233 100644 --- a/management/commands/timetables.py +++ b/management/commands/timetables.py @@ -64,6 +64,8 @@ class Command(BaseCommand): def handle(self, *args, **options): year = None + errcount = 0 + if options["week"] is None: _, week, day = timezone.now().isocalendar() if day >= 6: @@ -84,5 +86,9 @@ class Command(BaseCommand): process_timetable(timetable, year, weeks) except Exception as e: self.stderr.write(self.style.ERROR("Failed to process {0}: {1}".format(timetable, e))) + errcount += 1 - self.stdout.write(self.style.SUCCESS("Done.")) + if errcount == 0: + self.stdout.write(self.style.SUCCESS("Done.")) + else: + self.stdout.write(self.style.ERROR("Done with {0} errors.".format(errcount))) -- cgit v1.2.1 From 276158c7813cb75df3ea433d3b8543bdf5c7b7d3 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Mon, 4 Sep 2017 21:42:25 +0200 Subject: On trouve le parent de chaque groupe à sa création par le parseur d’emploi du temps, et pas autre part. Si jamais le parent est déjà connu, on ignore cette étape. --- management/commands/_private.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'management/commands') diff --git a/management/commands/_private.py b/management/commands/_private.py index 3cd23ca..dec13cd 100644 --- a/management/commands/_private.py +++ b/management/commands/_private.py @@ -41,6 +41,27 @@ def add_time(date, time): delta = datetime.timedelta(hours=time.hour, minutes=time.minute) return date + delta +def consolidate_group(group): + group_content_key = ("mention", "subgroup", "td", "tp") + group_content_list = group.group_info[1:] + group_content = dict(zip(group_content_key, group_content_list)) + + for i in range(len(group_content_list))[::-1]: + del group_content[group_content_key[i]] + group_content[group_content_key[i] + "__isnull"] = True + + if group_content_list[i] is not None: + break + + if "subgroup" in group_content: + group.parent_group = Group.objects.filter(**group_content).first() + group.save() + +def consolidate_groups(groups): + for group in groups: + if group.parent_group == None: + consolidate_group(group) + def delete_courses_in_week(timetable, year, week): start, end = get_week(year, week) Course.objects.filter(begin__gte=start, begin__lt=end, @@ -79,6 +100,7 @@ def get_events(timetable, year, week, soup, weeks_in_soup): groups = [get_from_db_or_create(Group, timetable=timetable, celcat_name=item.text) for item in event.resources.group.find_all("item")] + consolidate_groups(groups) if event.notes is not None: notes = event.notes.text -- cgit v1.2.1 From 8526c4588d88e98f59611771dbc0ca34c1b66d66 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Mon, 4 Sep 2017 21:43:40 +0200 Subject: Rennomage de parent_group en parent. --- management/commands/_private.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'management/commands') diff --git a/management/commands/_private.py b/management/commands/_private.py index dec13cd..c31eb34 100644 --- a/management/commands/_private.py +++ b/management/commands/_private.py @@ -54,12 +54,12 @@ def consolidate_group(group): break if "subgroup" in group_content: - group.parent_group = Group.objects.filter(**group_content).first() + group.parent = Group.objects.filter(**group_content).first() group.save() def consolidate_groups(groups): for group in groups: - if group.parent_group == None: + if group.parent == None: consolidate_group(group) def delete_courses_in_week(timetable, year, week): -- cgit v1.2.1