aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'views.py')
-rw-r--r--views.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/views.py b/views.py
index 1308db1..aabda59 100644
--- a/views.py
+++ b/views.py
@@ -79,6 +79,43 @@ def group_list(request, year_slug, timetable_slug):
{"timetable": timetable, "groups": groups})
+def groups_all(request, year_slug, timetable_slug):
+ # Récupération de l’emploi du temps et du groupe
+ timetable = get_object_or_404(Timetable, year__slug=year_slug,
+ slug=timetable_slug)
+ groups = Group.objects.filter(source=timetable.source).order_by("name")
+
+ # Rendu de la page
+ return render(request, "groups_all_list.html",
+ {"timetable": timetable, "elements": groups})
+
+
+def group_weeks(request, year_slug, timetable_slug, group_slug):
+ # Récupération de l’emploi du temps et des groupes
+ timetable = get_object_or_404(Timetable, year__slug=year_slug,
+ slug=timetable_slug)
+ group = get_object_or_404(Group, slug=group_slug, source=timetable.source)
+
+ # Groupes parents
+ groups = Group.objects.get_parents(group)
+
+ # Récupération de toutes les semaines avec des cours, sans doublons
+ courses = Course.objects.filter(groups__in=groups) \
+ .order_by("year", "week") \
+ .annotate(year=ExtractYear("begin"),
+ week=ExtractWeek("begin")) \
+ .values("year", "week") \
+ .annotate(c=Count("*"))
+
+ # Conversion des semaines de cours en dates
+ weeks = [get_week(course["year"], course["week"])[0] for course in courses]
+
+ # Rendu
+ return render(request, "group_weeks_list.html",
+ {"timetable": timetable, "group": group,
+ "elements": weeks})
+
+
def timetable_common(request, obj, year=None, week=None, timetable=None):
current_year, current_week = get_current_or_next_week()
is_old_timetable, provided_week = False, True
@@ -198,6 +235,23 @@ def rooms(request):
return render(request, "group_list.html", {"groups": rooms_weeks})
+def room_weeks(request, room_slug):
+ room = get_object_or_404(Room, slug=room_slug)
+
+ # Récupération des semaines de cours
+ courses = Course.objects.filter(rooms=room) \
+ .order_by("year", "week") \
+ .annotate(year=ExtractYear("begin"),
+ week=ExtractWeek("begin")) \
+ .values("year", "week") \
+ .annotate(c=Count("*"))
+
+ weeks = [get_week(course["year"], course["week"])[0] for course in courses]
+
+ return render(request, "room_weeks_list.html",
+ {"room": room, "elements": weeks})
+
+
def room_timetable(request, room_slug, year=None, week=None):
room = get_object_or_404(Room, slug=room_slug)
return timetable_common(request, room, year, week)