commit
c65345b0f1
7 changed files with 49 additions and 13 deletions
|
@ -124,7 +124,7 @@ class Dossier < ApplicationRecord
|
||||||
has_many :types_de_champ, through: :revision
|
has_many :types_de_champ, through: :revision
|
||||||
has_many :types_de_champ_private, through: :revision
|
has_many :types_de_champ_private, through: :revision
|
||||||
|
|
||||||
belongs_to :transfer, class_name: 'DossierTransfer', foreign_key: 'dossier_transfer_id', optional: true, inverse_of: :dossiers, dependent: :destroy
|
belongs_to :transfer, class_name: 'DossierTransfer', foreign_key: 'dossier_transfer_id', optional: true, inverse_of: :dossiers
|
||||||
has_many :transfer_logs, class_name: 'DossierTransferLog', dependent: :destroy
|
has_many :transfer_logs, class_name: 'DossierTransferLog', dependent: :destroy
|
||||||
|
|
||||||
accepts_nested_attributes_for :champs
|
accepts_nested_attributes_for :champs
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th{ colspan: 2 }= t(".existing_groupe", count: groupes_instructeurs.total_count)
|
%th{ colspan: 2 }= t(".existing_groupe", count: groupes_instructeurs.total_count)
|
||||||
|
%th
|
||||||
|
- if groupe_instructeurs_count > 1
|
||||||
|
= link_to "Exporter au format CSV", export_groupe_instructeurs_admin_procedure_groupe_instructeurs_path(procedure, format: :csv)
|
||||||
%tbody
|
%tbody
|
||||||
- groupes_instructeurs.each do |group|
|
- groupes_instructeurs.each do |group|
|
||||||
%tr
|
%tr
|
||||||
|
@ -49,7 +52,6 @@
|
||||||
= link_to reaffecter_dossiers_admin_procedure_groupe_instructeur_path(procedure, group), class: 'button', title:'Réaffecter les dossiers à un autre groupe afin de pouvoir le supprimer' do
|
= link_to reaffecter_dossiers_admin_procedure_groupe_instructeur_path(procedure, group), class: 'button', title:'Réaffecter les dossiers à un autre groupe afin de pouvoir le supprimer' do
|
||||||
%span.icon.follow
|
%span.icon.follow
|
||||||
déplacer les dossiers
|
déplacer les dossiers
|
||||||
- if groupe_instructeurs_count > 1
|
|
||||||
= link_to "Exporter au format CSV", export_groupe_instructeurs_admin_procedure_groupe_instructeurs_path(procedure, format: :csv)
|
|
||||||
|
|
||||||
= paginate groupes_instructeurs
|
= paginate groupes_instructeurs
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
namespace :after_party do
|
||||||
|
desc 'Deployment task: remove_orphaned_avis'
|
||||||
|
task remove_orphaned_avis: :environment do
|
||||||
|
puts "Running deploy task 'remove_orphaned_avis'"
|
||||||
|
|
||||||
|
avis = Avis.unscope(:joins)
|
||||||
|
.joins('LEFT JOIN dossiers ON dossiers.id = avis.dossier_id')
|
||||||
|
.where(dossiers: { id: nil })
|
||||||
|
progress = ProgressReport.new(avis.count)
|
||||||
|
|
||||||
|
avis.find_each do |avis|
|
||||||
|
avis.destroy
|
||||||
|
progress.inc
|
||||||
|
end
|
||||||
|
progress.finish
|
||||||
|
|
||||||
|
# Update task as completed. If you remove the line below, the task will
|
||||||
|
# run with every deploy (or every time you call after_party:run).
|
||||||
|
AfterParty::TaskRecord
|
||||||
|
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||||
|
end
|
||||||
|
end
|
5
spec/factories/dossier_transfer.rb
Normal file
5
spec/factories/dossier_transfer.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
FactoryBot.define do
|
||||||
|
factory :dossier_transfer do
|
||||||
|
email { generate(:user_email) }
|
||||||
|
end
|
||||||
|
end
|
|
@ -1439,14 +1439,18 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#destroy" do
|
describe "#destroy" do
|
||||||
let(:dossier) { create(:dossier) }
|
let(:transfer) { create(:dossier_transfer) }
|
||||||
|
let(:dossier) { create(:dossier, transfer: transfer) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
create(:dossier, transfer: transfer)
|
||||||
create(:attestation, dossier: dossier)
|
create(:attestation, dossier: dossier)
|
||||||
create(:attestation, dossier: dossier)
|
create(:attestation, dossier: dossier)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can destroy dossier with two attestations" do
|
it "can destroy dossier with two attestations" do
|
||||||
expect(dossier.destroy).to be_truthy
|
expect(dossier.destroy).to be_truthy
|
||||||
|
expect(transfer.reload).not_to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -46,5 +46,16 @@ RSpec.describe DossierTransfer, type: :model do
|
||||||
it { expect(DossierTransfer.with_dossiers.count).to eq(0) }
|
it { expect(DossierTransfer.with_dossiers.count).to eq(0) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'dossier relationship' do
|
||||||
|
let(:transfer) { create(:dossier_transfer) }
|
||||||
|
let(:dossier) { create(:dossier, user: user, transfer: transfer) }
|
||||||
|
|
||||||
|
it 'nullify transfer relationship on dossier' do
|
||||||
|
expect(dossier.transfer).to eq(transfer)
|
||||||
|
transfer.destroy
|
||||||
|
expect(dossier.reload.transfer).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
10
yarn.lock
10
yarn.lock
|
@ -12817,15 +12817,7 @@ url-parse-lax@^3.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
prepend-http "^2.0.0"
|
prepend-http "^2.0.0"
|
||||||
|
|
||||||
url-parse@^1.4.3:
|
url-parse@^1.4.3, url-parse@^1.5.3:
|
||||||
version "1.5.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.1.tgz#d5fa9890af8a5e1f274a2c98376510f6425f6e3b"
|
|
||||||
integrity sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q==
|
|
||||||
dependencies:
|
|
||||||
querystringify "^2.1.1"
|
|
||||||
requires-port "^1.0.0"
|
|
||||||
|
|
||||||
url-parse@^1.5.3:
|
|
||||||
version "1.5.3"
|
version "1.5.3"
|
||||||
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.3.tgz#71c1303d38fb6639ade183c2992c8cc0686df862"
|
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.3.tgz#71c1303d38fb6639ade183c2992c8cc0686df862"
|
||||||
integrity sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ==
|
integrity sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ==
|
||||||
|
|
Loading…
Reference in a new issue