Merge branch 'develop' into staging
This commit is contained in:
commit
a45ae986c6
20 changed files with 126 additions and 25 deletions
|
@ -4,6 +4,7 @@ $(document).ready(button_edit_procedure_init);
|
||||||
function button_edit_procedure_init(){
|
function button_edit_procedure_init(){
|
||||||
buttons_api_carto();
|
buttons_api_carto();
|
||||||
button_cerfa();
|
button_cerfa();
|
||||||
|
button_individual();
|
||||||
}
|
}
|
||||||
|
|
||||||
function buttons_api_carto () {
|
function buttons_api_carto () {
|
||||||
|
@ -25,3 +26,13 @@ function button_cerfa () {
|
||||||
if ($('#procedure_cerfa_flag').is(':checked'))
|
if ($('#procedure_cerfa_flag').is(':checked'))
|
||||||
$("#procedure_lien_demarche").show();
|
$("#procedure_lien_demarche").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function button_individual () {
|
||||||
|
|
||||||
|
$("#procedure_for_individual").on('change', function() {
|
||||||
|
$("#individual_with_siret").toggle()
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($('#procedure_for_individual').is(':checked'))
|
||||||
|
$("#individual_with_siret").show();
|
||||||
|
}
|
|
@ -5,3 +5,7 @@
|
||||||
#procedure_lien_demarche{
|
#procedure_lien_demarche{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#individual_with_siret {
|
||||||
|
display: none;
|
||||||
|
}
|
|
@ -187,7 +187,7 @@ class Admin::ProceduresController < AdminController
|
||||||
private
|
private
|
||||||
|
|
||||||
def create_procedure_params
|
def create_procedure_params
|
||||||
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :lien_site_web, :lien_notice, :euro_flag, :logo, :cerfa_flag, :for_individual, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
|
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :lien_site_web, :lien_notice, :euro_flag, :logo, :cerfa_flag, :for_individual, :individual_with_siret, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_module_api_carto_params
|
def create_module_api_carto_params
|
||||||
|
|
13
app/controllers/users/dossiers/add_siret_controller.rb
Normal file
13
app/controllers/users/dossiers/add_siret_controller.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
class Users::Dossiers::AddSiretController < ApplicationController
|
||||||
|
def show
|
||||||
|
@facade = DossierFacades.new params[:dossier_id], current_user.email
|
||||||
|
|
||||||
|
raise ActiveRecord::RecordNotFound unless @facade.procedure.individual_with_siret?
|
||||||
|
|
||||||
|
@siret = current_user.siret unless current_user.siret.nil?
|
||||||
|
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
flash.alert = t('errors.messages.dossier_not_found')
|
||||||
|
redirect_to url_for users_dossiers_path
|
||||||
|
end
|
||||||
|
end
|
|
@ -65,8 +65,12 @@ class Users::DossiersController < UsersController
|
||||||
end
|
end
|
||||||
|
|
||||||
@facade = facade params[:dossier_id]
|
@facade = facade params[:dossier_id]
|
||||||
render '/dossiers/new_siret', formats: 'js'
|
|
||||||
|
|
||||||
|
if @facade.procedure.individual_with_siret?
|
||||||
|
render '/dossiers/add_siret', formats: 'js'
|
||||||
|
else
|
||||||
|
render '/dossiers/new_siret', formats: 'js'
|
||||||
|
end
|
||||||
rescue RestClient::ResourceNotFound, RestClient::BadRequest
|
rescue RestClient::ResourceNotFound, RestClient::BadRequest
|
||||||
errors_valid_siret
|
errors_valid_siret
|
||||||
|
|
||||||
|
@ -80,7 +84,11 @@ class Users::DossiersController < UsersController
|
||||||
|
|
||||||
@facade = facade params[:dossier_id]
|
@facade = facade params[:dossier_id]
|
||||||
|
|
||||||
render '/dossiers/new_siret', formats: :js
|
if @facade.procedure.individual_with_siret?
|
||||||
|
render '/dossiers/add_siret', formats: 'js'
|
||||||
|
else
|
||||||
|
render '/dossiers/new_siret', formats: 'js'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
@ -73,8 +73,6 @@ class Dossier < ActiveRecord::Base
|
||||||
|
|
||||||
def build_default_individual
|
def build_default_individual
|
||||||
Individual.new(dossier_id: id).save(validate: false)
|
Individual.new(dossier_id: id).save(validate: false)
|
||||||
Entreprise.new(dossier_id: id).save(validate: false)
|
|
||||||
Etablissement.new(dossier_id: id, entreprise_id: entreprise.id).save(validate: false)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def ordered_champs
|
def ordered_champs
|
||||||
|
@ -289,7 +287,8 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset!
|
def reset!
|
||||||
entreprise.destroy unless entreprise.nil?
|
etablissement.destroy
|
||||||
|
entreprise.destroy
|
||||||
|
|
||||||
update_attributes(autorisation_donnees: false)
|
update_attributes(autorisation_donnees: false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,7 @@ class Entreprise < ActiveRecord::Base
|
||||||
has_one :rna_information, dependent: :destroy
|
has_one :rna_information, dependent: :destroy
|
||||||
|
|
||||||
validates_presence_of :siren
|
validates_presence_of :siren
|
||||||
|
validates_uniqueness_of :dossier_id
|
||||||
|
|
||||||
before_save :default_values
|
before_save :default_values
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ class Etablissement < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :exercices, dependent: :destroy
|
has_many :exercices, dependent: :destroy
|
||||||
|
|
||||||
|
validates_uniqueness_of :dossier_id
|
||||||
|
|
||||||
def geo_adresse
|
def geo_adresse
|
||||||
[numero_voie, type_voie, nom_voie, complement_adresse, code_postal, localite].join(' ')
|
[numero_voie, type_voie, nom_voie, complement_adresse, code_postal, localite].join(' ')
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,5 +37,6 @@ class TypeDeChamp < ActiveRecord::Base
|
||||||
|
|
||||||
def change_header_section_mandatory
|
def change_header_section_mandatory
|
||||||
self.mandatory = false if self.type_champ == 'header_section'
|
self.mandatory = false if self.type_champ == 'header_section'
|
||||||
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -60,9 +60,16 @@
|
||||||
.row
|
.row
|
||||||
.col-md-6.col-lg-6
|
.col-md-6.col-lg-6
|
||||||
%h4 Particuliers
|
%h4 Particuliers
|
||||||
|
%div
|
||||||
%label
|
%label
|
||||||
=f.check_box :for_individual
|
=f.check_box :for_individual
|
||||||
Cette procédure s'adresse à un public qui
|
Cette procédure s'adresse à un public qui
|
||||||
%b
|
%b
|
||||||
ne possède pas de numéro SIRET,
|
ne possède pas (ou pas encore) de numéro SIRET,
|
||||||
qui doivent donc s'identifier en tant que personne physique.
|
qui doivent donc s'identifier en tant que personne physique.
|
||||||
|
|
||||||
|
%ul#individual_with_siret{style:'margin-top: 8px'}
|
||||||
|
%li
|
||||||
|
%label
|
||||||
|
=f.check_box :individual_with_siret
|
||||||
|
Donner la possibilité de renseigner un SIRET au cours de la construction du dossier.
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
= @facade.dossier.display_state
|
= @facade.dossier.display_state
|
||||||
|
|
||||||
= render partial: 'follow_action'
|
= render partial: 'follow_action'
|
||||||
- unless @facade.procedure.for_individual?
|
- unless @facade.entreprise.nil?
|
||||||
= render partial: '/dossiers/infos_entreprise'
|
= render partial: '/dossiers/infos_entreprise'
|
||||||
|
|
||||||
= render partial: '/dossiers/infos_dossier'
|
= render partial: '/dossiers/infos_dossier'
|
||||||
|
|
|
@ -54,6 +54,9 @@
|
||||||
= render partial: 'users/recapitulatif/modal_upload_pj'
|
= render partial: 'users/recapitulatif/modal_upload_pj'
|
||||||
|
|
||||||
|
|
||||||
|
-if @facade.procedure.individual_with_siret
|
||||||
|
%a#add_siret.btn.btn-success{href: users_dossier_add_siret_path(dossier_id: @facade.dossier.id)}
|
||||||
|
= "Renseigner un SIRET"
|
||||||
-if @facade.dossier.procedure.module_api_carto.use_api_carto
|
-if @facade.dossier.procedure.module_api_carto.use_api_carto
|
||||||
%a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@facade.dossier.id}/carte"}
|
%a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@facade.dossier.id}/carte"}
|
||||||
= 'Modifier la carte'
|
= 'Modifier la carte'
|
||||||
|
|
12
app/views/dossiers/add_siret.js.erb
Normal file
12
app/views/dossiers/add_siret.js.erb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<% if flash.empty? %>
|
||||||
|
$('.row.etape.etape_2').hide(300, render_new_siret);
|
||||||
|
$('.row.etape.etape_2').slideDown(400, the_terms);
|
||||||
|
<% else %>
|
||||||
|
error_form_siret('<%= invalid_siret %>');
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% flash.clear %>
|
||||||
|
|
||||||
|
function render_new_siret(){
|
||||||
|
$('.row.etape.etape_2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape_2/entreprise', locals: { facade: @facade } ) %>");
|
||||||
|
}
|
|
@ -8,7 +8,6 @@ error_form_siret('<%= invalid_siret %>');
|
||||||
|
|
||||||
<% flash.clear %>
|
<% flash.clear %>
|
||||||
|
|
||||||
|
|
||||||
function render_new_siret(){
|
function render_new_siret(){
|
||||||
$('.row.etape.etape_2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape2', locals: { facade: @facade } ) %>");
|
$('.row.etape.etape_2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape2', locals: { facade: @facade } ) %>");
|
||||||
}
|
}
|
2
app/views/users/dossiers/add_siret/show.html.haml
Normal file
2
app/views/users/dossiers/add_siret/show.html.haml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.row.etape.etape_2
|
||||||
|
= render partial: 'dossiers/etapes/etape_2/entreprise'
|
|
@ -62,6 +62,8 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :dossiers do
|
resources :dossiers do
|
||||||
|
get '/add_siret' => 'dossiers/add_siret#show'
|
||||||
|
|
||||||
get '/description' => 'description#show'
|
get '/description' => 'description#show'
|
||||||
get '/description/error' => 'description#error'
|
get '/description/error' => 'description#error'
|
||||||
post 'description' => 'description#create'
|
post 'description' => 'description#create'
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddIndividualWithSiretInProcedure < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :procedures, :individual_with_siret, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20161004175442) do
|
ActiveRecord::Schema.define(version: 20161005082113) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -295,6 +295,7 @@ ActiveRecord::Schema.define(version: 20161004175442) do
|
||||||
t.string "lien_site_web"
|
t.string "lien_site_web"
|
||||||
t.string "lien_notice"
|
t.string "lien_notice"
|
||||||
t.boolean "for_individual", default: false
|
t.boolean "for_individual", default: false
|
||||||
|
t.boolean "individual_with_siret", default: false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "quartier_prioritaires", force: :cascade do |t|
|
create_table "quartier_prioritaires", force: :cascade do |t|
|
||||||
|
|
25
spec/controllers/users/dossiers/add_siret_controller_spec.rb
Normal file
25
spec/controllers/users/dossiers/add_siret_controller_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Users::Dossiers::AddSiretController, type: :controller do
|
||||||
|
describe '#GET show' do
|
||||||
|
|
||||||
|
let(:dossier) { create :dossier }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in dossier.user
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { get :show, dossier_id: dossier.id }
|
||||||
|
|
||||||
|
context 'when dossier is not attached at a procedure with individual siret attribut' do
|
||||||
|
it { is_expected.to redirect_to users_dossiers_path }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier is attached at a procedure with individual siret attribut' do
|
||||||
|
let(:procedure) { create :procedure, individual_with_siret: true }
|
||||||
|
let(:dossier) { create :dossier, procedure: procedure }
|
||||||
|
|
||||||
|
it { expect(subject.status).to eq 200 }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'users/recapitulatif/show.html.haml', type: :view do
|
describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative)) }
|
let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative, for_individual: true, individual_with_siret: true)) }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:state) { 'draft' }
|
let(:state) { 'draft' }
|
||||||
|
|
||||||
|
@ -46,6 +46,12 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'lien carte' do
|
||||||
|
it 'le lien vers le renseignement un SIRET est présent' do
|
||||||
|
expect(rendered).to have_css('#add_siret')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'lien carte' do
|
context 'lien carte' do
|
||||||
it 'le lien vers carte est présent' do
|
it 'le lien vers carte est présent' do
|
||||||
expect(rendered).to have_css('#maj_carte')
|
expect(rendered).to have_css('#maj_carte')
|
||||||
|
|
Loading…
Reference in a new issue