- Code review
- Delete Mandataires sociaux adapter - Add function to get mandataires sociaux in Enterprise Adapter
This commit is contained in:
parent
e0d980e804
commit
e8fd212d13
14 changed files with 121 additions and 138 deletions
|
@ -11,7 +11,6 @@ class Admin::ProceduresController < AdminController
|
|||
partial: "admin/procedures/list",
|
||||
array: true
|
||||
|
||||
@page = 'active'
|
||||
active_class
|
||||
end
|
||||
|
||||
|
@ -21,7 +20,6 @@ class Admin::ProceduresController < AdminController
|
|||
partial: "admin/procedures/list",
|
||||
array: true
|
||||
|
||||
@page = 'archived'
|
||||
archived_class
|
||||
|
||||
render 'index'
|
||||
|
@ -78,11 +76,11 @@ class Admin::ProceduresController < AdminController
|
|||
end
|
||||
|
||||
def active_class
|
||||
@active_class = 'active' if @page == 'active'
|
||||
@active_class = 'active'
|
||||
end
|
||||
|
||||
def archived_class
|
||||
@archived_class = 'active' if @page == 'archived'
|
||||
@archived_class = 'active'
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -33,20 +33,21 @@ class FranceConnect::ParticulierController < ApplicationController
|
|||
end
|
||||
|
||||
def check_email
|
||||
return create if User.find_by_email(params[:user][:email]).nil?
|
||||
user = User.find_by_email(params[:user][:email])
|
||||
|
||||
return create if user.nil?
|
||||
return redirect_to root_path if france_connect_particulier_id_blank?
|
||||
|
||||
unless params[:user][:password].nil?
|
||||
user = User.find_by_email(params[:user][:email])
|
||||
valid_password = user.valid_password?(params[:user][:password])
|
||||
|
||||
if valid_password
|
||||
if user.valid_password?(params[:user][:password])
|
||||
user.update_attributes create_user_params
|
||||
return connect_france_connect_particulier user
|
||||
else
|
||||
flash.now.alert = 'Mot de passe invalide'
|
||||
end
|
||||
end
|
||||
|
||||
@user = (User.new create_user_params).decorate
|
||||
end
|
||||
|
||||
|
|
|
@ -37,43 +37,31 @@ class Users::DossiersController < UsersController
|
|||
end
|
||||
|
||||
def create
|
||||
etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
|
||||
entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
||||
rna_information = SIADE::RNAAdapter.new(siret).to_params
|
||||
exercices = SIADE::ExercicesAdapter.new(siret).to_params
|
||||
mandataires_sociaux = SIADE::MandatairesSociauxAdapter.new(siren).to_params
|
||||
entreprise_adapter = SIADE::EntrepriseAdapter.new(siren)
|
||||
|
||||
dossier = Dossier.create(user: current_user,
|
||||
state: 'draft',
|
||||
procedure_id: create_params[:procedure_id],
|
||||
mandataire_social: mandataire_social?(entreprise_adapter.mandataires_sociaux))
|
||||
|
||||
entreprise = Entreprise.create entreprise_adapter.to_params
|
||||
.merge({dossier_id: dossier.id})
|
||||
|
||||
etablissement = Etablissement.create SIADE::EtablissementAdapter.new(siret).to_params
|
||||
.merge({dossier_id: dossier.id,
|
||||
entreprise_id: entreprise.id})
|
||||
|
||||
rna_information = SIADE::RNAAdapter.new(siret).to_params
|
||||
unless rna_information.nil?
|
||||
RNAInformation.create rna_information.merge({entreprise_id: entreprise.id})
|
||||
end
|
||||
|
||||
exercices = SIADE::ExercicesAdapter.new(siret).to_params
|
||||
unless exercices.nil?
|
||||
exercices.each_value do |exercice|
|
||||
exercice = Exercice.new(exercice)
|
||||
exercice.etablissement = etablissement
|
||||
exercice.save
|
||||
Exercice.create(exercice.merge({etablissement_id: etablissement.id}))
|
||||
end
|
||||
end
|
||||
mandataire_social = false
|
||||
|
||||
mandataires_sociaux.each do |k, mandataire|
|
||||
break mandataire_social = true if !current_user.france_connect_particulier_id.nil? &&
|
||||
mandataire[:nom] == current_user.family_name &&
|
||||
mandataire[:prenom] == current_user.given_name &&
|
||||
mandataire[:date_naissance_timestamp] == current_user.birthdate.to_time.to_i
|
||||
|
||||
end
|
||||
|
||||
dossier = Dossier.create(user: current_user, state: 'draft', procedure_id: create_params[:procedure_id], mandataire_social: mandataire_social)
|
||||
|
||||
entreprise.dossier = dossier
|
||||
entreprise.save
|
||||
|
||||
unless rna_information.nil?
|
||||
rna_information = RNAInformation.new(rna_information)
|
||||
rna_information.entreprise = entreprise
|
||||
rna_information.save
|
||||
end
|
||||
|
||||
etablissement.dossier = dossier
|
||||
etablissement.entreprise = entreprise
|
||||
etablissement.save
|
||||
|
||||
redirect_to url_for(controller: :dossiers, action: :show, id: dossier.id)
|
||||
|
||||
|
@ -177,4 +165,17 @@ class Users::DossiersController < UsersController
|
|||
|
||||
redirect_to url_for users_dossiers_path
|
||||
end
|
||||
|
||||
def mandataire_social? mandataires_list
|
||||
mandataire_social = false
|
||||
|
||||
mandataires_list.each do |mandataire|
|
||||
break mandataire_social = true if !current_user.france_connect_particulier_id.nil? &&
|
||||
mandataire[:nom].upcase == current_user.family_name.upcase &&
|
||||
mandataire[:prenom].upcase == current_user.given_name.upcase &&
|
||||
mandataire[:date_naissance_timestamp] == current_user.birthdate.to_time.to_i
|
||||
end
|
||||
|
||||
mandataire_social
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,6 @@ class Etablissement < ActiveRecord::Base
|
|||
has_many :exercices
|
||||
|
||||
def geo_adresse
|
||||
numero_voie.to_s << ' ' << type_voie.to_s << ' ' << nom_voie.to_s << ' ' << complement_adresse.to_s << ' ' << code_postal.to_s << ' ' << localite.to_s
|
||||
[numero_voie, type_voie, nom_voie, complement_adresse, code_postal, localite].join(' ')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
%br
|
||||
%p
|
||||
%h4.center Nous vous avons trouvé un compte qui utilise déjà cette adresse email.
|
||||
%h4.center Nous avons trouvé un compte qui utilise déjà cette adresse email.
|
||||
%p.center
|
||||
Afin d'associer ce compte à votre identifiant France Connect, merci de saisir votre mot de passe TPS.
|
||||
%br
|
||||
|
@ -15,7 +15,7 @@
|
|||
#france_connect_particulier_email
|
||||
= form_for @user, url: {controller: 'france_connect/particulier', action: :check_email}, method: :post do |f|
|
||||
.form-group.form-group-lg
|
||||
= f.text_field :email, class: "form-control", placeholder: "Entrez votre email", readonly: 'readonly'
|
||||
= f.text_field :email, class: "form-control", readonly: 'readonly'
|
||||
%br
|
||||
= f.password_field :password, class: "form-control", placeholder: "Entrez votre mot de passe"
|
||||
= f.hidden_field :email
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue