From 5a8498fa79f48fb4f6b96a1caecaf7268b431220 Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Thu, 21 Jan 2021 17:01:30 +0100 Subject: [PATCH] Do not show all webclass slots : https://trackers.pilotsystems.net/probarreau/1045 --- teleforma/webclass/views.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/teleforma/webclass/views.py b/teleforma/webclass/views.py index 077fb7b7..673cedbc 100644 --- a/teleforma/webclass/views.py +++ b/teleforma/webclass/views.py @@ -64,8 +64,19 @@ class WebclassAppointment(View): # Ensure user is logged in, a student, and has access to current period user = request.user student = user.student.all()[0] - - return render(request, self.template_name, {'slots': webclass.slots.order_by('day', 'start_hour'), 'webclass': webclass}) + slots = webclass.slots.order_by('day', 'start_hour') + # only display unavaible slots or first slot of the day + filtered_slots = [] + day = None + for slot in slots: + if slot.participant_slot_available: + if slot.day != day: + filtered_slots.append(slot) + day = slot.day + else: + filtered_slots.append(slot) + + return render(request, self.template_name, {'slots': filtered_slots, 'webclass': webclass}) def check_slot_validity(self, user, slot): """ -- 2.39.5