From 86efcdcd2df04a59eb5f27212d8d41f60f861f6c Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Thu, 19 Oct 2017 22:48:16 +0200 Subject: Adaptation des vues, correction du critère de sélection des groupes --- views.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'views.py') diff --git a/views.py b/views.py index 2100972..e5c89a2 100644 --- a/views.py +++ b/views.py @@ -39,13 +39,12 @@ def group_list_common(request, timetable, groups): groups_weeks = Course.objects.get_weeks(begin__gte=start, begin__lt=end, timetable=timetable) \ .values("groups__mention", "groups__subgroup", - "groups__td", "groups__tp", "year", "week") + "year", "week") for group in groups: for group_week in groups_weeks: if group.corresponds_to(timetable.id, group_week["groups__mention"], - group_week["groups__subgroup"], group_week["groups__td"], - group_week["groups__tp"]): + group_week["groups__subgroup"]): if not hasattr(group, "weeks"): group.weeks = [] @@ -60,7 +59,7 @@ def group_list_common(request, timetable, groups): def group_list(request, year_slug, timetable_slug): timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug) - groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name") + groups = Group.objects.filter(timetable=timetable).order_by("name") return group_list_common(request, timetable, groups) def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=None): @@ -78,8 +77,8 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug) group = get_object_or_404(Group, slug=group_slug, timetable=timetable) - if group.children.count(): - return group_list_common(request, timetable, Group.objects.get_relevant_children(group)) + # if group.children.count(): + # return group_list_common(request, timetable, Group.objects.get_relevant_children(group)) courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) if courses.count() == 0 and provided_week: -- cgit v1.2.1 From b7773b892ee68209feb33870496985f78243681a Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Fri, 20 Oct 2017 13:29:07 +0200 Subject: Modification de la requête qui sélectionne les groupes pertinents. --- views.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'views.py') diff --git a/views.py b/views.py index e5c89a2..9c38524 100644 --- a/views.py +++ b/views.py @@ -59,7 +59,7 @@ def group_list_common(request, timetable, groups): def group_list(request, year_slug, timetable_slug): timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug) - groups = Group.objects.filter(timetable=timetable).order_by("name") + groups = Group.objects.get_relevant_groups(timetable) return group_list_common(request, timetable, groups) def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=None): @@ -77,8 +77,11 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug) group = get_object_or_404(Group, slug=group_slug, timetable=timetable) - # if group.children.count(): - # return group_list_common(request, timetable, Group.objects.get_relevant_children(group)) + if Group.objects.filter(timetable=timetable, mention=group.mention, + subgroup__startswith=group.subgroup).count() > 1: + subgroups = Group.objects.get_relevant_groups(timetable, mention=group.mention, + subgroup__startswith=group.subgroup) + return group_list_common(request, timetable, subgroups) courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) if courses.count() == 0 and provided_week: -- cgit v1.2.1 From 7ef57a0226fa25b8ea5e9a6ff5526889dc300649 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Fri, 27 Oct 2017 21:51:12 +0200 Subject: Ajout d’une page pour lister les calendriers disponibles --- views.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'views.py') diff --git a/views.py b/views.py index 9c38524..76b7127 100644 --- a/views.py +++ b/views.py @@ -17,6 +17,7 @@ import datetime from django.conf import settings from django.db.models import Max +from django.db.models.functions import Length from django.http import Http404 from django.shortcuts import get_object_or_404, render @@ -95,5 +96,19 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No "year": year, "week": int(week), "is_old_timetable": is_old_timetable}) +def calendar_list(request, year_slug, timetable_slug, group_slug): + """Affiche une liste des ICS disponibles pour un groupe.""" + # On commence par récupérer l’emploi du temps associé, puis le groupe + # Si la récupération de l’un d’entre eux échoue, on affiche une erreur 404. + timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug) + group = get_object_or_404(Group, slug=group_slug, timetable=timetable) + + # On récupère les groupes « parents » au groupe spécifié. + groups = Group.objects.get_parents(group).annotate(length=Length("subgroup")) \ + .order_by("length") + + # On réutilise encore la template principale + return render(request, "index.html", {"group": group, "elements": groups}) + def contact(request): return render(request, "contact.html", {"email": settings.ADMINS[0][1]}) -- cgit v1.2.1 From f0790a2420684a39e2b48922beec1245f4446912 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 29 Oct 2017 15:17:03 +0100 Subject: Revert "Ajout d’une page pour lister les calendriers disponibles" This reverts commit 7ef57a0226fa25b8ea5e9a6ff5526889dc300649. --- views.py | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'views.py') diff --git a/views.py b/views.py index 76b7127..9c38524 100644 --- a/views.py +++ b/views.py @@ -17,7 +17,6 @@ import datetime from django.conf import settings from django.db.models import Max -from django.db.models.functions import Length from django.http import Http404 from django.shortcuts import get_object_or_404, render @@ -96,19 +95,5 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No "year": year, "week": int(week), "is_old_timetable": is_old_timetable}) -def calendar_list(request, year_slug, timetable_slug, group_slug): - """Affiche une liste des ICS disponibles pour un groupe.""" - # On commence par récupérer l’emploi du temps associé, puis le groupe - # Si la récupération de l’un d’entre eux échoue, on affiche une erreur 404. - timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug) - group = get_object_or_404(Group, slug=group_slug, timetable=timetable) - - # On récupère les groupes « parents » au groupe spécifié. - groups = Group.objects.get_parents(group).annotate(length=Length("subgroup")) \ - .order_by("length") - - # On réutilise encore la template principale - return render(request, "index.html", {"group": group, "elements": groups}) - def contact(request): return render(request, "contact.html", {"email": settings.ADMINS[0][1]}) -- cgit v1.2.1 From c80a41ffafe3065f35f07b71063b5596d33d0ff2 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 29 Oct 2017 15:37:43 +0100 Subject: Déplacement de tous les liens vers les ICS dans une page spéciale --- views.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'views.py') diff --git a/views.py b/views.py index 9c38524..7c19840 100644 --- a/views.py +++ b/views.py @@ -17,6 +17,7 @@ import datetime from django.conf import settings from django.db.models import Max +from django.db.models.functions import Length from django.http import Http404 from django.shortcuts import get_object_or_404, render @@ -95,5 +96,13 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No "year": year, "week": int(week), "is_old_timetable": is_old_timetable}) +def calendars(request, year_slug, timetable_slug, group_slug): + group = get_object_or_404(Group, timetable__year__slug=year_slug, + timetable__slug=timetable_slug, slug=group_slug) + groups = Group.objects.get_parents(group).annotate(length=Length("subgroup")) \ + .order_by("length") + + return render(request, "calendars.html", {"group": group, "groups": groups}) + def contact(request): return render(request, "contact.html", {"email": settings.ADMINS[0][1]}) -- cgit v1.2.1