Affichage des pièces jointes disponibles dans la console admin
This commit is contained in:
parent
3cfc488ab0
commit
5dc8ae822f
10 changed files with 103 additions and 9 deletions
1
Gemfile
1
Gemfile
|
@ -71,6 +71,7 @@ end
|
|||
group :development, :test do
|
||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||
gem 'byebug'
|
||||
gem 'pry-byebug'
|
||||
|
||||
gem 'rubocop'
|
||||
|
||||
|
|
14
Gemfile.lock
14
Gemfile.lock
|
@ -70,6 +70,7 @@ GEM
|
|||
childprocess (0.5.5)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
cliver (0.3.2)
|
||||
coderay (1.1.0)
|
||||
coffee-rails (4.1.0)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
|
@ -137,6 +138,7 @@ GEM
|
|||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
method_source (0.8.2)
|
||||
mime-types (2.6.1)
|
||||
mini_portile (0.6.2)
|
||||
minitest (5.7.0)
|
||||
|
@ -154,6 +156,13 @@ GEM
|
|||
multi_json (~> 1.0)
|
||||
websocket-driver (>= 0.2.0)
|
||||
powerpack (0.1.0)
|
||||
pry (0.10.1)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
pry-byebug (3.2.0)
|
||||
byebug (~> 5.0)
|
||||
pry (~> 0.10)
|
||||
rack (1.6.4)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
|
@ -246,6 +255,7 @@ GEM
|
|||
multi_json (~> 1.0)
|
||||
simplecov-html (~> 0.8.0)
|
||||
simplecov-html (0.8.0)
|
||||
slop (3.6.0)
|
||||
spring (1.3.6)
|
||||
sprockets (3.2.0)
|
||||
rack (~> 1.0)
|
||||
|
@ -306,6 +316,7 @@ DEPENDENCIES
|
|||
leaflet-rails
|
||||
pg
|
||||
poltergeist
|
||||
pry-byebug
|
||||
rails (= 4.2.0)
|
||||
rest-client
|
||||
rgeo-geojson
|
||||
|
@ -321,3 +332,6 @@ DEPENDENCIES
|
|||
uglifier (>= 1.3.0)
|
||||
web-console (~> 2.0)
|
||||
webmock
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.4
|
||||
|
|
|
@ -6,11 +6,13 @@ class Admin::DossierController < ApplicationController
|
|||
@entreprise = @dossier.entreprise.decorate
|
||||
@etablissement = @dossier.etablissement
|
||||
@dossier_pdf = @dossier.dossier_pdf
|
||||
|
||||
@commentaires = @dossier.commentaires.order(created_at: :desc)
|
||||
@commentaires = @commentaires.all.decorate
|
||||
@commentaire_email = current_user.email
|
||||
|
||||
@liste_pieces_jointes = RefPiecesJointe.get_liste_piece_jointe @dossier.ref_formulaire
|
||||
@array_id_pj_valides = DossierPdf.get_array_id_pj_valid_for_dossier @dossier.id
|
||||
|
||||
@dossier = @dossier.decorate
|
||||
rescue
|
||||
redirect_start
|
||||
|
|
|
@ -3,11 +3,7 @@ class DescriptionController < ApplicationController
|
|||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@dossier = @dossier.decorate
|
||||
|
||||
@array_id_pj_valides = Array.new
|
||||
|
||||
DossierPdf.where(dossier_id: @dossier.id).each do |pj_valide|
|
||||
@array_id_pj_valides << pj_valide.ref_pieces_jointes_id
|
||||
end
|
||||
@array_id_pj_valides = DossierPdf.get_array_id_pj_valid_for_dossier @dossier.id
|
||||
|
||||
@liste_pieces_jointes = get_liste_piece_jointe
|
||||
rescue
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
class Dossier < ActiveRecord::Base
|
||||
has_one :etablissement
|
||||
has_one :entreprise
|
||||
has_one :dossier_pdf
|
||||
has_many :dossier_pdf
|
||||
has_many :commentaires
|
||||
|
||||
def get_pj piece_jointe_id
|
||||
dossier_pdf.where(ref_pieces_jointes_id: piece_jointe_id).last
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,4 +2,14 @@ class DossierPdf < ActiveRecord::Base
|
|||
belongs_to :dossier
|
||||
|
||||
mount_uploader :ref_dossier_pdf, DossierPdfUploader
|
||||
|
||||
def self.get_array_id_pj_valid_for_dossier dossier_id
|
||||
@array_id_pj_valides = Array.new
|
||||
|
||||
DossierPdf.where(dossier_id: dossier_id).each do |pj_valide|
|
||||
@array_id_pj_valides << pj_valide.ref_pieces_jointes_id
|
||||
end
|
||||
|
||||
@array_id_pj_valides
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
class RefPiecesJointe < ActiveRecord::Base
|
||||
|
||||
def self.get_liste_piece_jointe ref_formulaire
|
||||
@formulaire = RefFormulaire.find(ref_formulaire)
|
||||
RefPiecesJointe.where ("\"CERFA\" = '#{@formulaire.ref_demarche}'")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -12,8 +12,24 @@
|
|||
%br
|
||||
|
||||
.content{class: 'row'}
|
||||
#map_qp{style: 'height:500px', class: 'col-lg-6 col-md-6'}
|
||||
= render partial: '/carte/carte_sources_CSS'
|
||||
#map_qp.col-lg-6.col-md-6{style: 'height:500px'}
|
||||
#pieces_jointes.col-lg-6.col-md-6
|
||||
%h3.text-info Liste des pièces jointes
|
||||
%br
|
||||
%table.table
|
||||
-@liste_pieces_jointes.each do |pj|
|
||||
%tr{id: "piece_jointe_#{pj.id}"}
|
||||
%th{class:'col-lg-6'}
|
||||
=pj.libelle
|
||||
%td.col-lg-4.col-md-4
|
||||
- if pj.api_entreprise
|
||||
%a{ href: '' } Récupérer
|
||||
- elsif @array_id_pj_valides.include?(pj.id)
|
||||
%a{ href: "#{@dossier.get_pj(pj.id).ref_dossier_pdf}", target: '_blank' } Consulter
|
||||
- else
|
||||
= 'Pièce non fournie'
|
||||
|
||||
= render partial: '/carte/carte_sources_CSS'
|
||||
= render partial: '/carte/carte_sources_JS_backend'
|
||||
%br
|
||||
|
||||
|
|
|
@ -32,6 +32,51 @@ feature 'Admin/Dossier#Show Page' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'la liste des pièces jointes est présente' do
|
||||
context 'Attestation MSA' do
|
||||
let(:id_piece_jointe){93}
|
||||
|
||||
scenario 'la ligne de la pièce jointe est présente' do
|
||||
expect(page).to have_selector("tr[id=piece_jointe_#{id_piece_jointe}]")
|
||||
end
|
||||
|
||||
scenario 'le bouton "Récupérer" est présent' do
|
||||
expect(page.find("tr[id=piece_jointe_#{id_piece_jointe}]")).to have_selector("a[href='']")
|
||||
expect(page.find("tr[id=piece_jointe_#{id_piece_jointe}]")).to have_content('Récupérer')
|
||||
end
|
||||
end
|
||||
|
||||
context 'Attestation RDI' do
|
||||
let(:id_piece_jointe){103}
|
||||
|
||||
scenario 'la ligne de la pièce jointe est présente' do
|
||||
expect(page).to have_selector("tr[id=piece_jointe_#{id_piece_jointe}]")
|
||||
end
|
||||
|
||||
scenario 'le libelle "Pièce manquante" est présent' do
|
||||
expect(page.find("tr[id=piece_jointe_#{id_piece_jointe}]")).to have_content('Pièce non fournie')
|
||||
end
|
||||
end
|
||||
|
||||
context 'Devis' do
|
||||
let(:id_piece_jointe){388}
|
||||
let(:piece_jointe_388) {File.open('./spec/support/files/piece_jointe_388.pdf')}
|
||||
|
||||
before do
|
||||
DossierPdf.create(dossier_id: dossier_id, ref_pieces_jointes_id: id_piece_jointe, ref_dossier_pdf: piece_jointe_388)
|
||||
end
|
||||
|
||||
scenario 'la ligne de la pièce jointe est présente' do
|
||||
expect(page).to have_selector("tr[id=piece_jointe_#{id_piece_jointe}]")
|
||||
end
|
||||
|
||||
scenario 'le libelle "Consulter" est présent' do
|
||||
expect(page.find("tr[id=piece_jointe_#{id_piece_jointe}] a")[:href]).to have_content("piece_jointe_388.pdf")
|
||||
expect(page.find("tr[id=piece_jointe_#{id_piece_jointe}]")).to have_content('Consulter')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'la carte est bien présente' do
|
||||
expect(page).to have_selector('#map_qp');
|
||||
end
|
||||
|
|
BIN
spec/support/files/piece_jointe_388.pdf
Normal file
BIN
spec/support/files/piece_jointe_388.pdf
Normal file
Binary file not shown.
Loading…
Reference in a new issue