Create fonction content_url to make public download link for cerfa and pj
This commit is contained in:
parent
16c72e7478
commit
4993abf5f2
5 changed files with 18 additions and 6 deletions
|
@ -2,9 +2,15 @@ class Cerfa < ActiveRecord::Base
|
|||
belongs_to :dossier
|
||||
|
||||
mount_uploader :content, CerfaUploader
|
||||
validates :content, :file_size => { :maximum => 3.megabytes }
|
||||
validates :content, :file_size => {:maximum => 3.megabytes}
|
||||
|
||||
def empty?
|
||||
content.blank?
|
||||
end
|
||||
|
||||
def content_url
|
||||
unless content.url.nil?
|
||||
(Downloader.new content, 'CERFA').url
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,9 +7,15 @@ class PieceJustificative < ActiveRecord::Base
|
|||
alias_attribute :type, :type_de_piece_justificative_id
|
||||
|
||||
mount_uploader :content, PieceJustificativeUploader
|
||||
validates :content, :file_size => { :maximum => 3.megabytes }
|
||||
validates :content, :file_size => {:maximum => 3.megabytes}
|
||||
|
||||
def empty?
|
||||
content.blank?
|
||||
end
|
||||
|
||||
def content_url
|
||||
unless content.url.nil?
|
||||
(Downloader.new content, type_de_piece_justificative.libelle).url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
- if user_signed_in?
|
||||
= 'Pièce fournie'
|
||||
- elsif gestionnaire_signed_in?
|
||||
%a{ href: "#{(Downloader.new @facade.dossier.cerfa.content, 'CERFA').url}", target: '_blank' } Consulter
|
||||
%a{ href: "#{@facade.dossier.cerfa.content_url}", target: '_blank' } Consulter
|
||||
- else
|
||||
= 'Pièce non fournie'
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
|||
- if user_signed_in?
|
||||
= 'Pièce fournie'
|
||||
- elsif gestionnaire_signed_in?
|
||||
%a{ href: "#{(Downloader.new piece_justificative.content, piece_justificative.type_de_piece_justificative.libelle).url}", target: '_blank' } Consulter
|
||||
%a{ href: "#{piece_justificative.content_url}", target: '_blank' } Consulter
|
||||
- else
|
||||
= 'Pièce non fournie'
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ describe API::V1::DossiersController do
|
|||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure) } }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:body) { JSON.parse(response.body, symbolize_names: true) }
|
||||
let(:field_list) { [:id, :nom_projet, :created_at, :updated_at, :description, :archived, :mandataire_social, :entreprise, :etablissement] }
|
||||
let(:field_list) { [:id, :nom_projet, :created_at, :updated_at, :description, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :pieces_justificatives, :champs] }
|
||||
subject { body[:dossier] }
|
||||
|
||||
it { expect(response.code).to eq('200') }
|
||||
|
|
|
@ -37,7 +37,7 @@ describe API::V1::ProceduresController do
|
|||
let(:champ) { procedure.types_de_champ.first }
|
||||
it { expect(subject[:id]).to eq(champ.id) }
|
||||
it { expect(subject[:libelle]).to eq(champ.libelle) }
|
||||
it { expect(subject[:type_champ]).to eq(champ.type_champ) }
|
||||
it { expect(subject[:type]).to eq(champ.type_champ) }
|
||||
it { expect(subject[:order_place]).to eq(champ.order_place) }
|
||||
it { expect(subject[:description]).to eq(champ.description) }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue