feat(ApplicationController): add an helper to retrieve a procedure_presentation from anywhere (target: will be used by Cache::ProcedureDossierPagination)
This commit is contained in:
parent
97c50bae0d
commit
a8e96a843c
2 changed files with 18 additions and 5 deletions
|
@ -426,4 +426,8 @@ class ApplicationController < ActionController::Base
|
||||||
def cast_bool(value)
|
def cast_bool(value)
|
||||||
ActiveRecord::Type::Boolean.new.deserialize(value)
|
ActiveRecord::Type::Boolean.new.deserialize(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def retrieve_procedure_presentation
|
||||||
|
@procedure_presentation ||= current_instructeur.procedure_presentation_for_procedure_id(params[:procedure_id])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -127,12 +127,14 @@ class Instructeur < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def procedure_presentation_for_procedure_id(procedure_id)
|
||||||
|
assign_to = assign_to_for_procedure_id(procedure_id)
|
||||||
|
assign_to.procedure_presentation || assign_to.create_procedure_presentation!
|
||||||
|
end
|
||||||
|
|
||||||
def procedure_presentation_and_errors_for_procedure_id(procedure_id)
|
def procedure_presentation_and_errors_for_procedure_id(procedure_id)
|
||||||
assign_to
|
assign_to = assign_to_for_procedure_id(procedure_id)
|
||||||
.joins(:groupe_instructeur)
|
assign_to.procedure_presentation_or_default_and_errors
|
||||||
.includes(:instructeur, :procedure)
|
|
||||||
.find_by(groupe_instructeurs: { procedure_id: procedure_id })
|
|
||||||
.procedure_presentation_or_default_and_errors
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications_for_dossier(dossier)
|
def notifications_for_dossier(dossier)
|
||||||
|
@ -355,4 +357,11 @@ class Instructeur < ApplicationRecord
|
||||||
.merge(followed_dossiers)
|
.merge(followed_dossiers)
|
||||||
.with_notifications
|
.with_notifications
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assign_to_for_procedure_id(procedure_id)
|
||||||
|
assign_to
|
||||||
|
.joins(:groupe_instructeur)
|
||||||
|
.includes(:instructeur, :procedure)
|
||||||
|
.find_by(groupe_instructeurs: { procedure_id: procedure_id })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue