2019-08-06 11:02:54 +02:00
|
|
|
module Instructeurs
|
|
|
|
class AvisController < InstructeurController
|
2018-10-31 14:56:01 +01:00
|
|
|
include CreateAvisConcern
|
|
|
|
|
2021-02-25 09:53:09 +01:00
|
|
|
before_action :authenticate_instructeur!
|
2017-09-06 11:21:29 +02:00
|
|
|
A_DONNER_STATUS = 'a-donner'
|
|
|
|
DONNES_STATUS = 'donnes'
|
|
|
|
|
2020-07-16 11:14:37 +02:00
|
|
|
def revoquer
|
|
|
|
avis = Avis.find(params[:id])
|
2020-07-16 20:42:50 +02:00
|
|
|
if avis.revoke_by!(current_instructeur)
|
2021-02-25 09:53:09 +01:00
|
|
|
flash.notice = "#{avis.expert.email} ne peut plus donner son avis sur ce dossier."
|
2020-07-16 11:14:37 +02:00
|
|
|
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-20 16:26:16 +02:00
|
|
|
def revive
|
|
|
|
avis = Avis.find(params[:id])
|
2020-07-21 13:14:07 +02:00
|
|
|
if avis.revivable_by?(current_instructeur)
|
|
|
|
if avis.answer.blank?
|
|
|
|
AvisMailer.avis_invitation(avis).deliver_later
|
2021-02-25 09:53:09 +01:00
|
|
|
flash.notice = "Un mail de relance a été envoyé à #{avis.expert.email}"
|
2020-07-21 13:14:07 +02:00
|
|
|
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
|
|
|
else
|
2021-02-25 09:53:09 +01:00
|
|
|
flash.alert = "#{avis.expert.email} a déjà donné son avis"
|
2020-07-21 13:14:07 +02:00
|
|
|
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
|
|
|
end
|
2020-07-20 16:26:16 +02:00
|
|
|
end
|
|
|
|
end
|
2017-09-06 11:21:29 +02:00
|
|
|
end
|
|
|
|
end
|