From 50f4e5d3277d611f3b9a662f436346e03f6e3996 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Thu, 9 Feb 2017 11:34:59 +0100 Subject: Plus de décalage artificiel à la semaine prochaine dans les vues --- utils.py | 3 +++ views.py | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/utils.py b/utils.py index 1a177b4..8b5325c 100644 --- a/utils.py +++ b/utils.py @@ -2,6 +2,9 @@ from django.utils import timezone import datetime +def get_current_week(): + return timezone.now().isocalendar()[:2] + def get_current_or_next_week(): year, week, day = timezone.now().isocalendar() if day >= 6: diff --git a/views.py b/views.py index b5d4cbf..f02061e 100644 --- a/views.py +++ b/views.py @@ -8,7 +8,7 @@ from django.template import Context, loader from edt.forms import SubscribeForm from edt.models import Timetable, LastUpdate, Group, Subscription, Course -from edt.utils import get_current_or_next_week, get_week, group_courses +from edt.utils import get_current_week, get_week, group_courses import datetime @@ -16,7 +16,7 @@ def index(request): timetables = Timetable.objects.all() groups = Group.objects.filter(tp__isnull=False).order_by("name") - year, week = get_current_or_next_week() + 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") @@ -37,7 +37,7 @@ def index(request): def timetable(request, timetable_slug, group_slug, year=None, week=None): if year is None or week is None: - year, week = get_current_or_next_week() + year, week = get_current_week() start, end = get_week(int(year), int(week)) @@ -73,7 +73,7 @@ def subscribe(request, timetable_slug, group_slug, year, week): def confirm_subscription(request, token): subscription = Subscription.objects.filter(token=token).first() - year, week = get_current_or_next_week() + year, week = get_current_week() if subscription is not None and not subscription.active: subscription.active = True -- cgit v1.2.1