diff options
author | Alban Gruin | 2017-09-06 12:40:30 +0200 |
---|---|---|
committer | Alban Gruin | 2017-09-06 12:40:30 +0200 |
commit | fb9aee0fcc690b96ccfb8a5d7d587e6a771a563c (patch) | |
tree | e1d3c3cb516928b2dae746674218596de8adadc5 | |
parent | 36757e937abd7d5aa3434f4c815dfb040e1e3a71 (diff) |
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 ?
-rw-r--r-- | models.py | 3 | ||||
-rw-r--r-- | views.py | 4 |
2 files changed, 5 insertions, 2 deletions
@@ -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 @@ -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) |