From fb9aee0fcc690b96ccfb8a5d7d587e6a771a563c Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Wed, 6 Sep 2017 12:40:30 +0200 Subject: Ajout des champs « active » et « checked » au modèle de cours, qui sera nécessaire pour la fonction de mise à jour sans tout jeter. Les cours avec active à False ne seront pas affichés. Il faudrait peut-être rajouter un index sur ce champ ? --- models.py | 3 +++ views.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/models.py b/models.py index 0b0ee63..de14b43 100644 --- a/models.py +++ b/models.py @@ -157,6 +157,9 @@ class Course(models.Model): begin = models.DateTimeField(verbose_name="début du cours", db_index=True) end = models.DateTimeField(verbose_name="fin du cours") + active = models.BooleanField(verbose_name="actif", default=True) + checked = models.BooleanField(default=True, db_index=True) + def __str__(self): return self.name diff --git a/views.py b/views.py index 176f174..ebe111b 100644 --- a/views.py +++ b/views.py @@ -29,7 +29,7 @@ def index(request): year, week = get_current_week() start, _ = get_week(year, week) - groups_weeks = Course.objects.get_weeks(begin__gte=start).values("groups__timetable", "groups__mention", "groups__subgroup", "groups__td", "groups__tp", "year", "week") + groups_weeks = Course.objects.get_weeks(begin__gte=start, active=True).values("groups__timetable", "groups__mention", "groups__subgroup", "groups__td", "groups__tp", "year", "week") for group in groups: for group_week in groups_weeks: @@ -55,7 +55,7 @@ def timetable(request, timetable_slug, group_slug, year=None, week=None): timetable = get_object_or_404(Timetable, slug=timetable_slug) group = get_object_or_404(Group, slug=group_slug, timetable=timetable) last_update = get_object_or_404(LastUpdate, timetable=timetable, week=week, year=year) - courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) + courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end, active=True) grouped_courses = group_courses(courses) -- cgit v1.2.1