2017-12-12 16:44:30 +01:00
|
|
|
module DossierLinkHelper
|
2018-12-28 17:22:51 +01:00
|
|
|
def dossier_linked_path(user, dossier)
|
2019-08-06 11:02:54 +02:00
|
|
|
if user.is_a?(Instructeur)
|
|
|
|
if dossier.procedure.instructeurs.include?(user)
|
|
|
|
instructeur_dossier_path(dossier.procedure, dossier)
|
2018-12-28 17:22:51 +01:00
|
|
|
else
|
2019-08-06 11:02:54 +02:00
|
|
|
avis = dossier.avis.find_by(instructeur: user)
|
2018-12-28 17:22:51 +01:00
|
|
|
if avis.present?
|
2019-08-06 11:02:54 +02:00
|
|
|
instructeur_avis_path(avis)
|
2018-12-28 17:22:51 +01:00
|
|
|
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
|