allow transfer sender to revoke a transfer
This commit is contained in:
parent
7c22e0840e
commit
3d5bf40c0f
6 changed files with 80 additions and 39 deletions
|
@ -78,6 +78,10 @@
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.no-border {
|
||||||
|
background-image: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-hidden-by-user {
|
.file-hidden-by-user {
|
||||||
|
|
|
@ -19,7 +19,10 @@ module Users
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
transfer = DossierTransfer.find_by!(id: params[:id], email: current_user.email)
|
transfer = DossierTransfer.find(params[:id])
|
||||||
|
|
||||||
|
authorized_email = (transfer.email == current_user.email || transfer.dossiers.where(dossiers: { user: current_user }).present?)
|
||||||
|
return if !authorized_email
|
||||||
|
|
||||||
transfer.destroy_and_nullify
|
transfer.destroy_and_nullify
|
||||||
redirect_to dossiers_path
|
redirect_to dossiers_path
|
||||||
|
|
|
@ -1,36 +1,45 @@
|
||||||
- if dossiers.present?
|
- if dossiers.present?
|
||||||
%table.table.dossiers-table.hoverable
|
.fr-table.fr-table--bordered
|
||||||
%caption= t('views.users.dossiers.dossiers_list.caption')
|
%table.table.dossiers-table.hoverable
|
||||||
%thead
|
%caption= t('views.users.dossiers.dossiers_list.caption')
|
||||||
%tr
|
%thead
|
||||||
%th.number-col{ scope: :col }= t('views.users.dossiers.dossiers_list.n_dossier')
|
%tr
|
||||||
%th{ scope: :col }= t('views.users.dossiers.dossiers_list.procedure')
|
%th.number-col{ scope: :col }= t('views.users.dossiers.dossiers_list.n_dossier')
|
||||||
- if dossiers.present?
|
%th{ scope: :col }= t('views.users.dossiers.dossiers_list.procedure')
|
||||||
%th{ scope: :col }= t('views.users.dossiers.dossiers_list.requester')
|
|
||||||
%th.status-col{ scope: :col }= t('views.users.dossiers.dossiers_list.status')
|
|
||||||
%th.updated-at-col{ scope: :col }= t('views.users.dossiers.dossiers_list.updated')
|
|
||||||
%th.sr-only{ scope: :col }= t('views.users.dossiers.dossiers_list.actions')
|
|
||||||
%tbody
|
|
||||||
- dossiers.each do |dossier|
|
|
||||||
%tr{ data: { 'dossier-id': dossier.id } }
|
|
||||||
%th.number-col{ scope: :row }
|
|
||||||
= link_to(url_for_dossier(dossier), class: 'cell-link', tabindex: -1) do
|
|
||||||
%span.icon.folder
|
|
||||||
= dossier.id
|
|
||||||
%td
|
|
||||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
|
||||||
= procedure_libelle(dossier.procedure)
|
|
||||||
- if dossiers.present?
|
- if dossiers.present?
|
||||||
%td
|
%th{ scope: :col }= t('views.users.dossiers.dossiers_list.requester')
|
||||||
%span.cell-link= demandeur_dossier(dossier)
|
%th.status-col{ scope: :col }= t('views.users.dossiers.dossiers_list.status')
|
||||||
%td.status-col
|
%th.updated-at-col{ scope: :col }= t('views.users.dossiers.dossiers_list.updated')
|
||||||
= status_badge(dossier.state)
|
%th.sr-only{ scope: :col }= t('views.users.dossiers.dossiers_list.actions')
|
||||||
%td.updated-at-col.cell-link
|
%tbody
|
||||||
= try_format_date(dossier.updated_at)
|
- dossiers.each do |dossier|
|
||||||
%td.action-col
|
- if dossier.transfer.present?
|
||||||
= render partial: 'dossier_actions', locals: { dossier: dossier }
|
%tr.fr-background-alt--blue-france.no-border
|
||||||
|
%td.fr-py-2w.text-center{ colspan: 100 }
|
||||||
|
%p
|
||||||
|
%small
|
||||||
|
= t('views.users.dossiers.transfers.demande_en_cours', id: dossier.id, email: dossier.transfer.email)
|
||||||
|
= link_to t('views.users.dossiers.transfers.revoke'), transfer_path(dossier.transfer), class: 'fr-btn fr-btn--sm fr-btn--tertiary-no-outline', method: :delete
|
||||||
|
|
||||||
= paginate(dossiers)
|
%tr{ data: { 'dossier-id': dossier.id } }
|
||||||
|
%th.number-col{ scope: :row }
|
||||||
|
= link_to(url_for_dossier(dossier), class: 'cell-link', tabindex: -1) do
|
||||||
|
%span.icon.folder
|
||||||
|
= dossier.id
|
||||||
|
%td
|
||||||
|
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||||
|
= procedure_libelle(dossier.procedure)
|
||||||
|
- if dossiers.present?
|
||||||
|
%td
|
||||||
|
%span.cell-link= demandeur_dossier(dossier)
|
||||||
|
%td.status-col
|
||||||
|
= status_badge(dossier.state)
|
||||||
|
%td.updated-at-col.cell-link
|
||||||
|
= try_format_date(dossier.updated_at)
|
||||||
|
%td.action-col
|
||||||
|
= render partial: 'dossier_actions', locals: { dossier: dossier }
|
||||||
|
|
||||||
|
= paginate(dossiers)
|
||||||
|
|
||||||
- else
|
- else
|
||||||
.blank-tab
|
.blank-tab
|
||||||
|
|
|
@ -357,6 +357,9 @@ en:
|
||||||
status: "Status"
|
status: "Status"
|
||||||
updated: "Updated"
|
updated: "Updated"
|
||||||
actions: "Actions"
|
actions: "Actions"
|
||||||
|
transfers:
|
||||||
|
demande_en_cours: "Une demande de transfert est en cours sur le dossier %{id} pour %{email}"
|
||||||
|
revoke: Révoquer cette demande
|
||||||
dossier_action:
|
dossier_action:
|
||||||
edit_dossier: "Edit the file"
|
edit_dossier: "Edit the file"
|
||||||
start_other_dossier: "Start another empty file"
|
start_other_dossier: "Start another empty file"
|
||||||
|
|
|
@ -361,6 +361,9 @@ fr:
|
||||||
transfer_dossier: "Transférer le dossier"
|
transfer_dossier: "Transférer le dossier"
|
||||||
edit_draft: "Modifier le brouillon"
|
edit_draft: "Modifier le brouillon"
|
||||||
actions: "Actions"
|
actions: "Actions"
|
||||||
|
transfers:
|
||||||
|
demande_en_cours: "Une demande de transfert est en cours sur le dossier %{id} pour %{email}"
|
||||||
|
revoke: Révoquer cette demande
|
||||||
sessions:
|
sessions:
|
||||||
new:
|
new:
|
||||||
sign_in: Connexion à %{application_name}
|
sign_in: Connexion à %{application_name}
|
||||||
|
|
|
@ -4,19 +4,38 @@ describe Users::TransfersController, type: :controller do
|
||||||
let(:dossier) { create(:dossier, user: sender_user) }
|
let(:dossier) { create(:dossier, user: sender_user) }
|
||||||
|
|
||||||
describe 'DELETE destroy' do
|
describe 'DELETE destroy' do
|
||||||
let(:dossier_transfert) { DossierTransfer.initiate(recipient_user.email, [dossier]) }
|
context "as transfer receiver" do
|
||||||
|
let(:dossier_transfert) { DossierTransfer.initiate(recipient_user.email, [dossier]) }
|
||||||
|
|
||||||
subject { delete :destroy, params: { id: dossier_transfert.id } }
|
subject { delete :destroy, params: { id: dossier_transfert.id } }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(recipient_user)
|
sign_in(recipient_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect { subject }.not_to raise_error }
|
||||||
|
|
||||||
|
it "deletes dossier transfert" do
|
||||||
|
subject
|
||||||
|
expect { dossier_transfert.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect { subject }.not_to raise_error }
|
context "as transfer sender" do
|
||||||
|
let(:dossier_transfert) { DossierTransfer.initiate(recipient_user.email, [dossier]) }
|
||||||
|
|
||||||
it "deletes dossier transfert" do
|
subject { delete :destroy, params: { id: dossier_transfert.id } }
|
||||||
subject
|
|
||||||
expect { dossier_transfert.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
before do
|
||||||
|
sign_in(sender_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect { subject }.not_to raise_error }
|
||||||
|
|
||||||
|
it "deletes dossier transfert" do
|
||||||
|
subject
|
||||||
|
expect { dossier_transfert.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue