commit
c8c2633bdb
18 changed files with 77 additions and 36 deletions
|
@ -189,7 +189,7 @@ GEM
|
||||||
activejob (>= 5.0)
|
activejob (>= 5.0)
|
||||||
devise (>= 4.0)
|
devise (>= 4.0)
|
||||||
diff-lcs (1.3)
|
diff-lcs (1.3)
|
||||||
discard (1.1.0)
|
discard (1.2.0)
|
||||||
activerecord (>= 4.2, < 7)
|
activerecord (>= 4.2, < 7)
|
||||||
domain_name (0.5.20180417)
|
domain_name (0.5.20180417)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
|
|
|
@ -8,11 +8,11 @@ module Manager
|
||||||
# this will be used to set the records shown on the `index` action.
|
# this will be used to set the records shown on the `index` action.
|
||||||
def scoped_resource
|
def scoped_resource
|
||||||
if unfiltered_list?
|
if unfiltered_list?
|
||||||
# Don't display deleted dossiers in the unfiltered list…
|
# Don't display discarded dossiers in the unfiltered list…
|
||||||
Dossier
|
Dossier.kept
|
||||||
else
|
else
|
||||||
# … but allow them to be searched and displayed.
|
# … but allow them to be searched and displayed.
|
||||||
Dossier.unscope(:where)
|
Dossier.with_discarded
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ module Manager
|
||||||
# Custom actions
|
# Custom actions
|
||||||
#
|
#
|
||||||
|
|
||||||
def hide
|
def discard
|
||||||
dossier = Dossier.find(params[:id])
|
dossier = Dossier.find(params[:id])
|
||||||
dossier.delete_and_keep_track!(current_administration, :manager_request)
|
dossier.discard_and_keep_track!(current_administration, :manager_request)
|
||||||
|
|
||||||
logger.info("Le dossier #{dossier.id} est supprimé par #{current_administration.email}")
|
logger.info("Le dossier #{dossier.id} est supprimé par #{current_administration.email}")
|
||||||
flash[:notice] = "Le dossier #{dossier.id} a été supprimé."
|
flash[:notice] = "Le dossier #{dossier.id} a été supprimé."
|
||||||
|
|
|
@ -209,7 +209,7 @@ module Users
|
||||||
dossier = current_user.dossiers.includes(:user, procedure: :administrateurs).find(params[:id])
|
dossier = current_user.dossiers.includes(:user, procedure: :administrateurs).find(params[:id])
|
||||||
|
|
||||||
if dossier.can_be_deleted_by_user?
|
if dossier.can_be_deleted_by_user?
|
||||||
dossier.delete_and_keep_track!(current_user, :user_request)
|
dossier.discard_and_keep_track!(current_user, :user_request)
|
||||||
flash.notice = 'Votre dossier a bien été supprimé.'
|
flash.notice = 'Votre dossier a bien été supprimé.'
|
||||||
redirect_to dossiers_path
|
redirect_to dossiers_path
|
||||||
else
|
else
|
||||||
|
|
|
@ -14,7 +14,6 @@ class AdministrateurDashboard < Administrate::BaseDashboard
|
||||||
updated_at: Field::DateTime,
|
updated_at: Field::DateTime,
|
||||||
procedures: Field::HasMany.with_options(limit: 20),
|
procedures: Field::HasMany.with_options(limit: 20),
|
||||||
registration_state: Field::String.with_options(searchable: false),
|
registration_state: Field::String.with_options(searchable: false),
|
||||||
current_sign_in_at: Field::DateTime,
|
|
||||||
features: FeaturesField,
|
features: FeaturesField,
|
||||||
email: Field::Email.with_options(searchable: false)
|
email: Field::Email.with_options(searchable: false)
|
||||||
}.freeze
|
}.freeze
|
||||||
|
@ -39,7 +38,6 @@ class AdministrateurDashboard < Administrate::BaseDashboard
|
||||||
:created_at,
|
:created_at,
|
||||||
:updated_at,
|
:updated_at,
|
||||||
:registration_state,
|
:registration_state,
|
||||||
:current_sign_in_at,
|
|
||||||
:features,
|
:features,
|
||||||
:procedures
|
:procedures
|
||||||
].freeze
|
].freeze
|
||||||
|
|
|
@ -12,7 +12,6 @@ class InstructeurDashboard < Administrate::BaseDashboard
|
||||||
user: Field::HasOne.with_options(searchable: true, searchable_field: 'email'),
|
user: Field::HasOne.with_options(searchable: true, searchable_field: 'email'),
|
||||||
created_at: Field::DateTime,
|
created_at: Field::DateTime,
|
||||||
updated_at: Field::DateTime,
|
updated_at: Field::DateTime,
|
||||||
current_sign_in_at: Field::DateTime,
|
|
||||||
dossiers: Field::HasMany,
|
dossiers: Field::HasMany,
|
||||||
procedures: Field::HasMany,
|
procedures: Field::HasMany,
|
||||||
features: FeaturesField
|
features: FeaturesField
|
||||||
|
@ -35,7 +34,6 @@ class InstructeurDashboard < Administrate::BaseDashboard
|
||||||
:dossiers,
|
:dossiers,
|
||||||
:id,
|
:id,
|
||||||
:user,
|
:user,
|
||||||
:current_sign_in_at,
|
|
||||||
:created_at,
|
:created_at,
|
||||||
:features
|
:features
|
||||||
].freeze
|
].freeze
|
||||||
|
|
|
@ -92,4 +92,8 @@ class Administrateur < ApplicationRecord
|
||||||
|
|
||||||
destroy
|
destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# required to display feature flags field in manager
|
||||||
|
def features
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -340,6 +340,10 @@ class Dossier < ApplicationRecord
|
||||||
brouillon? || en_construction?
|
brouillon? || en_construction?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_be_deleted_by_manager?
|
||||||
|
kept? && can_be_deleted_by_user?
|
||||||
|
end
|
||||||
|
|
||||||
def messagerie_available?
|
def messagerie_available?
|
||||||
!brouillon? && !archived
|
!brouillon? && !archived
|
||||||
end
|
end
|
||||||
|
@ -467,7 +471,7 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_and_keep_track!(author, reason)
|
def discard_and_keep_track!(author, reason)
|
||||||
if keep_track_on_deletion? && en_construction?
|
if keep_track_on_deletion? && en_construction?
|
||||||
deleted_dossier = DeletedDossier.create_from_dossier(self, reason)
|
deleted_dossier = DeletedDossier.create_from_dossier(self, reason)
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,10 @@ class Instructeur < ApplicationRecord
|
||||||
user.administrateur.nil? && procedures.all? { |p| p.defaut_groupe_instructeur.instructeurs.count > 1 }
|
user.administrateur.nil? && procedures.all? { |p| p.defaut_groupe_instructeur.instructeurs.count > 1 }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# required to display feature flags field in manager
|
||||||
|
def features
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def annotations_hash(demande, annotations_privees, avis, messagerie)
|
def annotations_hash(demande, annotations_privees, avis, messagerie)
|
||||||
|
|
|
@ -120,7 +120,7 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
dossiers.each do |dossier|
|
dossiers.each do |dossier|
|
||||||
dossier.delete_and_keep_track!(administration, :user_removed)
|
dossier.discard_and_keep_track!(administration, :user_removed)
|
||||||
end
|
end
|
||||||
dossiers.with_discarded.destroy_all
|
dossiers.with_discarded.destroy_all
|
||||||
destroy!
|
destroy!
|
||||||
|
|
|
@ -5,7 +5,8 @@ class FranceConnectService
|
||||||
client.authorization_uri(
|
client.authorization_uri(
|
||||||
scope: [:profile, :email],
|
scope: [:profile, :email],
|
||||||
state: SecureRandom.hex(16),
|
state: SecureRandom.hex(16),
|
||||||
nonce: SecureRandom.hex(16)
|
nonce: SecureRandom.hex(16),
|
||||||
|
acr_values: 'eidas1'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ as well as a link to its edit page.
|
||||||
<header class="main-content__header" role="banner">
|
<header class="main-content__header" role="banner">
|
||||||
<h1 class="main-content__page-title">
|
<h1 class="main-content__page-title">
|
||||||
<%= content_for(:title) %>
|
<%= content_for(:title) %>
|
||||||
<% if dossier.hidden_at %>
|
<% if dossier.discarded? %>
|
||||||
(Supprimé)
|
(Supprimé)
|
||||||
<% end %>
|
<% end %>
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -31,8 +31,8 @@ as well as a link to its edit page.
|
||||||
<% if dossier.accepte? %>
|
<% if dossier.accepte? %>
|
||||||
<%= link_to 'Repasser en instruction', repasser_en_instruction_manager_dossier_path(dossier), method: :post, class: 'button', data: { confirm: "Confirmez vous le passage en instruction du dossier ?" } %>
|
<%= link_to 'Repasser en instruction', repasser_en_instruction_manager_dossier_path(dossier), method: :post, class: 'button', data: { confirm: "Confirmez vous le passage en instruction du dossier ?" } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if dossier.hidden_at.nil? %>
|
<% if dossier.can_be_deleted_by_manager? %>
|
||||||
<%= link_to 'Supprimer le dossier', hide_manager_dossier_path(dossier), method: :post, class: 'button', data: { confirm: "Confirmez vous la suppression du dossier ?" } %>
|
<%= link_to 'Supprimer le dossier', discard_manager_dossier_path(dossier), method: :post, class: 'button', data: { confirm: "Confirmez vous la suppression du dossier ?" } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -15,7 +15,7 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :dossiers, only: [:index, :show] do
|
resources :dossiers, only: [:index, :show] do
|
||||||
post 'hide', on: :member
|
post 'discard', on: :member
|
||||||
post 'repasser_en_instruction', on: :member
|
post 'repasser_en_instruction', on: :member
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
describe Manager::AdministrateursController, type: :controller do
|
describe Manager::AdministrateursController, type: :controller do
|
||||||
let(:administration) { create(:administration) }
|
let(:administration) { create(:administration) }
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in administration
|
sign_in administration
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#show' do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
before do
|
||||||
|
get :show, params: { id: administrateur.id }
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(response.body).to include(administrateur.email) }
|
||||||
|
end
|
||||||
|
|
||||||
describe 'GET #new' do
|
describe 'GET #new' do
|
||||||
render_views
|
render_views
|
||||||
it 'displays form to create a new admin' do
|
it 'displays form to create a new admin' do
|
||||||
|
@ -41,23 +52,20 @@ describe Manager::AdministrateursController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#delete' do
|
describe '#delete' do
|
||||||
let!(:admin) { create(:administrateur) }
|
subject { delete :delete, params: { id: administrateur.id } }
|
||||||
|
|
||||||
subject { delete :delete, params: { id: admin.id } }
|
|
||||||
|
|
||||||
it 'deletes the admin' do
|
it 'deletes the admin' do
|
||||||
subject
|
subject
|
||||||
|
|
||||||
expect(Administrateur.find_by(id: admin.id)).to be_nil
|
expect(Administrateur.find_by(id: administrateur.id)).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
render_views
|
render_views
|
||||||
let(:admin) { create(:administrateur) }
|
|
||||||
|
|
||||||
it 'searches admin by email' do
|
it 'searches admin by email' do
|
||||||
get :index, params: { search: admin.email }
|
get :index, params: { search: administrateur.email }
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
describe Manager::DossiersController, type: :controller do
|
describe Manager::DossiersController, type: :controller do
|
||||||
describe '#hide' do
|
describe '#discard' do
|
||||||
let(:administration) { create :administration }
|
let(:administration) { create :administration }
|
||||||
let!(:dossier) { create(:dossier) }
|
let(:dossier) { create(:dossier) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in administration
|
sign_in administration
|
||||||
post :hide, params: { id: dossier.id }
|
post :discard, params: { id: dossier.id }
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(dossier.hidden_at).not_to be_nil }
|
it { expect(dossier.discarded?).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#repasser_en_instruction' do
|
describe '#repasser_en_instruction' do
|
||||||
let(:administration) { create :administration }
|
let(:administration) { create :administration }
|
||||||
let!(:dossier) { create(:dossier, :accepte) }
|
let(:dossier) { create(:dossier, :accepte) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in administration
|
sign_in administration
|
||||||
|
@ -22,6 +22,6 @@ describe Manager::DossiersController, type: :controller do
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(dossier.en_instruction?).to be true }
|
it { expect(dossier.en_instruction?).to be_truthy }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
describe Manager::InstructeursController, type: :controller do
|
describe Manager::InstructeursController, type: :controller do
|
||||||
let(:administration) { create(:administration) }
|
let(:administration) { create(:administration) }
|
||||||
|
let(:instructeur) { create(:instructeur) }
|
||||||
|
|
||||||
|
describe '#show' do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in(administration)
|
||||||
|
get :show, params: { id: instructeur.id }
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(response.body).to include(instructeur.email) }
|
||||||
|
end
|
||||||
|
|
||||||
describe '#delete' do
|
describe '#delete' do
|
||||||
let!(:instructeur) { create(:instructeur) }
|
|
||||||
|
|
||||||
before { sign_in administration }
|
before { sign_in administration }
|
||||||
|
|
||||||
subject { delete :delete, params: { id: instructeur.id } }
|
subject { delete :delete, params: { id: instructeur.id } }
|
||||||
|
|
|
@ -1,6 +1,20 @@
|
||||||
describe Manager::UsersController, type: :controller do
|
describe Manager::UsersController, type: :controller do
|
||||||
let(:administration) { create(:administration) }
|
let(:administration) { create(:administration) }
|
||||||
|
|
||||||
|
describe '#show' do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
let(:administration) { create(:administration) }
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in(administration)
|
||||||
|
get :show, params: { id: user.id }
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(response.body).to include(user.email) }
|
||||||
|
end
|
||||||
|
|
||||||
describe '#update' do
|
describe '#update' do
|
||||||
let!(:user) { create(:user, email: 'ancien.email@domaine.fr') }
|
let!(:user) { create(:user, email: 'ancien.email@domaine.fr') }
|
||||||
|
|
||||||
|
|
|
@ -670,7 +670,7 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#delete_and_keep_track!" do
|
describe "#discard_and_keep_track!" do
|
||||||
let(:dossier) { create(:dossier, :en_construction) }
|
let(:dossier) { create(:dossier, :en_construction) }
|
||||||
let(:deleted_dossier) { DeletedDossier.find_by(dossier_id: dossier.id) }
|
let(:deleted_dossier) { DeletedDossier.find_by(dossier_id: dossier.id) }
|
||||||
let(:last_operation) { dossier.dossier_operation_logs.last }
|
let(:last_operation) { dossier.dossier_operation_logs.last }
|
||||||
|
@ -681,7 +681,7 @@ describe Dossier do
|
||||||
allow(DossierMailer).to receive(:notify_deletion_to_administration).and_return(double(deliver_later: nil))
|
allow(DossierMailer).to receive(:notify_deletion_to_administration).and_return(double(deliver_later: nil))
|
||||||
end
|
end
|
||||||
|
|
||||||
subject! { dossier.delete_and_keep_track!(dossier.user, reason) }
|
subject! { dossier.discard_and_keep_track!(dossier.user, reason) }
|
||||||
|
|
||||||
context 'brouillon' do
|
context 'brouillon' do
|
||||||
let(:dossier) { create(:dossier) }
|
let(:dossier) { create(:dossier) }
|
||||||
|
|
|
@ -278,7 +278,7 @@ describe User, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "keep track of dossiers and delete user" do
|
it "keep track of dossiers and delete user" do
|
||||||
dossier_cache.delete_and_keep_track!(administration, :user_request)
|
dossier_cache.discard_and_keep_track!(administration, :user_request)
|
||||||
user.delete_and_keep_track_dossiers(administration)
|
user.delete_and_keep_track_dossiers(administration)
|
||||||
|
|
||||||
expect(DeletedDossier.find_by(dossier_id: dossier_en_construction)).to be_present
|
expect(DeletedDossier.find_by(dossier_id: dossier_en_construction)).to be_present
|
||||||
|
@ -287,7 +287,7 @@ describe User, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't destroy dossiers of another user" do
|
it "doesn't destroy dossiers of another user" do
|
||||||
dossier_cache.delete_and_keep_track!(administration, :user_request)
|
dossier_cache.discard_and_keep_track!(administration, :user_request)
|
||||||
user.delete_and_keep_track_dossiers(administration)
|
user.delete_and_keep_track_dossiers(administration)
|
||||||
|
|
||||||
expect(Dossier.find_by(id: dossier_from_another_user.id)).to be_present
|
expect(Dossier.find_by(id: dossier_from_another_user.id)).to be_present
|
||||||
|
|
Loading…
Reference in a new issue