Merge commit '9e737992c4f7f32b4bc48b1a2aa7235f881417cc'

This commit is contained in:
gregoirenovel 2018-10-04 19:47:11 +02:00
commit 18d2c71135
13 changed files with 56 additions and 99 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View file

@ -238,18 +238,6 @@ div.pagination {
left: 23% !important;
}
#fconnect-profile {
margin-top: 5px;
display: inline-block;
a {
color: #3471A9 !important;
text-decoration: none;
font-size: 16px !important;
margin-right: 0px !important;
}
}
.no-padding {
padding: 0;
}

View file

@ -240,8 +240,6 @@ module NewGestionnaire
end
end.each do |group_key, fields|
case group_key
when 'france_connect_information'
@dossiers = @dossiers.includes({ user: :france_connect_information })
when 'type_de_champ_group'
if fields.any? { |field| field['table'] == 'type_de_champ' }
@dossiers = @dossiers.includes(:champs).references(:champs)

View file

@ -73,17 +73,6 @@ class Users::DossiersController < UsersController
@siret = current_user.siret
end
if @facade.procedure.for_individual? && current_user.loged_in_with_france_connect?
individual = @facade.dossier.individual
individual.update_column :gender, @facade.dossier.france_connect_information.gender
individual.update_column :nom, @facade.dossier.france_connect_information.family_name
individual.update_column :prenom, @facade.dossier.france_connect_information.given_name
individual.birthdate = @facade.dossier.france_connect_information.birthdate
individual.save
end
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for dossiers_path

View file

@ -83,8 +83,6 @@ class Dossier < ApplicationRecord
def update_search_terms
self.search_terms = [
user&.email,
france_connect_information&.given_name,
france_connect_information&.family_name,
*champs.flat_map(&:search_terms),
*etablissement&.search_terms,
individual&.nom,

View file

@ -19,7 +19,6 @@ class User < ApplicationRecord
has_many :feedbacks, dependent: :destroy
has_one :france_connect_information, dependent: :destroy
delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information
accepts_nested_attributes_for :france_connect_information
before_validation -> { sanitize_email(:email) }

View file

@ -9,12 +9,6 @@ class DossierFieldService
field_hash('Demandeur', 'user', 'email')
]
fields.push(
field_hash('Civilité (FC)', 'france_connect_information', 'gender'),
field_hash('Prénom (FC)', 'france_connect_information', 'given_name'),
field_hash('Nom (FC)', 'france_connect_information', 'family_name')
)
if !procedure.for_individual || (procedure.for_individual && procedure.individual_with_siret)
fields.push(
field_hash('SIREN', 'etablissement', 'entreprise_siren'),
@ -53,8 +47,6 @@ class DossierFieldService
dossier.send(column)
when 'user'
dossier.user.send(column)
when 'france_connect_information'
dossier.user.france_connect_information&.send(column)
when 'etablissement'
dossier.etablissement&.send(column)
when 'type_de_champ'
@ -82,11 +74,6 @@ class DossierFieldService
when 'self'
dossiers.where("? ILIKE ?", filter['column'], "%#{filter['value']}%")
when 'france_connect_information'
dossiers
.includes(user: :france_connect_information)
.where("? ILIKE ?", "france_connect_informations.#{filter['column']}", "%#{filter['value']}%")
when 'type_de_champ', 'type_de_champ_private'
relation = table == 'type_de_champ' ? :champs : :champs_private
dossiers
@ -133,11 +120,6 @@ class DossierFieldService
return dossiers
.order("#{column} #{order}")
.pluck(:id)
when 'france_connect_information'
return dossiers
.includes(user: :france_connect_information)
.order("#{column} #{order}")
.pluck(:id)
when 'type_de_champ', 'type_de_champ_private'
return dossiers
.includes(table == 'type_de_champ' ? :champs : :champs_private)

View file

@ -1,12 +1,3 @@
- if current_user.loged_in_with_france_connect?
#fconnect-profile{ "data-fc-logout-url" => '/users/sign_out" data-method="delete' }
%a.text-info{ href: "#" }
= "#{current_user.given_name} #{current_user.family_name}"
= link_to "/users/sign_out", method: :delete do
%span.fa.fa-sign-out
Se déconnecter
- else
= link_to "/users/sign_out", method: :delete do
%span.fa.fa-sign-out
Se déconnecter
= link_to "/users/sign_out", method: :delete do
%span.fa.fa-sign-out
Se déconnecter

View file

@ -0,0 +1,52 @@
namespace :'2018_10_03_remove_fc_from_procedure_presentation' do
task run: :environment do
Class.new do
def run
fix_displayed_fields
fix_sort
fix_filters
end
def fix_displayed_fields
ProcedurePresentation.where(%q`displayed_fields @> '[{"table": "france_connect_information"}]'`).each do |procedure_presentation|
procedure_presentation.displayed_fields = procedure_presentation.displayed_fields.reject do |df|
df['table'] == 'france_connect_information'
end
procedure_presentation.save(validate: false)
end
end
def fix_sort
ProcedurePresentation.where(%q`sort @> '{"table": "france_connect_information"}'`).each do |procedure_presentation|
procedure_presentation.sort = {
"order" => "desc",
"table" => "notifications",
"column" => "notifications"
}
procedure_presentation.save(validate: false)
end
end
def fix_filters
ProcedurePresentation.find_by_sql(
<<~SQL
SELECT procedure_presentations.*
FROM procedure_presentations, LATERAL jsonb_each(filters)
WHERE value @> '[{"table": "france_connect_information"}]'
GROUP BY id;
SQL
).each do |procedure_presentation|
procedure_presentation.filters.keys.each do |key|
procedure_presentation.filters[key] = procedure_presentation.filters[key].reject do |filter|
filter['table'] == 'france_connect_information'
end
end
procedure_presentation.save
end
end
end.new.run
end
end

View file

@ -75,7 +75,7 @@ describe Dossier do
dossier.update_search_terms
end
it { expect(dossier.search_terms).to eq("#{user.email} #{france_connect_information.given_name} #{france_connect_information.family_name} champ public #{etablissement.entreprise_siren} #{etablissement.entreprise_numero_tva_intracommunautaire} #{etablissement.entreprise_forme_juridique} #{etablissement.entreprise_forme_juridique_code} #{etablissement.entreprise_nom_commercial} #{etablissement.entreprise_raison_sociale} #{etablissement.entreprise_siret_siege_social} #{etablissement.entreprise_nom} #{etablissement.entreprise_prenom} #{etablissement.association_rna} #{etablissement.association_titre} #{etablissement.association_objet} #{etablissement.siret} #{etablissement.naf} #{etablissement.libelle_naf} #{etablissement.adresse} #{etablissement.code_postal} #{etablissement.localite} #{etablissement.code_insee_localite}") }
it { expect(dossier.search_terms).to eq("#{user.email} champ public #{etablissement.entreprise_siren} #{etablissement.entreprise_numero_tva_intracommunautaire} #{etablissement.entreprise_forme_juridique} #{etablissement.entreprise_forme_juridique_code} #{etablissement.entreprise_nom_commercial} #{etablissement.entreprise_raison_sociale} #{etablissement.entreprise_siret_siege_social} #{etablissement.entreprise_nom} #{etablissement.entreprise_prenom} #{etablissement.association_rna} #{etablissement.association_titre} #{etablissement.association_objet} #{etablissement.siret} #{etablissement.naf} #{etablissement.libelle_naf} #{etablissement.adresse} #{etablissement.code_postal} #{etablissement.localite} #{etablissement.code_insee_localite}") }
it { expect(dossier.private_search_terms).to eq('champ privé') }
context 'with an update' do
@ -749,7 +749,6 @@ describe Dossier do
it { expect(dossier.get_value('self', 'created_at')).to eq(dossier.created_at) }
it { expect(dossier.get_value('user', 'email')).to eq(user.email) }
it { expect(dossier.get_value('france_connect_information', 'gender')).to eq(user.france_connect_information.gender) }
it { expect(dossier.get_value('etablissement', 'entreprise_siren')).to eq(dossier.etablissement.entreprise_siren) }
it { expect(dossier.get_value('etablissement', 'siret')).to eq(dossier.etablissement.siret) }
it { expect(dossier.get_value('type_de_champ', @champ_public.type_de_champ.id.to_s)).to eq(dossier.champs.first.value) }

View file

@ -639,9 +639,6 @@ describe Procedure do
{ "label" => 'Créé le', "table" => 'self', "column" => 'created_at' },
{ "label" => 'Mis à jour le', "table" => 'self', "column" => 'updated_at' },
{ "label" => 'Demandeur', "table" => 'user', "column" => 'email' },
{ "label" => 'Civilité (FC)', "table" => 'france_connect_information', "column" => 'gender' },
{ "label" => 'Prénom (FC)', "table" => 'france_connect_information', "column" => 'given_name' },
{ "label" => 'Nom (FC)', "table" => 'france_connect_information', "column" => 'family_name' },
{ "label" => 'SIREN', "table" => 'etablissement', "column" => 'entreprise_siren' },
{ "label" => 'Forme juridique', "table" => 'etablissement', "column" => 'entreprise_forme_juridique' },
{ "label" => 'Nom commercial', "table" => 'etablissement', "column" => 'entreprise_nom_commercial' },

View file

@ -118,22 +118,6 @@ describe DossierFieldService do
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
end
context 'for france_connect_information table' do
let(:table) { 'france_connect_information' }
let(:column) { 'given_name' } # All other columns work the same, no extra test required
let(:order) { 'asc' } # Desc works the same, no extra test required
let(:anna_dossier) { create(:dossier, procedure: procedure) }
let(:zacharie_dossier) { create(:dossier, procedure: procedure) }
before do
create(:france_connect_information, given_name: 'Anna', user: anna_dossier.user)
create(:france_connect_information, given_name: 'Zacharie', user: zacharie_dossier.user)
end
it { is_expected.to eq([anna_dossier, zacharie_dossier].map(&:id)) }
end
context 'for type_de_champ table' do
let(:table) { 'type_de_champ' }
let(:column) { procedure.types_de_champ.first.id.to_s }
@ -202,17 +186,6 @@ describe DossierFieldService do
it { is_expected.to eq('bla@yopmail.com') }
end
context 'for france_connect_information table' do
let(:table) { 'france_connect_information' }
let(:column) { 'given_name' } # All other columns work the same, no extra test required
let(:dossier) { create(:dossier, procedure: procedure) }
before { create(:france_connect_information, given_name: 'Anna', user: dossier.user) }
it { is_expected.to eq('Anna') }
end
context 'for etablissement table' do
let(:table) { 'etablissement' }
let(:column) { 'code_postal' } # All other columns work the same, no extra test required

View file

@ -39,15 +39,6 @@
width: 38px;
}
#fconnect-profile > a {
padding: 15px 0 15px 50px;
color: #ffffff;
margin-right: 10px;
font-size: 18px;
background: image-url('logo_mini_FC.png') left center no-repeat;
background-size: 40px;
}
#fconnect-access {
all: initial;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;