aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-09-06 12:40:30 +0200
committerAlban Gruin2017-09-06 12:40:30 +0200
commitfb9aee0fcc690b96ccfb8a5d7d587e6a771a563c (patch)
treee1d3c3cb516928b2dae746674218596de8adadc5
parent36757e937abd7d5aa3434f4c815dfb040e1e3a71 (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.py3
-rw-r--r--views.py4
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)