DossierController: user can destroy pjs
This commit is contained in:
parent
4c7c09c270
commit
db6c86b242
5 changed files with 60 additions and 5 deletions
|
@ -4,11 +4,11 @@ module NewUser
|
|||
|
||||
SESSION_USER_RETURN_LOCATION = 'user_return_to'
|
||||
ACTIONS_ALLOWED_TO_ANY_USER = [:index, :recherche, :new]
|
||||
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :create_commentaire]
|
||||
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :create_commentaire, :purge_champ_piece_justificative]
|
||||
|
||||
before_action :ensure_ownership!, except: ACTIONS_ALLOWED_TO_ANY_USER + ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
|
||||
before_action :ensure_ownership_or_invitation!, only: ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
|
||||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_brouillon, :modifier, :update]
|
||||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_brouillon, :modifier, :update, :purge_champ_piece_justificative]
|
||||
before_action :forbid_invite_submission!, only: [:update_brouillon]
|
||||
before_action :forbid_closed_submission!, only: [:update_brouillon]
|
||||
before_action :show_demarche_en_test_banner
|
||||
|
@ -230,6 +230,14 @@ module NewUser
|
|||
redirect_to url_for dossiers_path
|
||||
end
|
||||
|
||||
def purge_champ_piece_justificative
|
||||
@champ = dossier.champs.find(params[:champ_id])
|
||||
|
||||
@champ.piece_justificative_file.purge
|
||||
|
||||
flash.notice = 'La pièce jointe a bien été supprimée.'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def store_user_location!
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<%= render_flash(timeout: 5000, sticky: true) %>
|
||||
<%= remove_element("#piece_justificative_#{@champ.id}") %>
|
|
@ -10,9 +10,12 @@
|
|||
id: "champs_#{champ.id}",
|
||||
direct_upload: true
|
||||
- else
|
||||
= render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: champ, user_can_upload: true }
|
||||
%br
|
||||
Modifier :
|
||||
%div{ id: "piece_justificative_#{champ.id}" }
|
||||
= render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: champ, user_can_upload: true }
|
||||
%br
|
||||
= link_to 'supprimer', purge_champ_piece_justificative_dossier_path(champ_id: champ.id), remote: true, method: :delete
|
||||
%br
|
||||
Modifier :
|
||||
= form.file_field :piece_justificative_file,
|
||||
id: "champs_#{champ.id}",
|
||||
direct_upload: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue