aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils.py3
-rw-r--r--views.py8
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