From 57901f55320c95d18e305e504ee48b4e19002294 Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Mon, 28 Sep 2020 13:50:53 +0200 Subject: [PATCH] Fix appointment date / hour --- teleforma/models/appointment.py | 15 +++++---------- teleforma/templates/teleforma/appointments.html | 9 ++++----- .../teleforma/messages/email_appointment.txt | 8 +++++--- .../messages/email_appointment_sujet.txt | 2 +- teleforma/views/appointment.py | 4 +++- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/teleforma/models/appointment.py b/teleforma/models/appointment.py index 25f9eabb..f17d931e 100644 --- a/teleforma/models/appointment.py +++ b/teleforma/models/appointment.py @@ -75,7 +75,7 @@ class AppointmentPeriod(Model): for slot in AppointmentSlot.objects.filter(appointment_period=self).order_by('start'): cache_key = '%s_%s_%s-%s' % (CACHE_KEY, self.id, slot.date, slot.mode) dayData = cache.get(cache_key) - dayData = None + # dayData = None slot_key = str(slot.date) + "-" + slot.mode if not dayData: slotData = {'instance':slot, @@ -248,12 +248,9 @@ class AppointmentSlot(Model): for i in range(self.nb): arrival = datetime.datetime.combine(self.date, self.start) + datetime.timedelta(minutes=i * size) - if self.mode == 'distance': - start = arrival - end = start + datetime.timedelta(minutes=size) - else: - start = arrival + datetime.timedelta(minutes=60) - end = start + datetime.timedelta(minutes=size) + start = arrival + datetime.timedelta(minutes=60) + end = start + datetime.timedelta(minutes=size) + slot_info = { 'slot_nb': i, 'start': start, @@ -337,9 +334,7 @@ class Appointment(Model): @property def start(self): - base = dt = datetime.datetime.combine(datetime.date.today(), self.arrival) - if self.slot.mode != 'distance': - dt = base + datetime.timedelta(minutes=60) + dt = datetime.datetime.combine(datetime.date.today(), self.arrival) + datetime.timedelta(minutes=60) return datetime.time(dt.hour, dt.minute, 0) @property diff --git a/teleforma/templates/teleforma/appointments.html b/teleforma/templates/teleforma/appointments.html index abb25967..42d23a00 100644 --- a/teleforma/templates/teleforma/appointments.html +++ b/teleforma/templates/teleforma/appointments.html @@ -206,10 +206,9 @@ {{ ap_period.appointment.jury.name }}
{{ ap_period.appointment.jury.address|linebreaks }} - {% if ap_period.appointment.slot.mode == 'presentiel' %} - Heure d'arrivé : {{ ap_period.appointment.arrival|date:'H:i' }} -
- {% endif %} + + Heure de préparation : {{ ap_period.appointment.arrival|date:'H:i' }} +
Heure de début : {{ ap_period.appointment.start|date:'H:i' }}
Heure de fin : {{ ap_period.appointment.end|date:'H:i' }} @@ -271,7 +270,7 @@ {% for groupslot in day.slots %} - Heure d'arrivé + Heure de préparation {% for jury in groupslot.get_visible_jurys %} Jury {{ forloop.counter }} diff --git a/teleforma/templates/teleforma/messages/email_appointment.txt b/teleforma/templates/teleforma/messages/email_appointment.txt index 9e966b19..34ef66d4 100644 --- a/teleforma/templates/teleforma/messages/email_appointment.txt +++ b/teleforma/templates/teleforma/messages/email_appointment.txt @@ -1,13 +1,15 @@ Bonjour {{ student.first_name }}, -Nous vous confirmons votre rendez-vous pour "{{ title }}" -le {{ date|date:"l d F Y à H:i" }}. +Nous vous confirmons votre rendez-vous pour "{{ title }}" le {{ arrival|date:"l d F Y" }}. +Heure de préparation : {{ arrival|date:"H:i" }} +Heure de début : {{ start|date:"H:i" }} +Heure de fin :{{ end|date:"H:i" }} {% if mode == 'presentiel' %} Votre simulation se tiendra au {{ jury_address }} {% elif mode == 'distance' %} -Vous devrez vous connecter à cette adresse à l'heure indiquée : {{ bbb }} +Vous devrez vous connecter à cette adresse à l'heure de début : {{ bbb }} {% endif %} {{ main_text|safe }} \ No newline at end of file diff --git a/teleforma/templates/teleforma/messages/email_appointment_sujet.txt b/teleforma/templates/teleforma/messages/email_appointment_sujet.txt index 62a5967a..6b2b01af 100644 --- a/teleforma/templates/teleforma/messages/email_appointment_sujet.txt +++ b/teleforma/templates/teleforma/messages/email_appointment_sujet.txt @@ -1 +1 @@ -Validation de votre rendez-vous le {{ date|date:"d/m/Y" }} +Validation de votre rendez-vous le {{ arrival|date:"d/m/Y" }} diff --git a/teleforma/views/appointment.py b/teleforma/views/appointment.py index 7c971c21..7f255556 100644 --- a/teleforma/views/appointment.py +++ b/teleforma/views/appointment.py @@ -128,7 +128,9 @@ class Appointments(View): 'mto': ap.student.email, 'title': ap.appointment_period.name, 'jury_address': ap.jury.address, - 'date': ap.real_date, + 'arrival': ap.real_date, + 'start': ap.start, + 'end': ap.end, 'student': ap.student, 'mode': ap.slot.mode, 'bbb': ap.jury.bbb_room, -- 2.39.5