commit
f4282916e5
20 changed files with 146 additions and 57 deletions
|
@ -45,4 +45,9 @@
|
|||
margin-right: 6px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
p.explication-onglet {
|
||||
margin-bottom: 3 * $default-spacer;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class Admin::ProceduresController < AdminController
|
|||
end
|
||||
|
||||
def new
|
||||
@procedure ||= Procedure.new
|
||||
@procedure ||= Procedure.new(for_individual: true)
|
||||
@availability = Procedure::PATH_AVAILABLE
|
||||
end
|
||||
|
||||
|
@ -269,7 +269,7 @@ class Admin::ProceduresController < AdminController
|
|||
if @procedure&.locked?
|
||||
params.require(:procedure).permit(*editable_params)
|
||||
else
|
||||
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :individual_with_siret, :ask_birthday, :path)
|
||||
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :ask_birthday, :path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ module Gestionnaires
|
|||
include ActionView::Helpers::NumberHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
include CreateAvisConcern
|
||||
include DossierHelper
|
||||
|
||||
after_action :mark_demande_as_read, only: :show
|
||||
after_action :mark_messagerie_as_read, only: [:messagerie, :create_commentaire]
|
||||
|
@ -91,15 +92,23 @@ module Gestionnaires
|
|||
end
|
||||
|
||||
def repasser_en_construction
|
||||
dossier.repasser_en_construction!(current_gestionnaire)
|
||||
flash.notice = 'Dossier repassé en construction.'
|
||||
if dossier.en_construction?
|
||||
flash.notice = 'Le dossier est déjà en construction.'
|
||||
else
|
||||
dossier.repasser_en_construction!(current_gestionnaire)
|
||||
flash.notice = 'Dossier repassé en construction.'
|
||||
end
|
||||
|
||||
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)
|
||||
if dossier.en_instruction?
|
||||
flash.notice = 'Le dossier est déjà en instruction.'
|
||||
else
|
||||
flash.notice = "Le dossier #{dossier.id} a été repassé en instruction."
|
||||
dossier.repasser_en_instruction!(current_gestionnaire)
|
||||
end
|
||||
|
||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||
end
|
||||
|
@ -108,16 +117,20 @@ module Gestionnaires
|
|||
motivation = params[:dossier] && params[:dossier][:motivation]
|
||||
justificatif = params[:dossier] && params[:dossier][:justificatif_motivation]
|
||||
|
||||
case params[:process_action]
|
||||
when "refuser"
|
||||
dossier.refuser!(current_gestionnaire, motivation, justificatif)
|
||||
flash.notice = "Dossier considéré comme refusé."
|
||||
when "classer_sans_suite"
|
||||
dossier.classer_sans_suite!(current_gestionnaire, motivation, justificatif)
|
||||
flash.notice = "Dossier considéré comme sans suite."
|
||||
when "accepter"
|
||||
dossier.accepter!(current_gestionnaire, motivation, justificatif)
|
||||
flash.notice = "Dossier traité avec succès."
|
||||
if dossier.termine?
|
||||
flash.notice = "Le dossier est déjà #{dossier_display_state(dossier, lower: true)}"
|
||||
else
|
||||
case params[:process_action]
|
||||
when "refuser"
|
||||
dossier.refuser!(current_gestionnaire, motivation, justificatif)
|
||||
flash.notice = "Dossier considéré comme refusé."
|
||||
when "classer_sans_suite"
|
||||
dossier.classer_sans_suite!(current_gestionnaire, motivation, justificatif)
|
||||
flash.notice = "Dossier considéré comme sans suite."
|
||||
when "accepter"
|
||||
dossier.accepter!(current_gestionnaire, motivation, justificatif)
|
||||
flash.notice = "Dossier traité avec succès."
|
||||
end
|
||||
end
|
||||
|
||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||
|
|
|
@ -24,7 +24,6 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
|||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
for_individual: Field::Boolean,
|
||||
individual_with_siret: Field::Boolean,
|
||||
auto_archive_on: Field::DateTime,
|
||||
published_at: Field::DateTime,
|
||||
hidden_at: Field::DateTime,
|
||||
|
@ -75,7 +74,6 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
|||
:types_de_champ_private,
|
||||
:types_de_piece_justificative,
|
||||
:for_individual,
|
||||
:individual_with_siret,
|
||||
:auto_archive_on,
|
||||
:gestionnaires,
|
||||
:initiated_mail_template,
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
class Champs::DecimalNumberChamp < Champ
|
||||
validates :value, numericality: { allow_nil: true, allow_blank: true }
|
||||
validates :value, numericality: {
|
||||
allow_nil: true,
|
||||
allow_blank: true,
|
||||
message: -> (object, data) {
|
||||
"« #{object.libelle} » " + object.errors.generate_message(data[:attribute].downcase, :not_a_number)
|
||||
}
|
||||
}
|
||||
|
||||
def for_export
|
||||
processed_value
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
class Champs::IntegerNumberChamp < Champ
|
||||
validates :value, numericality: { only_integer: true, allow_nil: true, allow_blank: true }
|
||||
validates :value, numericality: {
|
||||
only_integer: true,
|
||||
allow_nil: true,
|
||||
allow_blank: true,
|
||||
message: -> (object, data) {
|
||||
"« #{object.libelle} » " + object.errors.generate_message(data[:attribute].downcase, :not_an_integer)
|
||||
}
|
||||
}
|
||||
|
||||
def for_export
|
||||
processed_value
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
class Dossier < ApplicationRecord
|
||||
include DossierFilteringConcern
|
||||
|
||||
self.ignored_columns = [:expects_multiple_submissions]
|
||||
|
||||
enum state: {
|
||||
brouillon: 'brouillon',
|
||||
en_construction: 'en_construction',
|
||||
|
@ -227,7 +225,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def messagerie_available?
|
||||
!brouillon? && !archived && !procedure.archivee?
|
||||
!brouillon? && !archived
|
||||
end
|
||||
|
||||
def retention_end_date
|
||||
|
|
|
@ -3,6 +3,8 @@ require Rails.root.join('lib', 'percentile')
|
|||
class Procedure < ApplicationRecord
|
||||
MAX_DUREE_CONSERVATION = 36
|
||||
|
||||
self.ignored_columns = [:individual_with_siret, :expects_multiple_submissions]
|
||||
|
||||
has_many :types_de_piece_justificative, -> { ordered }, inverse_of: :procedure, dependent: :destroy
|
||||
has_many :types_de_champ, -> { root.public_only.ordered }, inverse_of: :procedure, dependent: :destroy
|
||||
has_many :types_de_champ_private, -> { root.private_only.ordered }, class_name: 'TypeDeChamp', inverse_of: :procedure, dependent: :destroy
|
||||
|
|
|
@ -30,7 +30,7 @@ class ProcedurePresentation < ApplicationRecord
|
|||
)
|
||||
end
|
||||
|
||||
if !procedure.for_individual || (procedure.for_individual && procedure.individual_with_siret)
|
||||
if !procedure.for_individual
|
||||
fields.push(
|
||||
field_hash('SIREN', 'etablissement', 'entreprise_siren'),
|
||||
field_hash('Forme juridique', 'etablissement', 'entreprise_forme_juridique'),
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
%h4 À qui s’adresse ma démarche ?
|
||||
.checkbox
|
||||
%label
|
||||
= f.radio_button :for_individual, 1, :checked => true
|
||||
= f.radio_button :for_individual, true
|
||||
%b Ma démarche s’adresse à un particulier
|
||||
|
||||
%p
|
||||
|
@ -108,7 +108,7 @@
|
|||
|
||||
.checkbox
|
||||
%label
|
||||
= f.radio_button :for_individual, 0, :checked => false
|
||||
= f.radio_button :for_individual, false
|
||||
%b Ma démarche s’adresse à une personne morale
|
||||
|
||||
%p
|
||||
|
|
|
@ -44,6 +44,17 @@
|
|||
= render partial: "download_dossiers", locals: { procedure: @procedure }
|
||||
|
||||
.container
|
||||
- if @statut == 'a-suivre'
|
||||
%p.explication-onglet Aucun instructeur n'est affecté au suivi de ces dossiers. Soyez le premier !
|
||||
- if @statut == 'suivis'
|
||||
%p.explication-onglet Les dossiers qui sont dans cet onglet sont uniquement ceux que vous suivez. Vous pouvez échanger avec le demandeur jusqu'à pouvoir les accepter, les refuser ou les classer sans suite.
|
||||
- if @statut == 'traites'
|
||||
%p.explication-onglet Les dossiers dans cet onglet sont terminés : ils ont été acceptés, refusés ou classés sans suite.
|
||||
- if @statut == 'tous'
|
||||
%p.explication-onglet Tous les dossiers qui ont été déposés sur cette démarche, sans aucun filtre.
|
||||
- if @statut == 'archives'
|
||||
%p.explication-onglet Les dossiers de cet onglet sont archivés : vous ne pouvez plus y répondre, et les demandeurs ne peuvent plus les modifier.
|
||||
|
||||
- if @dossiers.present? || @current_filters.count > 0
|
||||
%span.dropdown
|
||||
%button.button.dropdown-button
|
||||
|
|
|
@ -128,6 +128,7 @@ fr:
|
|||
messages:
|
||||
blank: "doit être rempli"
|
||||
not_a_number: 'doit être un nombre'
|
||||
not_an_integer: 'doit être un nombre entier (sans chiffres après la virgule)'
|
||||
greater_than: "doit être supérieur à %{count}"
|
||||
greater_than_or_equal_to: "doit être supérieur ou égal à %{count}"
|
||||
less_than: "doit être inférieur à %{count}"
|
||||
|
|
5
config/locales/models/champs/fr.yml
Normal file
5
config/locales/models/champs/fr.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
fr:
|
||||
activerecord:
|
||||
attributes:
|
||||
champs:
|
||||
value: La valeur du champ
|
|
@ -323,7 +323,6 @@ describe Admin::ProceduresController, type: :controller do
|
|||
it { expect(subject.direction).to eq procedure_params[:direction] }
|
||||
|
||||
it { expect(subject.for_individual).not_to eq procedure_params[:for_individual] }
|
||||
it { expect(subject.individual_with_siret).not_to eq procedure_params[:individual_with_siret] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -128,21 +128,51 @@ describe Gestionnaires::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
describe '#repasser_en_construction' do
|
||||
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||
|
||||
before do
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
post :repasser_en_construction,
|
||||
params: { procedure_id: procedure.id, dossier_id: dossier.id },
|
||||
format: 'js'
|
||||
end
|
||||
|
||||
subject { post :repasser_en_construction, params: { procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) }
|
||||
it { expect(response).to have_http_status(:ok) }
|
||||
it { expect(response.body).to include('.state-button') }
|
||||
|
||||
it 'change state to en_construction' do
|
||||
subject
|
||||
context 'when the dossier has already been put en_construction' do
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:en_construction))
|
||||
it 'warns about the error, but doesn’t raise' do
|
||||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction))
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#repasser_en_instruction' do
|
||||
let(:dossier) { create(:dossier, :refuse, procedure: procedure) }
|
||||
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
post :repasser_en_instruction,
|
||||
params: { procedure_id: procedure.id, dossier_id: dossier.id },
|
||||
format: 'js'
|
||||
end
|
||||
|
||||
it { expect(subject.body).to include('.state-button') }
|
||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
||||
it { expect(response).to have_http_status(:ok) }
|
||||
it { expect(response.body).to include('.state-button') }
|
||||
|
||||
context 'when the dossier has already been put en_instruction' do
|
||||
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||
|
||||
it 'warns about the error, but doesn’t raise' do
|
||||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#terminer' do
|
||||
|
@ -319,6 +349,21 @@ describe Gestionnaires::DossiersController, type: :controller do
|
|||
it { expect(subject.body).to include('.state-button') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a dossier is already closed' do
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
|
||||
before { allow(dossier).to receive(:accepter!) }
|
||||
|
||||
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id, dossier: { justificatif_motivation: fake_justificatif } }, format: 'js' }
|
||||
|
||||
it 'does not close it again' do
|
||||
subject
|
||||
|
||||
expect(dossier).not_to have_received(:accepter!)
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#create_commentaire" do
|
||||
|
|
|
@ -36,6 +36,8 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
|
|||
click_on 'from-scratch'
|
||||
|
||||
expect(page).to have_current_path(new_admin_procedure_path)
|
||||
expect(find('#procedure_for_individual_true')).to be_checked
|
||||
expect(find('#procedure_for_individual_false')).not_to be_checked
|
||||
fill_in 'procedure_duree_conservation_dossiers_dans_ds', with: '3'
|
||||
fill_in 'procedure_duree_conservation_dossiers_hors_ds', with: '6'
|
||||
click_on 'save-procedure'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Champs::DecimalNumberChamp do
|
||||
subject { Champs::DecimalNumberChamp.new(value: value) }
|
||||
subject { build(:champ_decimal_number, value: value).tap(&:valid?) }
|
||||
|
||||
describe '#valid?' do
|
||||
context 'when the value is integer number' do
|
||||
|
@ -20,6 +20,7 @@ describe Champs::DecimalNumberChamp do
|
|||
let(:value) { 'toto' }
|
||||
|
||||
it { is_expected.to_not be_valid }
|
||||
it { expect(subject.errors[:value]).to eq(["« #{subject.libelle} » doit être un nombre"]) }
|
||||
end
|
||||
|
||||
context 'when the value is blank' do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Champs::IntegerNumberChamp do
|
||||
subject { Champs::IntegerNumberChamp.new(value: value) }
|
||||
subject { build(:champ_integer_number, value: value).tap(&:valid?) }
|
||||
|
||||
describe '#valid?' do
|
||||
context 'when the value is integer number' do
|
||||
|
@ -14,12 +14,14 @@ describe Champs::IntegerNumberChamp do
|
|||
let(:value) { 2.6 }
|
||||
|
||||
it { is_expected.to_not be_valid }
|
||||
it { expect(subject.errors[:value]).to eq(["« #{subject.libelle} » doit être un nombre entier (sans chiffres après la virgule)"]) }
|
||||
end
|
||||
|
||||
context 'when the value is not a number' do
|
||||
let(:value) { 'toto' }
|
||||
|
||||
it { is_expected.to_not be_valid }
|
||||
it { expect(subject.errors[:value]).to eq(["« #{subject.libelle} » doit être un nombre entier (sans chiffres après la virgule)"]) }
|
||||
end
|
||||
|
||||
context 'when the value is blank' do
|
||||
|
|
|
@ -747,23 +747,17 @@ describe Dossier do
|
|||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context "dossier is submitted" do
|
||||
before { dossier.state = Dossier.states.fetch(:en_instruction) }
|
||||
|
||||
it { is_expected.to be true }
|
||||
end
|
||||
|
||||
context "dossier is archived" do
|
||||
before { dossier.archived = true }
|
||||
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context "procedure is archived" do
|
||||
before { procedure.archived_at = Date.today }
|
||||
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context "procedure is not archived, dossier is not archived" do
|
||||
before { dossier.state = Dossier.states.fetch(:en_instruction) }
|
||||
|
||||
it { is_expected.to be true }
|
||||
end
|
||||
end
|
||||
|
||||
context "retention date" do
|
||||
|
|
18
yarn.lock
18
yarn.lock
|
@ -5068,7 +5068,7 @@ locate-path@^3.0.0:
|
|||
p-locate "^3.0.0"
|
||||
path-exists "^3.0.0"
|
||||
|
||||
lodash._reinterpolate@~3.0.0:
|
||||
lodash._reinterpolate@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
|
||||
integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=
|
||||
|
@ -5094,19 +5094,19 @@ lodash.tail@^4.1.1:
|
|||
integrity sha1-0jM6NtnncXyK0vfKyv7HwytERmQ=
|
||||
|
||||
lodash.template@^4.2.4:
|
||||
version "4.4.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0"
|
||||
integrity sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A=
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab"
|
||||
integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A==
|
||||
dependencies:
|
||||
lodash._reinterpolate "~3.0.0"
|
||||
lodash._reinterpolate "^3.0.0"
|
||||
lodash.templatesettings "^4.0.0"
|
||||
|
||||
lodash.templatesettings@^4.0.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz#2b4d4e95ba440d915ff08bc899e4553666713316"
|
||||
integrity sha1-K01OlbpEDZFf8IvImeRVNmZxMxY=
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz#e481310f049d3cf6d47e912ad09313b154f0fb33"
|
||||
integrity sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==
|
||||
dependencies:
|
||||
lodash._reinterpolate "~3.0.0"
|
||||
lodash._reinterpolate "^3.0.0"
|
||||
|
||||
lodash.uniq@^4.5.0:
|
||||
version "4.5.0"
|
||||
|
|
Loading…
Reference in a new issue