From: Yoan Le Clanche Date: Thu, 21 Jan 2021 16:01:30 +0000 (+0100) Subject: Do not show all webclass slots : https://trackers.pilotsystems.net/probarreau/1045 X-Git-Tag: 1.4.3~32^2~3 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=5a8498fa79f48fb4f6b96a1caecaf7268b431220;p=teleforma.git Do not show all webclass slots : https://trackers.pilotsystems.net/probarreau/1045 --- 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): """