From b16845233a01adfef9ad2e29c384a2c5ad38afe8 Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Wed, 20 Apr 2022 09:48:32 +0200 Subject: [PATCH] Add date to webclass : https://trackers.pilotsystems.net/prebarreau/0401 --- teleforma/webclass/models.py | 15 +++++++++++++++ .../webclass/templates/webclass/appointments.html | 4 ++-- .../webclass/appointments_professor.html | 2 +- .../templates/webclass/inc/webclass_list.html | 4 ++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/teleforma/webclass/models.py b/teleforma/webclass/models.py index 7f6c504f..524ffbbf 100644 --- a/teleforma/webclass/models.py +++ b/teleforma/webclass/models.py @@ -210,6 +210,21 @@ class WebclassSlot(models.Model): def __str__(self): return "Webclass slot : " + str(self.id) + @property + def date(self): + """ + Compute the last date (from weekday) before the end of webclass. + This is the webclass date. Before, webclass were every "monday" for example. + Now there is only one date per webclass. + This is not ideal. We should have a "date" field on the webclass slot instead of "day". + But we're waiting to see how PB use webclasses in the future. + """ + end_day = self.webclass.end_date + next_day = end_day + datetime.timedelta(days=7 - end_day.weekday() + self.day, weeks=-1) + if next_day > end_day: + next_day = next_day - datetime.timedelta(weeks=1) + return next_day + @property def remaining_participant_slot(self): """ diff --git a/teleforma/webclass/templates/webclass/appointments.html b/teleforma/webclass/templates/webclass/appointments.html index a052a298..7a5652c7 100644 --- a/teleforma/webclass/templates/webclass/appointments.html +++ b/teleforma/webclass/templates/webclass/appointments.html @@ -68,7 +68,7 @@ {% for slot in slots %} - {{slot.get_day_display}} de {{slot.start_hour|date:"H\hi"}} à {{slot.end_hour|date:"H\hi"}} + {{slot.get_day_display}} {{slot.date}} de {{slot.start_hour|date:"H\hi"}} à {{slot.end_hour|date:"H\hi"}} {{slot.professor}} @@ -79,7 +79,7 @@
- + {% csrf_token %} {% if slot.participant_slot_available %} diff --git a/teleforma/webclass/templates/webclass/appointments_professor.html b/teleforma/webclass/templates/webclass/appointments_professor.html index 6031d158..f48b3c78 100644 --- a/teleforma/webclass/templates/webclass/appointments_professor.html +++ b/teleforma/webclass/templates/webclass/appointments_professor.html @@ -31,7 +31,7 @@ Calendrier des Webclass {% for slot in slots %} - {{slot.get_day_display}} de {{slot.start_hour|date:"H\hi"}} à + {{slot.get_day_display}} {{slot.date}} de {{slot.start_hour|date:"H\hi"}} à {{slot.end_hour|date:"H\hi"}} diff --git a/teleforma/webclass/templates/webclass/inc/webclass_list.html b/teleforma/webclass/templates/webclass/inc/webclass_list.html index a96fc8c6..b48d4c0f 100644 --- a/teleforma/webclass/templates/webclass/inc/webclass_list.html +++ b/teleforma/webclass/templates/webclass/inc/webclass_list.html @@ -11,8 +11,8 @@ {% if webclass_slot %} -

Vous êtes inscrit pour les webclasses du - {{webclass_slot.get_day_display}} de +

Vous êtes inscrit pour la webclass du + {{webclass_slot.get_day_display}} {{webclass_slot.date}} de {{webclass_slot.start_hour|date:"H\hi"}} à {{webclass_slot.end_hour|date:"H\hi"}} avec le professeur {{webclass_slot.professor.user.last_name}}. -- 2.39.5