only instructeurs of the avis dossier or claimant can revive expert
This commit is contained in:
parent
169b8c9b3e
commit
7f90bdeec4
2 changed files with 13 additions and 7 deletions
|
@ -125,13 +125,15 @@ module Instructeurs
|
|||
|
||||
def revive
|
||||
avis = Avis.find(params[:id])
|
||||
if avis.answer.blank?
|
||||
AvisMailer.avis_invitation(avis).deliver_later
|
||||
flash.notice = "Un mail de relance a été envoyé à #{avis.email_to_display}"
|
||||
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
||||
else
|
||||
flash.alert = "#{avis.email} a déjà donné son avis"
|
||||
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
||||
if avis.revivable_by?(current_instructeur)
|
||||
if avis.answer.blank?
|
||||
AvisMailer.avis_invitation(avis).deliver_later
|
||||
flash.notice = "Un mail de relance a été envoyé à #{avis.email_to_display}"
|
||||
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
||||
else
|
||||
flash.alert = "#{avis.email} a déjà donné son avis"
|
||||
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -60,6 +60,10 @@ class Avis < ApplicationRecord
|
|||
revoked_at.present?
|
||||
end
|
||||
|
||||
def revivable_by?(reviver)
|
||||
revokable_by?(reviver)
|
||||
end
|
||||
|
||||
def revokable_by?(revocator)
|
||||
revocator.dossiers.include?(dossier) || revocator == claimant
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue