diff options
author | Alban Gruin | 2017-01-19 21:55:29 +0100 |
---|---|---|
committer | Alban Gruin | 2017-01-19 21:55:29 +0100 |
commit | d17c1152615162e33703dd67b92b64d0cbf5b63d (patch) | |
tree | f2db90f8c83c3da626090efee9133c0754849530 /views.py | |
parent | f55e7ff672ba18291d7361c4c8649e174c9fa556 (diff) |
Travail initial sur les vues
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -1,3 +1,19 @@ -from django.shortcuts import render +from django.http import HttpResponse +from django.shortcuts import get_object_or_404, render, render_to_response +from django.db.models import Q -# Create your views here. +from edt.models import Timetable, Group, Course + +def index(request): + timetables = Timetable.objects.all() + groups = Group.objects.filter(tp__isnull=False).order_by("name") + + return render_to_response("index.html", {"timetables": timetables, "groups": groups}) + +def timetable(request, timetable_slug, group_slug): + timetable = get_object_or_404(Timetable, slug=timetable_slug) + group = get_object_or_404(Group, slug=group_slug, timetable=timetable) + + courses = Course.objects.filter(Q(groups__td__isnull=True) | Q(groups__td=group.td), Q(groups__tp__isnull=True) | Q(groups__tp=group.tp), groups__mention=group.mention, groups__subgroup=group.subgroup).order_by("begin").distinct() + + return render_to_response("timetable.html", {"timetable": timetable, "group": group, "courses": courses}) |