Merge branch 'develop' into staging

This commit is contained in:
Xavier J 2016-10-05 15:01:42 +02:00
commit a45ae986c6
20 changed files with 126 additions and 25 deletions

View file

@ -4,6 +4,7 @@ $(document).ready(button_edit_procedure_init);
function button_edit_procedure_init(){
buttons_api_carto();
button_cerfa();
button_individual();
}
function buttons_api_carto () {
@ -25,3 +26,13 @@ function button_cerfa () {
if ($('#procedure_cerfa_flag').is(':checked'))
$("#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();
}

View file

@ -5,3 +5,7 @@
#procedure_lien_demarche{
display: none;
}
#individual_with_siret {
display: none;
}

View file

@ -187,7 +187,7 @@ class Admin::ProceduresController < AdminController
private
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
def create_module_api_carto_params

View 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

View file

@ -65,8 +65,12 @@ class Users::DossiersController < UsersController
end
@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
errors_valid_siret
@ -80,7 +84,11 @@ class Users::DossiersController < UsersController
@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
def update

View file

@ -73,8 +73,6 @@ class Dossier < ActiveRecord::Base
def build_default_individual
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
def ordered_champs
@ -289,7 +287,8 @@ class Dossier < ActiveRecord::Base
end
def reset!
entreprise.destroy unless entreprise.nil?
etablissement.destroy
entreprise.destroy
update_attributes(autorisation_donnees: false)
end

View file

@ -4,6 +4,7 @@ class Entreprise < ActiveRecord::Base
has_one :rna_information, dependent: :destroy
validates_presence_of :siren
validates_uniqueness_of :dossier_id
before_save :default_values

View file

@ -4,6 +4,8 @@ class Etablissement < ActiveRecord::Base
has_many :exercices, dependent: :destroy
validates_uniqueness_of :dossier_id
def geo_adresse
[numero_voie, type_voie, nom_voie, complement_adresse, code_postal, localite].join(' ')
end

View file

@ -28,7 +28,7 @@ class TypeDeChamp < ActiveRecord::Base
before_validation :change_header_section_mandatory
def self.type_de_champs_list_fr
type_champs.map { |champ| [ I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first ] }
type_champs.map { |champ| [I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first] }
end
def field_for_list?
@ -37,5 +37,6 @@ class TypeDeChamp < ActiveRecord::Base
def change_header_section_mandatory
self.mandatory = false if self.type_champ == 'header_section'
true
end
end

View file

@ -25,7 +25,7 @@
%h4 Drapeau européen
%label
=f.check_box :euro_flag
Afficher le drapeau européen
Afficher le drapeau européen
%br
@ -60,9 +60,16 @@
.row
.col-md-6.col-lg-6
%h4 Particuliers
%label
=f.check_box :for_individual
Cette procédure s'adresse à un public qui
%b
ne possède pas de numéro SIRET,
qui doivent donc s'identifier en tant que personne physique.
%div
%label
=f.check_box :for_individual
Cette procédure s'adresse à un public qui
%b
ne possède pas (ou pas encore) de numéro SIRET,
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.

View file

@ -7,7 +7,7 @@
= @facade.dossier.display_state
= render partial: 'follow_action'
- unless @facade.procedure.for_individual?
- unless @facade.entreprise.nil?
= render partial: '/dossiers/infos_entreprise'
= render partial: '/dossiers/infos_dossier'

View file

@ -54,6 +54,9 @@
= 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
%a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@facade.dossier.id}/carte"}
= 'Modifier la carte'

View 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 } ) %>");
}

View file

@ -8,7 +8,6 @@ error_form_siret('<%= invalid_siret %>');
<% flash.clear %>
function render_new_siret(){
$('.row.etape.etape_2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape2', locals: { facade: @facade } ) %>");
}

View file

@ -0,0 +1,2 @@
.row.etape.etape_2
= render partial: 'dossiers/etapes/etape_2/entreprise'

View file

@ -62,6 +62,8 @@ Rails.application.routes.draw do
end
resources :dossiers do
get '/add_siret' => 'dossiers/add_siret#show'
get '/description' => 'description#show'
get '/description/error' => 'description#error'
post 'description' => 'description#create'

View file

@ -0,0 +1,5 @@
class AddIndividualWithSiretInProcedure < ActiveRecord::Migration
def change
add_column :procedures, :individual_with_siret, :boolean, default: false
end
end

View file

@ -11,7 +11,7 @@
#
# 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
enable_extension "plpgsql"
@ -282,19 +282,20 @@ ActiveRecord::Schema.define(version: 20161004175442) do
t.string "organisation"
t.string "direction"
t.string "lien_demarche"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "test"
t.integer "administrateur_id"
t.boolean "archived", default: false
t.boolean "euro_flag", default: false
t.boolean "archived", default: false
t.boolean "euro_flag", default: false
t.string "logo"
t.boolean "cerfa_flag", default: false
t.boolean "cerfa_flag", default: false
t.string "logo_secure_token"
t.boolean "published", default: false, null: false
t.boolean "published", default: false, null: false
t.string "lien_site_web"
t.string "lien_notice"
t.boolean "for_individual", default: false
t.boolean "for_individual", default: false
t.boolean "individual_with_siret", default: false
end
create_table "quartier_prioritaires", force: :cascade do |t|

View 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

View file

@ -1,7 +1,7 @@
require 'spec_helper'
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(:state) { 'draft' }
@ -46,6 +46,12 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
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
it 'le lien vers carte est présent' do
expect(rendered).to have_css('#maj_carte')