feat(groupe-instructeur): instructeur can add signature in attestation

This commit is contained in:
Christophe Robillard 2023-09-21 13:51:04 +02:00 committed by krichtof
parent ad10335888
commit c02e6f2a77
4 changed files with 56 additions and 0 deletions

View file

@ -1,5 +1,7 @@
module Instructeurs
class GroupeInstructeursController < InstructeurController
include UninterlacePngConcern
ITEMS_PER_PAGE = 25
def index
@ -13,6 +15,26 @@ module Instructeurs
@instructeurs = paginated_instructeurs
end
def add_signature
@procedure = procedure
@groupe_instructeur = groupe_instructeur
@instructeurs = paginated_instructeurs
signature_file = params[:groupe_instructeur][:signature]
if params[:groupe_instructeur].nil? || signature_file.blank?
flash[:alert] = "Aucun fichier joint pour le tampon de l'attestation"
render :show
else
file = uninterlace_png(signature_file)
params[:groupe_instructeur][:signature] = file
if @groupe_instructeur.update(signature: file)
redirect_to instructeur_groupe_path(@procedure, @groupe_instructeur),
notice: "Le tampon de l'attestation a bien été ajouté"
end
end
end
def add_instructeur
instructeur = Instructeur.by_email(instructeur_email) ||
create_instructeur(instructeur_email)