-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Init a tab for instructors to visualise habilitations #655
base: develop
Are you sure you want to change the base?
Changes from all commits
f10713d
625f3a6
ac7dbf5
dfda5d9
6efec27
f2a47fc
85433c0
71af264
fec5f93
8a658f9
3070820
60e71a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ul li.authorization-row { | ||
display: block; | ||
border-bottom: 1px solid rgba(0,0,0,0.1); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Instruction::AuthorizationsController < Instruction::AbstractAuthorizationRequestsController | ||
def index | ||
authorize [:instruction, @authorization_request], :show? | ||
|
||
@authorizations = AuthorizationRequest.find(params[:authorization_request_id]).authorizations.order(created_at: :desc) | ||
end | ||
|
||
private | ||
|
||
def layout_name | ||
'instruction/authorization_request' | ||
end | ||
end |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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 | ||||||||||||||||||||||||||||
|
@@ -45,7 +49,11 @@ def request_as_validated | |||||||||||||||||||||||||||
# rubocop:enable Metrics/AbcSize | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
def latest? | ||||||||||||||||||||||||||||
request.latest_authorization == self | ||||||||||||||||||||||||||||
if definition.stage.exists? | ||||||||||||||||||||||||||||
request.latest_authorization_of_class(authorization_request_class) == self | ||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||
request.latest_authorization == self | ||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
def latest | ||||||||||||||||||||||||||||
|
@@ -56,6 +64,18 @@ def authorization_request | |||||||||||||||||||||||||||
request | ||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||
Comment on lines
+71
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
pas sûr de la syntaxe. Je pense que c'est mieux d'avoir une relation Sinon: def approving_instructor
authorization_request_event
.where(name: 'approve')
.order(created_at: :asc)
.limit(1)
.first
.try(:user)
end |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
private | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
def affect_snapshot_documents(request_as_validated) | ||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,17 @@ | |
<% end %> | ||
</div> | ||
</div> | ||
|
||
<% if @authorization && policy([:instruction, @authorization_request]).show? %> | ||
<div class="fr-pb-2w fr-pl-1w"> | ||
Cette habilitation est liée à la <%= link_to "demande N°#{@authorization_request.id}", instruction_authorization_request_authorizations_path(@authorization_request), class: 'fr-link' %> | ||
<% if @authorization.approving_instructor %> | ||
et a été validée par | ||
<strong><%[email protected]_instructor.email%></strong> | ||
<% end %> | ||
|
||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,5 +6,5 @@ | |||||
<p class="fr-callout__text"> | ||||||
<%= t(".text.#{type}") %> | ||||||
</p> | ||||||
<%= link_to t('.link.text', authorization_id: @authorization_request.latest_authorization.id), latest_authorization_path(@authorization_request), class:"fr-btn" %> | ||||||
<%= link_to t('.link.text', authorization_slug: @authorization_request.latest_authorization.slug), latest_authorization_path(@authorization_request), class:"fr-btn" %> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Si il y plusieurs validations le même jour, le slug sera
Suggested change
|
||||||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,44 @@ | ||
<li id="<%= dom_id(authorization_request_event) %>" class="authorization-request-event"> | ||
<%= | ||
content_tag( | ||
:span, | ||
'', | ||
class: [ | ||
"fr-icon-#{t(".#{authorization_request_event.name}.icon", default: 'error-warning-line')}", | ||
"fr-text-#{t(".#{authorization_request_event.name}.color", default: 'info')}", | ||
] | ||
) | ||
%> | ||
<li id="<%= dom_id(authorization_request_event) %>" class="fr-grid-row"> | ||
<div class="fr-mr-1w"> | ||
<%= | ||
content_tag( | ||
:span, | ||
'', | ||
class: [ | ||
"fr-icon-#{t(".#{authorization_request_event.name}.icon", default: 'error-warning-line')}", | ||
"fr-text-#{t(".#{authorization_request_event.name}.color", default: 'info')}", | ||
] | ||
) | ||
%> | ||
</div> | ||
|
||
<%= | ||
t( | ||
".#{authorization_request_event.name}.text", | ||
**{ | ||
user_full_name: authorization_request_event.user_full_name, | ||
text: authorization_request_event.text, | ||
copied_from_authorization_request_id: authorization_request_event.copied_from_authorization_request_id, | ||
}.compact | ||
).html_safe | ||
%> | ||
<div class="fr-col"> | ||
<%= | ||
t( | ||
".#{authorization_request_event.name}.text", | ||
**{ | ||
user_full_name: authorization_request_event.user_full_name, | ||
text: authorization_request_event.text, | ||
copied_from_authorization_request_id: authorization_request_event.copied_from_authorization_request_id, | ||
}.compact | ||
).html_safe | ||
%> | ||
|
||
<%= time_tag authorization_request_event.created_at do %> | ||
<%= authorization_request_event.created_at.strftime("%d/%m/%Y") %> | ||
<% end %> | ||
<% if authorization_request_event.name == 'approve' %> | ||
<div class="fr-mt-1w"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je suis tiraillé sur le fait d'avoir mis ce morceau ici plutôt que dans le décorateur: d'un côté c'est plus simple et ça reste quand même une info importante à afficher, mais du coup on a une partie de logique vue dans le décorateur et ici. En l'état ça me va, mais j'ai peur que ça devienne peu maintenable à l'avenir. ceci est donc une simple remarque. |
||
<%= link_to( | ||
t('.approve.view_authorization'), | ||
authorization_request_authorization_path(authorization_request_event.authorization_request, authorization_request_event.authorization), | ||
target: '_blank', | ||
class: 'fr-link' | ||
) %> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<div> | ||
<%= time_tag authorization_request_event.created_at do %> | ||
<%= authorization_request_event.created_at.strftime("%d/%m/%Y") %> | ||
<% end %> | ||
</div> | ||
</li> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<h3> <%= t('.title') %> </h3> | ||
|
||
<ul class="fr-mt-2w fr-p-0"> | ||
<% @authorizations.each do |authorization| %> | ||
<li class="authorization-row fr-mb-4w fr-pb-2w"> | ||
<div class="fr-grid-row fr-grid-row--middle"> | ||
<div class="fr-col"> | ||
<ul class="fr-badge-group"> | ||
<li> | ||
<span class="fr-badge fr-badge--no-icon"> | ||
<%= t("authorization.id_badge", id: authorization.id) %> | ||
</span> | ||
</li> | ||
<li> | ||
<span class="fr-badge fr-badge--no-icon"> | ||
<%= t("authorization.date_badge", date: authorization.created_at.strftime('%d/%m/%Y')) %> | ||
</span> | ||
</li> | ||
|
||
<% if authorization.definition.stage.exists? %> | ||
<li> | ||
<%= authorization_stage_badge(authorization) %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
|
||
<% if authorization.approving_instructor.present? %> | ||
<div> | ||
Validé par <strong><%= authorization.approving_instructor.email %></strong> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<div> | ||
<%= link_to t('.show_cta'), authorization_request_authorization_path(@authorization_request, authorization), class: "fr-btn" %> | ||
</div> | ||
</div> | ||
</li> | ||
<% end %> | ||
</ul> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(et en fait avec le commentaire du dessous imo ça peut jarter ici)