Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
yomguy committed Feb 23, 2021
2 parents c4f2e93 + ae31259 commit 8db46d5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
7 changes: 6 additions & 1 deletion teleforma/templates/registration/registration_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@

{% block content %}


<form class="register" id="_registerForm" method="post" action="" enctype="multipart/form-data" data-ajax="false">
{% csrf_token %}

<p>Pour ceux qui <strong>souhaitent s’inscrire en présentiel</strong>, 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 – <strong>d’être basculé en e-learning</strong>.</p>

<p>Bien évidemment, dans ce cas de figure, vous seriez remboursé à due concurrence.</p>
<br/>

<h1>{% if mode_corrector %}Pré-inscription des correcteurs - PRÉ-BARREAU -
CRFPA{% else %}{% trans "Pre-registration" %} -
Expand Down
18 changes: 11 additions & 7 deletions teleforma/webclass/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,47 @@
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():
rooms.append(slot.room_id)

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)
vocabulary.append((str(record['id']) + ";" + str(record['server_id']), label))
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

Expand Down
19 changes: 12 additions & 7 deletions teleforma/webclass/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8db46d5

Please sign in to comment.