Merge pull request #8484 from E-L-T/8459-add-revived-at-field-to-avis
feat(avis): display remind in instructor view
This commit is contained in:
commit
7dafe9d11f
8 changed files with 24 additions and 18 deletions
|
@ -14,17 +14,12 @@ module Instructeurs
|
|||
end
|
||||
end
|
||||
|
||||
def revive
|
||||
def remind
|
||||
avis = Avis.find(params[:id])
|
||||
if avis.revivable_by?(current_instructeur)
|
||||
if avis.answer.blank?
|
||||
AvisMailer.avis_invitation(avis).deliver_later
|
||||
flash.notice = "Un mail de relance a été envoyé à #{avis.expert.email}"
|
||||
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
||||
else
|
||||
flash.alert = "#{avis.expert.email} a déjà donné son avis"
|
||||
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
||||
end
|
||||
if avis.remind_by!(current_instructeur)
|
||||
AvisMailer.avis_invitation(avis).deliver_later
|
||||
flash.notice = "Un mail de relance a été envoyé à #{avis.expert.email}"
|
||||
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -84,8 +84,8 @@ class Avis < ApplicationRecord
|
|||
revoked_at.present?
|
||||
end
|
||||
|
||||
def revivable_by?(reviver)
|
||||
revokable_by?(reviver)
|
||||
def remindable_by?(reminder)
|
||||
revokable_by?(reminder)
|
||||
end
|
||||
|
||||
def revokable_by?(revocator)
|
||||
|
@ -101,4 +101,9 @@ class Avis < ApplicationRecord
|
|||
destroy!
|
||||
end
|
||||
end
|
||||
|
||||
def remind_by!(revocator)
|
||||
return false if !remindable_by?(revocator) || answer.present?
|
||||
update!(reminded_at: Time.zone.now)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,10 +36,13 @@
|
|||
%span.fr-text--xs.fr-text-mention--grey
|
||||
= t('en_attente', scope: 'views.shared.avis')
|
||||
|
|
||||
%span= link_to(t('revive', scope: 'helpers.label'), revive_instructeur_avis_path(avis.procedure, avis), data: { confirm: t('revive', scope: 'helpers.confirmation', email: avis.expert.email) })
|
||||
%span= link_to(t('remind', scope: 'helpers.label'), remind_instructeur_avis_path(avis.procedure, avis), data: { confirm: t('remind', scope: 'helpers.confirmation', email: avis.expert.email) })
|
||||
- if avis.revokable_by?(current_instructeur)
|
||||
|
|
||||
= link_to(t('revoke', scope: 'helpers.label'), revoquer_instructeur_avis_path(avis.procedure, avis), data: { confirm: t('revoke', scope: 'helpers.confirmation', email: avis.expert.email) }, method: :patch)
|
||||
- if avis.reminded_at
|
||||
%span.date.fr-text--xs.fr-text-mention--grey{ class: highlight_if_unseen_class(avis_seen_at, avis.reminded_at) }
|
||||
= t('relance_effectuee_le', scope: 'views.shared.avis', date: l(avis.reminded_at, format: '%d/%m/%y à %H:%M'))
|
||||
- if avis.introduction_file.attached?
|
||||
= render Attachment::ShowComponent.new(attachment: avis.introduction_file.attachment)
|
||||
.answer-body.mb-3
|
||||
|
|
|
@ -13,9 +13,9 @@ fr:
|
|||
one: Inviter aussi l’expert sur le dossier lié n° %{ids}
|
||||
other: Inviter aussi l’expert sur les dossiers liés n° %{ids}
|
||||
revoke: Révoquer la demande d’avis
|
||||
revive: Relancer l’expert
|
||||
remind: Relancer l’expert
|
||||
hint:
|
||||
confidentiel: "Cet avis n’est pas affiché avec les autres experts consultés"
|
||||
confirmation:
|
||||
revoke: "Souhaitez-vous révoquer la demande d’avis à %{email} ?"
|
||||
revive: "Souhaitez-vous relancer %{email} ?"
|
||||
remind: "Souhaitez-vous relancer %{email} ?"
|
||||
|
|
|
@ -7,6 +7,7 @@ en:
|
|||
avis:
|
||||
demande_envoyee_le: "Feedback send at %{date}"
|
||||
demande_revoquee_le: "Feedback revoked at %{date}"
|
||||
relance_effectuee_le: "Reminder sent at %{date}"
|
||||
reponse_donnee_le: "Response sent at %{date}"
|
||||
en_attente: "Waiting for response"
|
||||
france_connect_login:
|
||||
|
|
|
@ -7,6 +7,7 @@ fr:
|
|||
avis:
|
||||
demande_envoyee_le: "Demande d’avis envoyée le %{date}"
|
||||
demande_revoquee_le: "Demande d’avis révoquée le %{date}"
|
||||
relance_effectuee_le: "Relance effectuée le %{date}"
|
||||
reponse_donnee_le: "Réponse donnée le %{date}"
|
||||
en_attente: "En attente de réponse"
|
||||
france_connect_login:
|
||||
|
|
|
@ -393,7 +393,7 @@ Rails.application.routes.draw do
|
|||
get '', action: 'procedure', on: :collection, as: :procedure
|
||||
member do
|
||||
patch 'revoquer'
|
||||
get 'revive'
|
||||
get 'remind'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -24,15 +24,16 @@ describe Instructeurs::AvisController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'revive' do
|
||||
describe 'remind' do
|
||||
before do
|
||||
allow(AvisMailer).to receive(:avis_invitation).and_return(double(deliver_later: nil))
|
||||
end
|
||||
|
||||
it 'sends a reminder to the expert' do
|
||||
get :revive, params: { procedure_id: procedure.id, id: avis.id }
|
||||
get :remind, params: { procedure_id: procedure.id, id: avis.id }
|
||||
expect(AvisMailer).to have_received(:avis_invitation).once.with(avis)
|
||||
expect(flash.notice).to eq("Un mail de relance a été envoyé à #{avis.expert.email}")
|
||||
expect(avis.reload.reminded_at).to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue