diff --git a/app/models/authorization.rb b/app/models/authorization.rb index 749b5f466..8e7187e4d 100644 --- a/app/models/authorization.rb +++ b/app/models/authorization.rb @@ -22,6 +22,10 @@ class Authorization < ApplicationRecord inverse_of: :authorization, dependent: :destroy + has_many :authorization_request_event, + as: :entity, + dependent: :nullify + scope :validated, -> { joins(:request).where(authorization_requests: { state: 'validated' }) } delegate :name, :kind, to: :request @@ -64,6 +68,14 @@ def definition authorization_request_class.constantize.definition end + def approving_instructor + authorization_request_event + .where(name: 'approve') + .order(created_at: :desc) + .first + .try(:user) + end + private def affect_snapshot_documents(request_as_validated) diff --git a/app/views/authorization_request_forms/build/_header.html.erb b/app/views/authorization_request_forms/build/_header.html.erb index 42ab307b0..1dc17c9ef 100644 --- a/app/views/authorization_request_forms/build/_header.html.erb +++ b/app/views/authorization_request_forms/build/_header.html.erb @@ -32,7 +32,12 @@ <% if @authorization && policy([:instruction, @authorization_request]).show? %>
- Cette habilitation a été délivrée suite à la <%= link_to "demande N°#{@authorization_request.id}", instruction_authorization_request_authorizations_path(@authorization_request), class: 'fr-link' %> + Cette habilitation a été validée + <% if @authorization.approving_instructor %> + par + <%=@authorization.approving_instructor.email%> + <% end %> + durant la <%= link_to "demande N°#{@authorization_request.id}", instruction_authorization_request_authorizations_path(@authorization_request), class: 'fr-link' %>
<% end %> diff --git a/app/views/instruction/authorizations/index.html.erb b/app/views/instruction/authorizations/index.html.erb index c2b9d8cf4..ddff94eb3 100644 --- a/app/views/instruction/authorizations/index.html.erb +++ b/app/views/instruction/authorizations/index.html.erb @@ -4,24 +4,32 @@ <% @authorizations.each do |authorization| %>
  • - +
    <%= link_to t('.show_cta'), authorization_request_authorization_path(@authorization_request, authorization), class: "fr-btn" %> diff --git a/features/instructeurs/historique_habilitation.feature b/features/instructeurs/historique_habilitation.feature index b7fec7d02..93eed0471 100644 --- a/features/instructeurs/historique_habilitation.feature +++ b/features/instructeurs/historique_habilitation.feature @@ -100,4 +100,4 @@ Fonctionnalité: Instruction: historique habilitation Et que je clique sur "Consulter" Et que je clique sur "Historique" Et que je clique sur "Consulter l'habilitation" - Alors la page contient "Cette habilitation a été délivrée suite à la demande N°" \ No newline at end of file + Alors la page contient "Cette habilitation a été validée par" \ No newline at end of file