From fed7bcaa8ef516e52f5f59e39f23deeb88fd864a Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Thu, 18 Feb 2021 10:06:08 +0100 Subject: [PATCH 1/2] Fix issue with missing WebclassSlot while retrieving bbb records https://trackers.pilotsystems.net/probarreau/1070 --- teleforma/webclass/forms.py | 18 +++++++++++------- teleforma/webclass/models.py | 19 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/teleforma/webclass/forms.py b/teleforma/webclass/forms.py index 2a1319e9..d190ec6d 100644 --- a/teleforma/webclass/forms.py +++ b/teleforma/webclass/forms.py @@ -7,23 +7,21 @@ from django.core.exceptions import ValidationError class WebclassRecordsForm(Form): - # period = ModelChoiceField(label='Période', - # queryset=Period.objects.filter(is_open=True)) - - class Meta: - pass - def __init__(self, *args, **kwargs): + # for each course, we create a field whcih includes a list of bbb course from the same course id and same period id self.period_id = kwargs.pop('period_id') self.period = Period.objects.get(pk=self.period_id) super(WebclassRecordsForm, self).__init__(*args, **kwargs) courses = Course.objects.all() all_records = self.get_records_by_course() + for course in courses: + # get list of webclass webclasses = course.webclass.filter(period=self.period).all() if webclasses: + # build a rooms id list rooms = [] for webclass in webclasses: for slot in webclass.slots.all(): @@ -31,8 +29,11 @@ def __init__(self, *args, **kwargs): field_name = 'course_%d' % course.id records = all_records.get(course.id, []) + print(records) vocabulary = [('none', 'Aucun')] + # for each bbb record for the current course, add an option to the field + for record in records: webclass_slot = WebclassSlot.objects.get(pk=record['slot'].id) label = u"%s à %s - %s" % (record['start_date'].strftime('%d/%m/%Y %H:%M'), record['end_date'].strftime('%H:%M'), webclass_slot.professor.user.last_name) @@ -40,10 +41,13 @@ def __init__(self, *args, **kwargs): self.fields[field_name] = ChoiceField(label=course.title, choices=vocabulary, required=False) def get_records_by_course(self): + """ + Get all records, in a dict with course_id as key + """ records = get_records(period_id=self.period_id) by_course = {} for record in records: - if hasattr(record, 'course_id'): + if record.get('course_id'): by_course.setdefault(record['course_id'], []).append(record) return by_course diff --git a/teleforma/webclass/models.py b/teleforma/webclass/models.py index abd0f3ad..d5587215 100644 --- a/teleforma/webclass/models.py +++ b/teleforma/webclass/models.py @@ -65,13 +65,18 @@ def get_records_from_bbb(**kwargs): 'state': recording['state'].decode(), } if recording['metadata'].get('periodid'): - webclass_slots = WebclassSlot.objects.filter(pk=int(recording['metadata'].get('slotid').decode())) - if webclass_slots: - data.update({ - 'period_id': int(recording['metadata'].get('periodid').decode()), - 'course_id': int(recording['metadata'].get('courseid').decode()), - 'slot': WebclassSlot.objects.get(pk=int(recording['metadata'].get('slotid').decode())) - }) + # we try to get metadata added to bbb record during the recording + slot = None + try: + slot = WebclassSlot.objects.get(pk=int(recording['metadata'].get('slotid').decode())) + except WebclassSlot.DoesNotExist: + # this happen if the slot is deleted in django admin + continue + data.update({ + 'period_id': int(recording['metadata'].get('periodid').decode()), + 'course_id': int(recording['metadata'].get('courseid').decode()), + 'slot': slot + }) data['duration'] = data['end'] - data['start'] records.append(data) From ae31259470c4156e69b08eb32e4a7dc0fa18448a Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Tue, 23 Feb 2021 15:30:11 +0100 Subject: [PATCH 2/2] Add introduction text https://trackers.pilotsystems.net/probarreau/1073 --- teleforma/templates/registration/registration_form.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/teleforma/templates/registration/registration_form.html b/teleforma/templates/registration/registration_form.html index adbc63cd..c417654b 100644 --- a/teleforma/templates/registration/registration_form.html +++ b/teleforma/templates/registration/registration_form.html @@ -26,9 +26,14 @@ {% block content %} -
{% csrf_token %} + +

Pour ceux qui souhaitent s’inscrire en présentiel, nous vous informons que vous êtes susceptibles + - dans la mesure ou les conditions sanitaires ne s’amélioreraient pas d’ici fin juin et que les mesures gouvernementales nous imposeraient des effectifs réduits – d’être basculé en e-learning.

+ +

Bien évidemment, dans ce cas de figure, vous seriez remboursé à due concurrence.

+

{% if mode_corrector %}Pré-inscription des correcteurs - PRÉ-BARREAU - CRFPA{% else %}{% trans "Pre-registration" %} -