Merge pull request #4022 from betagouv/fix_3683_redo_refused_dossier
Fix 3683 redo refused dossier
This commit is contained in:
commit
87cf862e10
10 changed files with 59 additions and 18 deletions
|
@ -183,7 +183,7 @@
|
|||
color: $black;
|
||||
padding: $default-padding;
|
||||
|
||||
h4 {
|
||||
.title {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
|
@ -266,6 +266,10 @@
|
|||
color: $black;
|
||||
margin-bottom: $default-spacer;
|
||||
}
|
||||
|
||||
&.with-top-border {
|
||||
border-top: 1px solid $grey;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-form {
|
||||
|
|
|
@ -93,6 +93,13 @@ module Gestionnaires
|
|||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||
end
|
||||
|
||||
def repasser_en_instruction
|
||||
flash.notice = "Le dossier #{dossier.id} a été repassé en instruction."
|
||||
dossier.repasser_en_instruction!(current_gestionnaire)
|
||||
|
||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||
end
|
||||
|
||||
def terminer
|
||||
motivation = params[:dossier] && params[:dossier][:motivation]
|
||||
justificatif = params[:dossier] && params[:dossier][:justificatif_motivation]
|
||||
|
|
|
@ -20,16 +20,6 @@ module Manager
|
|||
# Custom actions
|
||||
#
|
||||
|
||||
def change_state_to_instruction
|
||||
dossier = Dossier.find(params[:id])
|
||||
dossier.update(state: Dossier.states.fetch(:en_instruction), processed_at: nil, motivation: nil)
|
||||
dossier.attestation&.destroy
|
||||
logger.info("Le dossier #{dossier.id} est repassé en instruction par #{current_administration.email}")
|
||||
flash[:notice] = "Le dossier #{dossier.id} est repassé en instruction"
|
||||
DossierMailer.notify_revert_to_instruction(dossier).deliver_later
|
||||
redirect_to manager_dossier_path(dossier)
|
||||
end
|
||||
|
||||
def hide
|
||||
dossier = Dossier.find(params[:id])
|
||||
deleted_dossier = dossier.hide!(current_administration)
|
||||
|
|
|
@ -5,7 +5,7 @@ module DossierHelper
|
|||
elsif dossier.sans_suite?
|
||||
'without-continuation'
|
||||
elsif dossier.refuse?
|
||||
'refuse'
|
||||
'refused'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -302,6 +302,14 @@ class Dossier < ApplicationRecord
|
|||
log_dossier_operation(gestionnaire, :repasser_en_construction)
|
||||
end
|
||||
|
||||
def repasser_en_instruction!(gestionnaire)
|
||||
update(state: Dossier.states.fetch(:en_instruction), processed_at: nil, motivation: nil)
|
||||
attestation&.destroy
|
||||
DossierMailer.notify_revert_to_instruction(self).deliver_later
|
||||
|
||||
log_dossier_operation(gestionnaire, :repasser_en_instruction)
|
||||
end
|
||||
|
||||
def accepter!(gestionnaire, motivation, justificatif = nil)
|
||||
self.motivation = motivation
|
||||
self.en_instruction_at ||= Time.zone.now
|
||||
|
|
|
@ -2,6 +2,7 @@ class DossierOperationLog < ApplicationRecord
|
|||
enum operation: {
|
||||
passer_en_instruction: 'passer_en_instruction',
|
||||
repasser_en_construction: 'repasser_en_construction',
|
||||
repasser_en_instruction: 'repasser_en_instruction',
|
||||
accepter: 'accepter',
|
||||
refuser: 'refuser',
|
||||
classer_sans_suite: 'classer_sans_suite',
|
||||
|
|
|
@ -58,14 +58,24 @@
|
|||
= dossier_display_state(dossier, lower: true)
|
||||
.dropdown-content.fade-in-down.terminated
|
||||
- if dossier.motivation.present?
|
||||
%h4 Motivation
|
||||
%h4.title Motivation
|
||||
%p.dossier-motivation= dossier.motivation
|
||||
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
|
||||
|
||||
- if dossier.attestation.present?
|
||||
%h4 Attestation
|
||||
%h4.title Attestation
|
||||
%p.attestation L'acceptation du dossier a envoyé automatiquement une attestation au demandeur
|
||||
= link_to "Voir l'attestation", attestation_gestionnaire_dossier_path(dossier.procedure, dossier), target: '_blank', rel: 'noopener', class: 'button'
|
||||
|
||||
|
||||
- if dossier.refuse? || dossier.sans_suite?
|
||||
%ul.dropdown-items.with-top-border
|
||||
%li
|
||||
= link_to repasser_en_instruction_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, data: { remote:true, confirm: "Voulez vous remettre le dossier #{dossier.id} en instruction ?" } do
|
||||
%span.icon.in-progress
|
||||
.dropdown-description
|
||||
%h4 Repasser en instruction
|
||||
L’usager sera notifié que son dossier est réexaminé.
|
||||
- else
|
||||
%span.label{ class: button_or_label_class(dossier) }
|
||||
= dossier_display_state(dossier, lower: true)
|
||||
|
|
|
@ -28,9 +28,6 @@ as well as a link to its edit page.
|
|||
</h1>
|
||||
|
||||
<div>
|
||||
<% if dossier.termine? %>
|
||||
<%= link_to 'Repasser en instruction', change_state_to_instruction_manager_dossier_path(dossier), method: :post, class: 'button', data: { confirm: "Repasser en instruction ?" } %>
|
||||
<% end %>
|
||||
<% if dossier.hidden_at.nil? %>
|
||||
<%= link_to 'Supprimer le dossier', hide_manager_dossier_path(dossier), method: :post, class: 'button', data: { confirm: "Confirmez vous la suppression du dossier ?" } %>
|
||||
<% end %>
|
||||
|
|
|
@ -15,7 +15,6 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
resources :dossiers, only: [:index, :show] do
|
||||
post 'change_state_to_instruction', on: :member
|
||||
post 'hide', on: :member
|
||||
end
|
||||
|
||||
|
@ -325,6 +324,7 @@ Rails.application.routes.draw do
|
|||
post 'commentaire' => 'dossiers#create_commentaire'
|
||||
post 'passer-en-instruction' => 'dossiers#passer_en_instruction'
|
||||
post 'repasser-en-construction' => 'dossiers#repasser_en_construction'
|
||||
post 'repasser-en-instruction' => 'dossiers#repasser_en_instruction'
|
||||
post 'terminer'
|
||||
post 'send-to-instructeurs' => 'dossiers#send_to_instructeurs'
|
||||
post 'avis' => 'dossiers#create_avis'
|
||||
|
|
|
@ -987,4 +987,28 @@ describe Dossier do
|
|||
it { expect(last_operation.operation).to eq('supprimer') }
|
||||
it { expect(last_operation.automatic_operation?).to be_falsey }
|
||||
end
|
||||
|
||||
describe '#repasser_en_instruction!' do
|
||||
let(:dossier) { create(:dossier, :refuse, :with_attestation) }
|
||||
let!(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:last_operation) { dossier.dossier_operation_logs.last }
|
||||
|
||||
before do
|
||||
Timecop.freeze
|
||||
allow(DossierMailer).to receive(:notify_revert_to_instruction)
|
||||
.and_return(double(deliver_later: true))
|
||||
dossier.repasser_en_instruction!(gestionnaire)
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.state).to eq('en_instruction') }
|
||||
it { expect(dossier.processed_at).to be_nil }
|
||||
it { expect(dossier.motivation).to be_nil }
|
||||
it { expect(dossier.attestation).to be_nil }
|
||||
it { expect(last_operation.operation).to eq('repasser_en_instruction') }
|
||||
it { expect(JSON.parse(last_operation.serialized.download)['author']['email']).to eq(gestionnaire.email) }
|
||||
it { expect(DossierMailer).to have_received(:notify_revert_to_instruction).with(dossier) }
|
||||
|
||||
after { Timecop.return }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue