diff options
author | Alban Gruin | 2017-02-09 11:34:59 +0100 |
---|---|---|
committer | Alban Gruin | 2017-02-09 11:34:59 +0100 |
commit | 50f4e5d3277d611f3b9a662f436346e03f6e3996 (patch) | |
tree | 8daea60e78e1a0a252cf58b7fd2633355a48977e | |
parent | 1fd2062ca3fe15bf3442114ca45127e26d9566b7 (diff) |
Plus de décalage artificiel à la semaine prochaine dans les vues
-rw-r--r-- | utils.py | 3 | ||||
-rw-r--r-- | views.py | 8 |
2 files changed, 7 insertions, 4 deletions
@@ -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: @@ -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 |