Merge pull request #5144 from betagouv/add-piece-justificative-filename-to-export
Instructeur : le nom de fichier des pièces justificatives est maintenant indiqué dans les exports tableur
This commit is contained in:
commit
c01b69214e
3 changed files with 26 additions and 2 deletions
|
@ -36,6 +36,10 @@ class Champs::PieceJustificativeChamp < Champ
|
||||||
mandatory? && !piece_justificative_file.attached?
|
mandatory? && !piece_justificative_file.attached?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def for_export
|
||||||
|
piece_justificative_file.filename.to_s if piece_justificative_file.attached?
|
||||||
|
end
|
||||||
|
|
||||||
def for_api
|
def for_api
|
||||||
if piece_justificative_file.attached? && (piece_justificative_file.virus_scanner.safe? || piece_justificative_file.virus_scanner.pending?)
|
if piece_justificative_file.attached? && (piece_justificative_file.virus_scanner.safe? || piece_justificative_file.virus_scanner.pending?)
|
||||||
piece_justificative_file.service_url
|
piece_justificative_file.service_url
|
||||||
|
|
|
@ -131,11 +131,19 @@ class Dossier < ApplicationRecord
|
||||||
etablissement: :champ,
|
etablissement: :champ,
|
||||||
champs: {
|
champs: {
|
||||||
etablissement: :champ,
|
etablissement: :champ,
|
||||||
type_de_champ: :drop_down_list
|
type_de_champ: :drop_down_list,
|
||||||
|
piece_justificative_file_attachment: :blob,
|
||||||
|
champs: [
|
||||||
|
piece_justificative_file_attachment: :blob
|
||||||
|
]
|
||||||
},
|
},
|
||||||
champs_private: {
|
champs_private: {
|
||||||
etablissement: :champ,
|
etablissement: :champ,
|
||||||
type_de_champ: :drop_down_list
|
type_de_champ: :drop_down_list,
|
||||||
|
piece_justificative_file_attachment: :blob,
|
||||||
|
champs: [
|
||||||
|
piece_justificative_file_attachment: :blob
|
||||||
|
]
|
||||||
},
|
},
|
||||||
procedure: :groupe_instructeurs
|
procedure: :groupe_instructeurs
|
||||||
).order(en_construction_at: 'asc')
|
).order(en_construction_at: 'asc')
|
||||||
|
|
|
@ -14,6 +14,18 @@ describe Champs::PieceJustificativeChamp do
|
||||||
it { is_expected.to validate_content_type_of(:piece_justificative_file).allowing(Champs::PieceJustificativeChamp::ACCEPTED_FORMATS) }
|
it { is_expected.to validate_content_type_of(:piece_justificative_file).allowing(Champs::PieceJustificativeChamp::ACCEPTED_FORMATS) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#for_export" do
|
||||||
|
let(:champ_pj) { create(:champ_piece_justificative) }
|
||||||
|
subject { champ_pj.for_export }
|
||||||
|
|
||||||
|
it { is_expected.to eq('toto.txt') }
|
||||||
|
|
||||||
|
context 'without attached file' do
|
||||||
|
before { champ_pj.piece_justificative_file.purge }
|
||||||
|
it { is_expected.to eq(nil) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#for_api' do
|
describe '#for_api' do
|
||||||
let(:champ_pj) { create(:champ_piece_justificative) }
|
let(:champ_pj) { create(:champ_piece_justificative) }
|
||||||
let(:metadata) { champ_pj.piece_justificative_file.blob.metadata }
|
let(:metadata) { champ_pj.piece_justificative_file.blob.metadata }
|
||||||
|
|
Loading…
Reference in a new issue