From 8ade790a81c5cc040157573b5c627c807849df43 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Thu, 6 Oct 2016 11:21:07 +0200 Subject: [PATCH 1/2] Add gender on individual form --- app/controllers/users/dossiers_controller.rb | 2 +- app/views/dossiers/etapes/etape_2/_individual.html.haml | 5 +++++ db/migrate/20161006085422_add_gender_in_individual_table.rb | 5 +++++ db/schema.rb | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20161006085422_add_gender_in_individual_table.rb diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index a0dac2e30..bcda80d68 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -132,7 +132,7 @@ class Users::DossiersController < UsersController end def update_params - params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:nom, :prenom, :birthdate]) + params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:gender, :nom, :prenom, :birthdate]) end def checked_autorisation_donnees? diff --git a/app/views/dossiers/etapes/etape_2/_individual.html.haml b/app/views/dossiers/etapes/etape_2/_individual.html.haml index 0b1c37ece..6807a0daa 100644 --- a/app/views/dossiers/etapes/etape_2/_individual.html.haml +++ b/app/views/dossiers/etapes/etape_2/_individual.html.haml @@ -13,6 +13,11 @@ = f.hidden_field :id = f.fields_for :individual, @facade.individual do |ff| + .form-group + %label + %h4 + Civilité + = ff.select :gender, ['Monsieur', 'Madame'] .form-group %label %h4 diff --git a/db/migrate/20161006085422_add_gender_in_individual_table.rb b/db/migrate/20161006085422_add_gender_in_individual_table.rb new file mode 100644 index 000000000..a60839072 --- /dev/null +++ b/db/migrate/20161006085422_add_gender_in_individual_table.rb @@ -0,0 +1,5 @@ +class AddGenderInIndividualTable < ActiveRecord::Migration + def change + add_column :individuals, :gender, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 9eb0892ec..a89a328ef 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20161005144657) do +ActiveRecord::Schema.define(version: 20161006085422) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -218,6 +218,7 @@ ActiveRecord::Schema.define(version: 20161005144657) do t.string "prenom" t.string "birthdate" t.integer "dossier_id" + t.string "gender" end create_table "invites", force: :cascade do |t| From 52bac4f3f9f006b4f77252b5ed137282abd25f73 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Thu, 6 Oct 2016 11:45:26 +0200 Subject: [PATCH 2/2] Add automatically values on individual form if user is logged with FranceConnect --- app/controllers/users/dossiers_controller.rb | 9 +++++++++ app/views/dossiers/etapes/etape_2/_individual.html.haml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index bcda80d68..91020bc73 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -48,6 +48,15 @@ class Users::DossiersController < UsersController @facade = facade @siret = current_user.siret unless current_user.siret.nil? + 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.update_column :birthdate, @facade.dossier.france_connect_information.birthdate.strftime("%d/%m/%Y") + end + rescue ActiveRecord::RecordNotFound flash.alert = t('errors.messages.dossier_not_found') redirect_to url_for users_dossiers_path diff --git a/app/views/dossiers/etapes/etape_2/_individual.html.haml b/app/views/dossiers/etapes/etape_2/_individual.html.haml index 6807a0daa..96d7b1246 100644 --- a/app/views/dossiers/etapes/etape_2/_individual.html.haml +++ b/app/views/dossiers/etapes/etape_2/_individual.html.haml @@ -17,7 +17,7 @@ %label %h4 Civilité - = ff.select :gender, ['Monsieur', 'Madame'] + = ff.select :gender, ['Mr', 'Mme'] .form-group %label %h4