dossiers: allow users to delete "en construction" dossiers
This commit is contained in:
parent
d251ebc2f4
commit
a6704c4cd6
4 changed files with 7 additions and 3 deletions
|
@ -188,7 +188,7 @@ module NewUser
|
||||||
def ask_deletion
|
def ask_deletion
|
||||||
dossier = current_user.dossiers.includes(:user, procedure: :administrateur).find(params[:id])
|
dossier = current_user.dossiers.includes(:user, procedure: :administrateur).find(params[:id])
|
||||||
|
|
||||||
if !dossier.instruction_commencee?
|
if dossier.can_be_deleted_by_user?
|
||||||
dossier.delete_and_keep_track
|
dossier.delete_and_keep_track
|
||||||
flash.notice = 'Votre dossier a bien été supprimé.'
|
flash.notice = 'Votre dossier a bien été supprimé.'
|
||||||
redirect_to dossiers_path
|
redirect_to dossiers_path
|
||||||
|
|
|
@ -170,6 +170,10 @@ class Dossier < ApplicationRecord
|
||||||
brouillon? || en_construction?
|
brouillon? || en_construction?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_be_deleted_by_user?
|
||||||
|
brouillon? || en_construction?
|
||||||
|
end
|
||||||
|
|
||||||
def retention_end_date
|
def retention_end_date
|
||||||
if instruction_commencee?
|
if instruction_commencee?
|
||||||
en_instruction_at + procedure.duree_conservation_dossiers_dans_ds.months
|
en_instruction_at + procedure.duree_conservation_dossiers_dans_ds.months
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||||
= dossier.updated_at.strftime("%d/%m/%Y")
|
= dossier.updated_at.strftime("%d/%m/%Y")
|
||||||
%td.action-col.delete-col
|
%td.action-col.delete-col
|
||||||
- if dossier.brouillon?
|
- if dossier.can_be_deleted_by_user?
|
||||||
= link_to(ask_deletion_dossier_path(dossier), method: :post, class: 'button danger', data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" }) do
|
= link_to(ask_deletion_dossier_path(dossier), method: :post, class: 'button danger', data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" }) do
|
||||||
%span.icon.delete
|
%span.icon.delete
|
||||||
Supprimer
|
Supprimer
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
||||||
describe 'user access to the list of his dossier' do
|
describe 'user access to the list of his dossier' do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
|
let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
|
||||||
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
|
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_instruction)) }
|
||||||
let!(:dossier2) { create(:dossier, :with_entreprise) }
|
let!(:dossier2) { create(:dossier, :with_entreprise) }
|
||||||
let!(:dossier_brouillon) { create(:dossier, :with_entreprise, user: user) }
|
let!(:dossier_brouillon) { create(:dossier, :with_entreprise, user: user) }
|
||||||
let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
|
let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
|
||||||
|
|
Loading…
Add table
Reference in a new issue