User : delete the folder if the instructeur has hide it
This commit is contained in:
parent
7d7b847437
commit
37e991ccb8
4 changed files with 8 additions and 24 deletions
|
@ -212,16 +212,15 @@ module Users
|
|||
end
|
||||
end
|
||||
|
||||
def ask_deletion
|
||||
def delete_dossier
|
||||
dossier = current_user.dossiers.includes(:user, procedure: :administrateurs).find(params[:id])
|
||||
|
||||
if dossier.can_be_deleted_by_user?
|
||||
dossier.discard_and_keep_track!(current_user, :user_request)
|
||||
flash.notice = t('.soft_deleted_dossier')
|
||||
flash.notice = t('users.dossiers.ask_deletion.soft_deleted_dossier')
|
||||
redirect_to dossiers_path
|
||||
else
|
||||
flash.notice = t('.undergoingreview')
|
||||
redirect_to dossier_path(dossier)
|
||||
flash.alert = t('users.dossiers.ask_deletion.undergoingreview')
|
||||
redirect_to dossiers_path
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -288,13 +287,6 @@ module Users
|
|||
@transfer = DossierTransfer.new(dossiers: current_user.dossiers)
|
||||
end
|
||||
|
||||
def hide_dossier
|
||||
dossier = current_user.dossiers.includes(:user, procedure: :administrateurs).find(params[:id])
|
||||
dossier.update(hidden_by_user_at: Time.zone.now)
|
||||
flash.notice = t('users.dossiers.ask_deletion.soft_deleted_dossier')
|
||||
redirect_to dossiers_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# if the status tab is filled, then this tab
|
||||
|
|
|
@ -526,7 +526,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def can_be_deleted_by_user?
|
||||
brouillon? || en_construction?
|
||||
brouillon? || en_construction? || termine?
|
||||
end
|
||||
|
||||
def can_be_deleted_by_manager?
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
- has_delete_action = dossier.can_be_deleted_by_user?
|
||||
- has_new_dossier_action = dossier.procedure.accepts_new_dossiers?
|
||||
- has_transfer_action = dossier.user == current_user
|
||||
- has_hide_action = dossier.termine? && dossier.hidden_by_user_at.nil?
|
||||
- has_actions = has_edit_action || has_delete_action || has_new_dossier_action || has_transfer_action || has_hide_action
|
||||
- has_actions = has_edit_action || has_delete_action || has_new_dossier_action || has_transfer_action
|
||||
|
||||
- if has_actions
|
||||
.dropdown.user-dossier-actions
|
||||
|
@ -41,14 +40,8 @@
|
|||
|
||||
- if has_delete_action
|
||||
%li.danger
|
||||
= link_to ask_deletion_dossier_path(dossier), method: :post, data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraîne l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" } do
|
||||
= link_to delete_dossier_dossier_path(dossier), method: :patch, data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraîne l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" } do
|
||||
%span.icon.delete
|
||||
.dropdown-description
|
||||
= t('views.users.dossiers.dossier_action.delete_dossier')
|
||||
- if has_hide_action
|
||||
%li
|
||||
= link_to hide_dossier_dossier_path(dossier), method: :patch do
|
||||
%span.icon.delete
|
||||
.dropdown-description
|
||||
= t('views.users.dossiers.dossier_action.hide_dossier')
|
||||
|
||||
|
|
|
@ -268,8 +268,7 @@ Rails.application.routes.draw do
|
|||
get 'demande'
|
||||
get 'messagerie'
|
||||
post 'commentaire' => 'dossiers#create_commentaire'
|
||||
post 'ask_deletion'
|
||||
patch 'hide_dossier'
|
||||
patch 'delete_dossier'
|
||||
get 'attestation'
|
||||
get 'transferer', to: 'dossiers#transferer'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue