add role mechanism for participants

This commit is contained in:
Florian du Garage Num 2023-06-08 17:57:27 +02:00
parent 0ec6996550
commit e78e2f1989

View File

@ -99,10 +99,17 @@ def airtable_dashboard():
@auth_required()
def display_participants():
participants = fetch_api('participants')
print("Participants: " + str(participants))
intervenants = fetch_api('intervenants')
records = []
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_id>/dashboard", methods=['GET'])
@ -347,8 +354,6 @@ def presences_workshop(module_id, workshop_id):
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})