2017-12-12 16:44:30 +01:00
|
|
|
module DossierLinkHelper
|
2018-12-28 17:22:51 +01:00
|
|
|
def dossier_linked_path(user, dossier)
|
|
|
|
if user.is_a?(Gestionnaire)
|
|
|
|
if dossier.procedure.gestionnaires.include?(user)
|
|
|
|
gestionnaire_dossier_path(dossier.procedure, dossier)
|
|
|
|
else
|
|
|
|
avis = dossier.avis.find_by(gestionnaire: user)
|
|
|
|
if avis.present?
|
|
|
|
gestionnaire_avis_path(avis)
|
|
|
|
end
|
2017-12-12 16:44:30 +01:00
|
|
|
end
|
2018-12-28 17:22:51 +01:00
|
|
|
elsif user.owns_or_invite?(dossier)
|
|
|
|
dossier_path(dossier)
|
2017-12-12 16:44:30 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|