Code review
This commit is contained in:
parent
58f840ac92
commit
141e23a381
18 changed files with 47 additions and 50 deletions
|
@ -2,12 +2,12 @@ class Admin::ProceduresController < AdminController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@procedures = current_administrateur.procedures.where(archived: false)
|
@procedures = current_administrateur.procedures.where(archived: false)
|
||||||
@procedures = @procedures.paginate(:page => params[:page], :per_page => 12)
|
@procedures = @procedures.paginate(:page => params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def archived
|
def archived
|
||||||
@procedures_archived = current_administrateur.procedures.where(archived: true)
|
@procedures_archived = current_administrateur.procedures.where(archived: true)
|
||||||
@procedures_archived = @procedures_archived.paginate(:page => params[:page], :per_page => 12)
|
@procedures_archived = @procedures_archived.paginate(:page => params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -7,20 +7,20 @@ class Backoffice::DossiersController < ApplicationController
|
||||||
|
|
||||||
def a_traiter
|
def a_traiter
|
||||||
@dossiers_a_traiter = current_gestionnaire.dossiers.waiting_for_gestionnaire()
|
@dossiers_a_traiter = current_gestionnaire.dossiers.waiting_for_gestionnaire()
|
||||||
@dossiers_a_traiter = @dossiers_a_traiter.paginate(:page => params[:page], :per_page => 12).decorate
|
@dossiers_a_traiter = @dossiers_a_traiter.paginate(:page => params[:page]).decorate
|
||||||
|
|
||||||
total_dossiers_per_state
|
total_dossiers_per_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def en_attente
|
def en_attente
|
||||||
@dossiers_en_attente = current_gestionnaire.dossiers.waiting_for_user()
|
@dossiers_en_attente = current_gestionnaire.dossiers.waiting_for_user()
|
||||||
@dossiers_en_attente = @dossiers_en_attente.paginate(:page => params[:page], :per_page => 12).decorate
|
@dossiers_en_attente = @dossiers_en_attente.paginate(:page => params[:page]).decorate
|
||||||
total_dossiers_per_state
|
total_dossiers_per_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def termine
|
def termine
|
||||||
@dossiers_termine = current_gestionnaire.dossiers.termine()
|
@dossiers_termine = current_gestionnaire.dossiers.termine()
|
||||||
@dossiers_termine = @dossiers_termine.paginate(:page => params[:page], :per_page => 12).decorate
|
@dossiers_termine = @dossiers_termine.paginate(:page => params[:page]).decorate
|
||||||
total_dossiers_per_state
|
total_dossiers_per_state
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class Backoffice::DossiersController < ApplicationController
|
||||||
@dossiers_search, @dossier = Dossier.search(current_gestionnaire, @search_terms)
|
@dossiers_search, @dossier = Dossier.search(current_gestionnaire, @search_terms)
|
||||||
|
|
||||||
unless @dossiers_search.empty?
|
unless @dossiers_search.empty?
|
||||||
@dossiers_search = @dossiers_search.paginate(:page => params[:page], :per_page => 12).decorate
|
@dossiers_search = @dossiers_search.paginate(:page => params[:page]).decorate
|
||||||
end
|
end
|
||||||
|
|
||||||
@dossier = @dossier.decorate unless @dossier.nil?
|
@dossier = @dossier.decorate unless @dossier.nil?
|
||||||
|
|
|
@ -11,10 +11,10 @@ class Users::CarteController < UsersController
|
||||||
def save
|
def save
|
||||||
dossier = current_user_dossier
|
dossier = current_user_dossier
|
||||||
|
|
||||||
dossier.quartier_prioritaires.all.map(&:destroy)
|
dossier.quartier_prioritaires.map(&:destroy)
|
||||||
|
|
||||||
unless params[:json_latlngs] == '' || params[:json_latlngs] == '[]'
|
unless params[:json_latlngs].blank?
|
||||||
qp_list = generate_qp JSON.parse(params[:json_latlngs]);
|
qp_list = generate_qp JSON.parse(params[:json_latlngs])
|
||||||
|
|
||||||
qp_list.each do |key, qp|
|
qp_list.each do |key, qp|
|
||||||
qp.merge!({dossier_id: dossier.id})
|
qp.merge!({dossier_id: dossier.id})
|
||||||
|
@ -33,8 +33,7 @@ class Users::CarteController < UsersController
|
||||||
body: 'La localisation de la demande a été modifiée. Merci de le prendre en compte.',
|
body: 'La localisation de la demande a été modifiée. Merci de le prendre en compte.',
|
||||||
dossier_id: dossier.id
|
dossier_id: dossier.id
|
||||||
}
|
}
|
||||||
commentaire = Commentaire.new commentaire_params
|
Commentaire.create commentaire_params
|
||||||
commentaire.save
|
|
||||||
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: params[:dossier_id])
|
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: params[:dossier_id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,6 @@ class Users::DossiersController < UsersController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
procedure = Procedure.find(params['procedure_id'])
|
|
||||||
@etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
|
@etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
|
||||||
@entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
@entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
||||||
|
|
||||||
|
@ -30,11 +29,7 @@ class Users::DossiersController < UsersController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@dossier = Dossier.create(user: current_user)
|
@dossier = Dossier.create(user: current_user, state: 'draft', procedure_id: params['procedure_id'])
|
||||||
@dossier.draft!
|
|
||||||
|
|
||||||
@dossier.procedure = procedure
|
|
||||||
@dossier.save
|
|
||||||
|
|
||||||
@entreprise.dossier = @dossier
|
@entreprise.dossier = @dossier
|
||||||
@entreprise.save
|
@entreprise.save
|
||||||
|
@ -90,7 +85,7 @@ class Users::DossiersController < UsersController
|
||||||
|
|
||||||
params[:page] = 1 if params[:page].nil?
|
params[:page] = 1 if params[:page].nil?
|
||||||
|
|
||||||
@dossiers = @dossiers.paginate(:page => params[:page], :per_page => 12).decorate
|
@dossiers = @dossiers.paginate(:page => params[:page]).decorate
|
||||||
total_dossiers_per_state
|
total_dossiers_per_state
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -100,7 +95,7 @@ class Users::DossiersController < UsersController
|
||||||
|
|
||||||
params[:page] = 1 if params[:page].nil?
|
params[:page] = 1 if params[:page].nil?
|
||||||
|
|
||||||
@dossiers = @dossiers.paginate(:page => params[:page], :per_page => 12).decorate
|
@dossiers = @dossiers.paginate(:page => params[:page]).decorate
|
||||||
total_dossiers_per_state
|
total_dossiers_per_state
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -110,7 +105,7 @@ class Users::DossiersController < UsersController
|
||||||
|
|
||||||
params[:page] = 1 if params[:page].nil?
|
params[:page] = 1 if params[:page].nil?
|
||||||
|
|
||||||
@dossiers = @dossiers.paginate(:page => params[:page], :per_page => 12).decorate
|
@dossiers = @dossiers.paginate(:page => params[:page]).decorate
|
||||||
total_dossiers_per_state
|
total_dossiers_per_state
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
#new_user
|
#new_user
|
||||||
= form_for @gestionnaire, url: {controller: 'gestionnaires/sessions', action: :create } do |f|
|
= form_for @gestionnaire, url: gestionnaire_session_path, method: :post do |f|
|
||||||
%h4
|
%h4
|
||||||
= f.label :email
|
= f.label :email
|
||||||
.input-group
|
.input-group
|
||||||
|
|
3
config/initializers/will_paginate.rb
Normal file
3
config/initializers/will_paginate.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
require 'will_paginate'
|
||||||
|
|
||||||
|
WillPaginate.per_page = 12
|
|
@ -19,10 +19,6 @@ class CARTO::SGMAP::API
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.base_url
|
def self.base_url
|
||||||
if Rails.env.production?
|
|
||||||
'https://apicarto.sgmap.fr'
|
|
||||||
else
|
|
||||||
'https://apicarto.sgmap.fr'
|
'https://apicarto.sgmap.fr'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class CARTO::SGMAP::QuartierPrioritaireAdapter
|
||||||
def to_params
|
def to_params
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
data_source[:features].each_with_index do |feature, index|
|
data_source[:features].each do |feature|
|
||||||
qp_code = feature[:properties][:code]
|
qp_code = feature[:properties][:code]
|
||||||
|
|
||||||
params[qp_code] = feature[:properties]
|
params[qp_code] = feature[:properties]
|
||||||
|
@ -19,10 +19,4 @@ class CARTO::SGMAP::QuartierPrioritaireAdapter
|
||||||
|
|
||||||
params
|
params
|
||||||
end
|
end
|
||||||
|
|
||||||
def properties_to_fetch
|
|
||||||
[:code,
|
|
||||||
:nom,
|
|
||||||
:commune]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -181,14 +181,20 @@ RSpec.describe Users::CarteController, type: :controller do
|
||||||
let(:coordinates) { '[]' }
|
let(:coordinates) { '[]' }
|
||||||
|
|
||||||
subject { JSON.parse(response.body) }
|
subject { JSON.parse(response.body) }
|
||||||
it { expect(subject['quartier_prioritaires']).to eq({}) }
|
|
||||||
|
it 'Quartier Prioritaire Adapter does not call' do
|
||||||
|
expect(subject['quartier_prioritaires']).to eq({})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when coordinates are informed' do
|
context 'when coordinates are informed' do
|
||||||
let(:coordinates) { '[[{"lat":48.87442541960633,"lng":2.3859214782714844},{"lat":48.87273183590832,"lng":2.3850631713867183},{"lat":48.87081237174292,"lng":2.3809432983398438},{"lat":48.8712640169951,"lng":2.377510070800781},{"lat":48.87510283703279,"lng":2.3778533935546875},{"lat":48.87544154230615,"lng":2.382831573486328},{"lat":48.87442541960633,"lng":2.3859214782714844}]]' }
|
let(:coordinates) { '[[{"lat":48.87442541960633,"lng":2.3859214782714844},{"lat":48.87273183590832,"lng":2.3850631713867183},{"lat":48.87081237174292,"lng":2.3809432983398438},{"lat":48.8712640169951,"lng":2.377510070800781},{"lat":48.87510283703279,"lng":2.3778533935546875},{"lat":48.87544154230615,"lng":2.382831573486328},{"lat":48.87442541960633,"lng":2.3859214782714844}]]' }
|
||||||
|
|
||||||
subject { JSON.parse(response.body) }
|
subject { JSON.parse(response.body)['quartier_prioritaires'] }
|
||||||
it { expect(subject['quartier_prioritaires']).not_to be_nil }
|
it { expect(subject).not_to be_nil }
|
||||||
|
it { expect(subject['QPCODE1234']['code']).to eq('QPCODE1234') }
|
||||||
|
it { expect(subject['QPCODE1234']['geometry']['type']).to eq('MultiPolygon') }
|
||||||
|
it { expect(subject['QPCODE1234']['geometry']['coordinates']).to eq([[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]]) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -88,6 +88,7 @@ describe Users::DossiersController, type: :controller do
|
||||||
|
|
||||||
it 'creates exercices for dossier' do
|
it 'creates exercices for dossier' do
|
||||||
expect { subject }.to change { Exercice.count }.by(3)
|
expect { subject }.to change { Exercice.count }.by(3)
|
||||||
|
expect(Exercice.last.etablissement).to eq(Dossier.last.etablissement)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'links procedure to dossier' do
|
it 'links procedure to dossier' do
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe CARTO::SGMAP::API do
|
||||||
context 'when geojson exist' do
|
context 'when geojson exist' do
|
||||||
let(:geojson) { File.read('spec/support/files/geojson/request.json') }
|
let(:geojson) { File.read('spec/support/files/geojson/request.json') }
|
||||||
let(:status) { 200 }
|
let(:status) { 200 }
|
||||||
let(:body) { File.read('spec/support/files/geojson/response.json') }
|
let(:body) { 'toto' }
|
||||||
|
|
||||||
it 'returns response body' do
|
it 'returns response body' do
|
||||||
expect(subject).to eq(body)
|
expect(subject).to eq(body)
|
||||||
|
|
|
@ -10,20 +10,23 @@ describe CARTO::SGMAP::QuartierPrioritaireAdapter do
|
||||||
to_return(status: status, body: body)
|
to_return(status: status, body: body)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'coordinates ard informed' do
|
context 'coordinates are filled' do
|
||||||
let(:coordinates) { '' }
|
let(:coordinates) { '[[2.252728, 43.27151][2.323223, 32.835332]]' }
|
||||||
let(:status) { 200 }
|
let(:status) { 200 }
|
||||||
let(:body) { File.read('spec/support/files/geojson/response.json') }
|
let(:body) { File.read('spec/support/files/geojson/response.json') }
|
||||||
|
|
||||||
it { expect(subject).to be_a_instance_of(Hash) }
|
it { expect(subject).to be_a_instance_of(Hash) }
|
||||||
|
|
||||||
context 'Attributs' do
|
context 'Attributes' do
|
||||||
let(:qp_code) { 'QP057019' }
|
let(:qp_code) { 'QP057019' }
|
||||||
it { expect(subject[qp_code][:code]).to eq(qp_code) }
|
|
||||||
it { expect(subject[qp_code][:nom]).to eq('Hauts De Vallières') }
|
|
||||||
it { expect(subject[qp_code][:commune]).to eq('Metz') }
|
|
||||||
|
|
||||||
it { expect(subject[qp_code][:geometry]).to eq({:type=>"MultiPolygon", :coordinates=>[[[[6.2136923480551, 49.1342109827851], [6.21416055031881, 49.1338823553928]]]]}) }
|
subject { super()[qp_code] }
|
||||||
|
|
||||||
|
it { expect(subject[:code]).to eq(qp_code) }
|
||||||
|
it { expect(subject[:nom]).to eq('Hauts De Vallières') }
|
||||||
|
it { expect(subject[:commune]).to eq('Metz') }
|
||||||
|
|
||||||
|
it { expect(subject[:geometry]).to eq({:type=>"MultiPolygon", :coordinates=>[[[[6.2136923480551, 49.1342109827851], [6.21416055031881, 49.1338823553928]]]]}) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe 'backoffice/dossiers/a_traiter.html.haml', type: :view do
|
||||||
let!(:decorate_dossier) { create(:dossier, :with_user, state: 'initiated', procedure: procedure).decorate }
|
let!(:decorate_dossier) { create(:dossier, :with_user, state: 'initiated', procedure: procedure).decorate }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
assign(:dossiers_a_traiter, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1, :per_page => 12).decorate)
|
assign(:dossiers_a_traiter, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate)
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe 'backoffice/dossiers/en_attente.html.haml', type: :view do
|
||||||
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'replied').decorate }
|
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'replied').decorate }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
assign(:dossiers_en_attente, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1, :per_page => 12).decorate)
|
assign(:dossiers_en_attente, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate)
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe 'backoffice/dossiers/termine.html.haml', type: :view do
|
||||||
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'closed').decorate }
|
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'closed').decorate }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
assign(:dossiers_termine, gestionnaire.dossiers.termine.paginate(:page => 1, :per_page => 12).decorate)
|
assign(:dossiers_termine, gestionnaire.dossiers.termine.paginate(:page => 1).decorate)
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe 'users/dossiers/a_traiter.html.haml', type: :view do
|
||||||
let!(:decorate_dossier) { create(:dossier, :with_procedure, user: user, state: 'replied').decorate }
|
let!(:decorate_dossier) { create(:dossier, :with_procedure, user: user, state: 'replied').decorate }
|
||||||
let!(:decorate_dossier_2) { create(:dossier, :with_procedure, user: user, state: 'initiated', nom_projet: 'projet de test').decorate }
|
let!(:decorate_dossier_2) { create(:dossier, :with_procedure, user: user, state: 'initiated', nom_projet: 'projet de test').decorate }
|
||||||
|
|
||||||
let(:dossiers_list) { user.dossiers.waiting_for_user.paginate(:page => 1, :per_page => 12).decorate }
|
let(:dossiers_list) { user.dossiers.waiting_for_user.paginate(:page => 1).decorate }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
assign(:dossiers, dossiers_list)
|
assign(:dossiers, dossiers_list)
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe 'users/dossiers/en_attente.html.haml', type: :view do
|
||||||
let!(:decorate_dossier) { create(:dossier, :with_procedure, user: user, state: 'initiated', nom_projet: 'projet de test').decorate }
|
let!(:decorate_dossier) { create(:dossier, :with_procedure, user: user, state: 'initiated', nom_projet: 'projet de test').decorate }
|
||||||
let!(:decorate_dossier_2) { create(:dossier, :with_procedure, user: user, state: 'replied').decorate }
|
let!(:decorate_dossier_2) { create(:dossier, :with_procedure, user: user, state: 'replied').decorate }
|
||||||
|
|
||||||
let(:dossiers_list) { user.dossiers.waiting_for_gestionnaire.paginate(:page => 1, :per_page => 12).decorate }
|
let(:dossiers_list) { user.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
assign(:dossiers, dossiers_list)
|
assign(:dossiers, dossiers_list)
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe 'users/dossiers/termine.html.haml', type: :view do
|
||||||
let!(:decorate_dossier_2) { create(:dossier, :with_procedure, user: user, state: 'replied', nom_projet: 'projet terminé').decorate }
|
let!(:decorate_dossier_2) { create(:dossier, :with_procedure, user: user, state: 'replied', nom_projet: 'projet terminé').decorate }
|
||||||
let!(:dossier_termine) { create(:dossier, :with_procedure, user: user, state: 'closed').decorate }
|
let!(:dossier_termine) { create(:dossier, :with_procedure, user: user, state: 'closed').decorate }
|
||||||
|
|
||||||
let(:dossiers_list) { user.dossiers.termine.paginate(:page => 1, :per_page => 12).decorate }
|
let(:dossiers_list) { user.dossiers.termine.paginate(:page => 1).decorate }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
assign(:dossiers, dossiers_list)
|
assign(:dossiers, dossiers_list)
|
||||||
|
|
Loading…
Reference in a new issue