|
|
|
@ -99,41 +99,53 @@ def airtable_dashboard():
|
|
|
|
|
@auth_required()
|
|
|
|
|
def display_participants():
|
|
|
|
|
participants = fetch_api('participants')
|
|
|
|
|
print("Participants: " + str(participants))
|
|
|
|
|
intervenants = fetch_api('intervenants')
|
|
|
|
|
|
|
|
|
|
records = []
|
|
|
|
|
|
|
|
|
|
for participant in participants.get_all():
|
|
|
|
|
records.append(participant)
|
|
|
|
|
if current_user.has_role("gestionnaire"):
|
|
|
|
|
for participant in participants.get_all():
|
|
|
|
|
records.append(participant)
|
|
|
|
|
elif current_user.has_role("prof"):
|
|
|
|
|
for participant in participants.get_all():
|
|
|
|
|
mes_intervenants = [ intervenants.get(intervenant_id)['fields'].get('email') for intervenant_id in (participant['fields'].get('Intervenants') or [])]
|
|
|
|
|
if current_user.email in mes_intervenants:
|
|
|
|
|
records.append(participant)
|
|
|
|
|
return render_template('participants/participants_list.html', records=records)
|
|
|
|
|
|
|
|
|
|
@airtable_bp.route("/participants/<participant_number>", methods=['GET'])
|
|
|
|
|
|
|
|
|
|
@airtable_bp.route("/participants/<participant_id>/dashboard", methods=['GET'])
|
|
|
|
|
@auth_required()
|
|
|
|
|
def display_participant_form(participant_number):
|
|
|
|
|
participants = fetch_api('participants')
|
|
|
|
|
def participant_dashboard(participant_id):
|
|
|
|
|
participant = fetch_api('participants').get(participant_id)
|
|
|
|
|
sessions_ids = participant['fields']['Sessions']
|
|
|
|
|
sessions = fetch_api('sessions')
|
|
|
|
|
participant = participants.search('Number', participant_number)[0]
|
|
|
|
|
return render_template('participants/participants_detail.html', record=participant, sessions=sessions)
|
|
|
|
|
sessions = [ sessions.get(session_id) for session_id in sessions_ids ]
|
|
|
|
|
|
|
|
|
|
@airtable_bp.route('/participants/<participant_number>/edit', methods=['GET', 'POST'])
|
|
|
|
|
formation_ids = [ session['fields']['Formations'][0] for session in sessions ]
|
|
|
|
|
formations = fetch_api('formations')
|
|
|
|
|
formations = [ formations.get(formation_id) for formation_id in formation_ids]
|
|
|
|
|
|
|
|
|
|
return render_template('participants/participant_dashboard.html', participant=participant, sessions=sessions, formations=formations)
|
|
|
|
|
|
|
|
|
|
@airtable_bp.route("/participants/<participant_id>/profile", methods=['GET', 'POST'])
|
|
|
|
|
@auth_required()
|
|
|
|
|
def edit_participant(participant_number):
|
|
|
|
|
def participant_profile(participant_id):
|
|
|
|
|
participants = fetch_api('participants')
|
|
|
|
|
record = participants.search('Number', participant_number)[0]
|
|
|
|
|
record_id = record['id']
|
|
|
|
|
participant = participants.get(participant_id)
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
data = {}
|
|
|
|
|
if request.form['first_name'] != record['fields']['Prénom']:
|
|
|
|
|
if request.form['first_name'] != participant['fields']['Prénom']:
|
|
|
|
|
data['Prénom'] = request.form['first_name']
|
|
|
|
|
if request.form['family_name'] != record['fields']['Nom']:
|
|
|
|
|
if request.form['family_name'] != participant['fields']['Nom de famille']:
|
|
|
|
|
data['Nom de famille'] = request.form['family_name']
|
|
|
|
|
data['CNI'] = update_airtable_attachment_field(request, record, "CNI")
|
|
|
|
|
data["Attestation Pôle Emploi"] = update_airtable_attachment_field(request, record, "Attestation", "Attestation Pôle Emploi")
|
|
|
|
|
data['CNI'] = update_airtable_attachment_field(request, participant, "CNI")
|
|
|
|
|
data["Attestation Pôle Emploi"] = update_airtable_attachment_field(request, participant, "Attestation", "Attestation Pôle Emploi")
|
|
|
|
|
|
|
|
|
|
if data:
|
|
|
|
|
participants.update(record_id, data)
|
|
|
|
|
return redirect(url_for('airtable.display_participant_form', participant_number=participant_number))
|
|
|
|
|
participants.update(participant_id, data)
|
|
|
|
|
return redirect(url_for('airtable.participant_profile', participant_id=participant_id))
|
|
|
|
|
else:
|
|
|
|
|
return render_template('airtable/participants/participants_edit.html', record=record)
|
|
|
|
|
return render_template('participants/participant_profile.html', record = participant)
|
|
|
|
|
|
|
|
|
|
def is_session_active(sessions, formations):
|
|
|
|
|
formation_id = request.args.get('formation_id')
|
|
|
|
@ -236,32 +248,8 @@ def show_workshops(module_id):
|
|
|
|
|
if modules.get(module_id)['fields'].get("Participants", []):
|
|
|
|
|
participants_prevus = [ participant for participant in participants.get_all() if participant['id'] in modules.get(module_id)['fields']['Participants']]
|
|
|
|
|
|
|
|
|
|
participants_presents = []
|
|
|
|
|
if modules.get(module_id)['fields'].get("Participants présents", []):
|
|
|
|
|
participants_presents = [ participant for participant in participants.get_all() if participant['id'] in modules.get(module_id)['fields']['Participants présents']]
|
|
|
|
|
|
|
|
|
|
return render_template('/airtable/workshops/workshops.html', module = module, workshops = workshops, intervenants = intervenants, participants = participants_prevus, presents = participants_presents)
|
|
|
|
|
|
|
|
|
|
############## affichage des participants par module session d'un prof
|
|
|
|
|
@airtable_bp.route('/participants/module/<module_id>', methods=['GET'])
|
|
|
|
|
@auth_required()
|
|
|
|
|
def display_module_participants(module_id, intervenant_id):
|
|
|
|
|
modules = fetch_api('modules')
|
|
|
|
|
# Authentifier l'utilisateur pour déterminer son rôle (professeur ou autre)
|
|
|
|
|
user = current_user()
|
|
|
|
|
|
|
|
|
|
# Vérifier si l'utilisateur est un professeur
|
|
|
|
|
if user.role == 'prof':
|
|
|
|
|
module = modules.get(module_id,intervenant_id)
|
|
|
|
|
if module:
|
|
|
|
|
# Récupérer la liste des participants prévus pour ce module
|
|
|
|
|
participants = fetch_api('participants')
|
|
|
|
|
participants_prevus = [participants.get(participant_id)['fields']['Nom'] for participant_id in module['fields']['Participants prévus']]
|
|
|
|
|
|
|
|
|
|
return render_template('module_participants.html', participants=participants_prevus)
|
|
|
|
|
else:
|
|
|
|
|
return "Accès non autorisé"
|
|
|
|
|
|
|
|
|
|
return render_template('/airtable/workshops/workshops.html', module = module, workshops = workshops, intervenants = intervenants, participants = participants_prevus)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
######### Affichage de la fiche d'une séance
|
|
|
|
|
@airtable_bp.route('/modules/<module_id>/workshops/<workshop_id>', methods=['GET', 'POST'])
|
|
|
|
@ -291,7 +279,7 @@ def show_workshop(module_id, workshop_id):
|
|
|
|
|
|
|
|
|
|
return redirect(url_for('airtable.show_workshop', module_id=module_id, workshop_id=workshop_id))
|
|
|
|
|
else:
|
|
|
|
|
return render_template('/airtable/workshops/workshop.html', workshop = workshop, module = module, module_base = module_base, participants = participants_prevus )
|
|
|
|
|
return render_template('/airtable/workshops/workshop.html', workshop = workshop, module = module, module_base = module_base, participants = participants_prevus)
|
|
|
|
|
|
|
|
|
|
####### Evaluations individuelles pour une séance
|
|
|
|
|
@airtable_bp.route('/modules/<module_id>/workshops/<workshop_id>/<participant_id>', methods=['GET', 'POST'])
|
|
|
|
@ -365,9 +353,7 @@ def presences_workshop(module_id, workshop_id):
|
|
|
|
|
participants_prevus = [ participants.get(participant) for participant in workshop['fields']['Participants prévus']]
|
|
|
|
|
participants_presents = [ participants.get(participant) for participant in workshop['fields']['Participants présents']]
|
|
|
|
|
participants_presents_ids = [ participant['id'] for participant in participants_presents ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
participants_presents_ids = request.form['presentParticipants'].split(',')
|
|
|
|
|
workshops.update(workshop['id'], {"Participants présents": participants_presents_ids})
|
|
|
|
@ -386,7 +372,17 @@ def show_module():
|
|
|
|
|
|
|
|
|
|
data_module = []
|
|
|
|
|
for module in modules.get_all():
|
|
|
|
|
data_module.append(module)
|
|
|
|
|
if current_user.has_role("gestionnaire"):
|
|
|
|
|
data_module.append(module)
|
|
|
|
|
elif current_user.has_role("prof"):
|
|
|
|
|
if module['fields'].get('Intervenants'):
|
|
|
|
|
for intervenant in module['fields']['Intervenants']:
|
|
|
|
|
intervenant = intervenants.get(intervenant)
|
|
|
|
|
print("intervenant testé : " + str(intervenant))
|
|
|
|
|
print("current user email : " + current_user.email)
|
|
|
|
|
if intervenant['fields'].get('email') and intervenant['fields']['email'] == current_user.email:
|
|
|
|
|
data_module.append(module)
|
|
|
|
|
break
|
|
|
|
|
return render_template('/airtable/modules/modules.html' , records = data_module, sessions = sessions, intervenants = intervenants, participants = participants )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|