From b535f7ce3b348071f0e59bf27a8df18911bba0b4 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 18:18:07 +0200 Subject: [PATCH 01/11] Fix the colors in the satisfaction graph I forgot to change it after I switched to an enum in the previous PR and changed the values order --- app/views/stats/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/stats/index.html.haml b/app/views/stats/index.html.haml index 666c3033c..27d5e1b75 100644 --- a/app/views/stats/index.html.haml +++ b/app/views/stats/index.html.haml @@ -22,7 +22,7 @@ .chart-container .chart = line_chart @satisfaction_usagers, - colors: ["#F28900", "rgba(161, 0, 5, 0.9)", "#15AD70"] + colors: ["#15AD70", "#F28900", "rgba(161, 0, 5, 0.9)"] .stat-card.stat-card-half.pull-left %span.stat-card-title From 4c7f9af73dbc1c9323e66aa27cb359b75624e541 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 18:18:26 +0200 Subject: [PATCH 02/11] Order the legend in the same order as the enum --- app/controllers/stats_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index c24489b83..b9e4adacc 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -89,9 +89,9 @@ class StatsController < ApplicationController def satisfaction_usagers legend = { - Feedback.ratings.fetch(:unhappy) => "Mécontents", + Feedback.ratings.fetch(:happy) => "Satisfaits", Feedback.ratings.fetch(:neutral) => "Neutres", - Feedback.ratings.fetch(:happy) => "Satisfaits" + Feedback.ratings.fetch(:unhappy) => "Mécontents" } totals = Feedback.where(created_at: 5.weeks.ago..Time.now).group_by_week(:created_at).count From e96b6c449836c58b77b86bf20c6565325b9698fe Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 16:53:51 +0200 Subject: [PATCH 03/11] Remove now useless tasks --- lib/tasks/dev.rake | 52 ---------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 5c0bf8746..d14c6782b 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -1,56 +1,4 @@ namespace :dev do - desc 'Initialise dev environment' - task :init do - puts 'start initialisation' - Rake::Task['dev:generate_franceconnect_file'].invoke - Rake::Task['dev:generate_fog_credentials_file'].invoke - Rake::Task['dev:generate_features_file'].invoke - - puts 'end initialisation' - end - - task :generate_franceconnect_file do - file = File.new('config/france_connect.yml', 'w+') - comment = <<~EOF - particulier_identifier: plop - particulier_secret: plip - - particulier_redirect_uri: 'http://localhost:3000/france_connect/particulier/callback' - - particulier_authorization_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize' - particulier_token_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/token' - particulier_userinfo_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/userinfo' - particulier_logout_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/logout' - EOF - file.write(comment) - file.close - end - - task :generate_fog_credentials_file do - puts 'creating fog_credentials.test.yml file' - content = <<~EOF - default: - openstack_tenant: "ovh_fake_tenant_name" - openstack_api_key: "ovh_fake_password" - openstack_username: "ovh_fake_username" - openstack_auth_url: "https://auth.cloud.ovh.net/v2.0/tokens" - openstack_region: "SBG1" - EOF - file = File.new("config/fog_credentials.test.yml", "w+") - file.write(content) - file.close - end - - task :generate_features_file do - puts 'creating features.yml file' - content = <<~EOF - remote_storage: true - EOF - file = File.new("config/initializers/features.yml", "w+") - file.write(content) - file.close - end - def run_and_stop_if_error(cmd) sh cmd do |ok, res| if !ok From 9f3650b12fab63d4f4c7d0d3cdffcf42869b160e Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 22:24:07 +0200 Subject: [PATCH 04/11] Remove 2 months old call for suggestions --- app/views/new_user/dossiers/index.html.haml | 8 -------- spec/features/new_user/list_dossiers_spec.rb | 5 ----- 2 files changed, 13 deletions(-) diff --git a/app/views/new_user/dossiers/index.html.haml b/app/views/new_user/dossiers/index.html.haml index aecf834f0..e878a79fb 100644 --- a/app/views/new_user/dossiers/index.html.haml +++ b/app/views/new_user/dossiers/index.html.haml @@ -18,14 +18,6 @@ .container - if @dossiers.present? - - if @dossiers.total_pages >= 2 - .card.feedback - .card-title Nous avons redesigné la liste des dossiers. - %p - Une suggestion pour améliorer cette page ? Votre avis nous intéresse ! Écrivez-nous à - = mail_to CONTACT_EMAIL, CONTACT_EMAIL, subject: "Amélioration de la liste des dossiers" - \. - %table.table.dossiers-table.hoverable %thead %tr diff --git a/spec/features/new_user/list_dossiers_spec.rb b/spec/features/new_user/list_dossiers_spec.rb index 95e140763..a179581a0 100644 --- a/spec/features/new_user/list_dossiers_spec.rb +++ b/spec/features/new_user/list_dossiers_spec.rb @@ -59,11 +59,6 @@ describe 'user access to the list of his dossier' do page.click_link("Suivant") expect(page).to have_content(dossier_archived.procedure.libelle) end - - scenario 'the user sees a card asking for feedback' do - expect(page).to have_css('.card.feedback') - expect(page).to have_content(CONTACT_EMAIL) - end end describe "recherche" do From 66c5f080cc843a2f52e0858d8273d684e6e9dabb Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 17:14:58 +0200 Subject: [PATCH 05/11] Add AR validation for Feedback rating --- app/models/feedback.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/feedback.rb b/app/models/feedback.rb index d697541d9..a8e174aa1 100644 --- a/app/models/feedback.rb +++ b/app/models/feedback.rb @@ -6,4 +6,6 @@ class Feedback < ApplicationRecord neutral: 'neutral', unhappy: 'unhappy' } + + validates :rating, presence: true end From fc0c54365f84c0903f3cef3937986bb4bfaa6f08 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 13:14:11 +0200 Subject: [PATCH 06/11] Add SQL validation for Feedback rating --- db/migrate/20180827111328_make_feedbacks_rating_not_null.rb | 5 +++++ db/schema.rb | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20180827111328_make_feedbacks_rating_not_null.rb diff --git a/db/migrate/20180827111328_make_feedbacks_rating_not_null.rb b/db/migrate/20180827111328_make_feedbacks_rating_not_null.rb new file mode 100644 index 000000000..5a3d0d818 --- /dev/null +++ b/db/migrate/20180827111328_make_feedbacks_rating_not_null.rb @@ -0,0 +1,5 @@ +class MakeFeedbacksRatingNotNull < ActiveRecord::Migration[5.2] + def change + change_column_null :feedbacks, :rating, false + end +end diff --git a/db/schema.rb b/db/schema.rb index f3ed94862..bee9049cc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_08_27_102828) do +ActiveRecord::Schema.define(version: 2018_08_27_111328) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -323,7 +323,7 @@ ActiveRecord::Schema.define(version: 2018_08_27_102828) do t.integer "mark" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.string "rating" + t.string "rating", null: false t.index ["user_id"], name: "index_feedbacks_on_user_id" end From 5059c12b34a3d46524a28f8a2c3619405372516d Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 13:15:19 +0200 Subject: [PATCH 07/11] Remove the now useless mark column on the feedbacks table --- db/migrate/20180827111451_remove_mark_on_feedbacks.rb | 5 +++++ db/schema.rb | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20180827111451_remove_mark_on_feedbacks.rb diff --git a/db/migrate/20180827111451_remove_mark_on_feedbacks.rb b/db/migrate/20180827111451_remove_mark_on_feedbacks.rb new file mode 100644 index 000000000..8f6a4ec6a --- /dev/null +++ b/db/migrate/20180827111451_remove_mark_on_feedbacks.rb @@ -0,0 +1,5 @@ +class RemoveMarkOnFeedbacks < ActiveRecord::Migration[5.2] + def change + remove_column :feedbacks, :mark + end +end diff --git a/db/schema.rb b/db/schema.rb index bee9049cc..d6c557ed8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_08_27_111328) do +ActiveRecord::Schema.define(version: 2018_08_27_111451) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -320,7 +320,6 @@ ActiveRecord::Schema.define(version: 2018_08_27_111328) do create_table "feedbacks", force: :cascade do |t| t.bigint "user_id" - t.integer "mark" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "rating", null: false From 9284afc6490116564cbe9f036baac60a9c43d934 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 16:12:34 +0200 Subject: [PATCH 08/11] Use a constant for the API Entreprise URL --- app/lib/api_entreprise/api.rb | 6 +----- config/initializers/urls.rb | 2 ++ config/secrets.yml | 2 -- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/lib/api_entreprise/api.rb b/app/lib/api_entreprise/api.rb index e4e53812b..a722c29d7 100644 --- a/app/lib/api_entreprise/api.rb +++ b/app/lib/api_entreprise/api.rb @@ -45,7 +45,7 @@ class ApiEntreprise::API end def self.url(resource_name, siret_or_siren) - [base_url, resource_name, siret_or_siren].join("/") + [API_ENTREPRISE_URL, resource_name, siret_or_siren].join("/") end def self.params(siret_or_siren, procedure_id) @@ -62,8 +62,4 @@ class ApiEntreprise::API def self.token Rails.application.secrets.api_entreprise[:key] end - - def self.base_url - Rails.application.secrets.api_entreprise[:base_url] - end end diff --git a/config/initializers/urls.rb b/config/initializers/urls.rb index 9fa7943ef..27281f6fe 100644 --- a/config/initializers/urls.rb +++ b/config/initializers/urls.rb @@ -1,5 +1,7 @@ API_CARTO_URL = "https://apicarto.sgmap.fr" +API_ENTREPRISE_URL = "https://entreprise.api.gouv.fr/v2" + API_GEO_URL = "https://geo.api.gouv.fr" PIPEDRIVE_API_URL = 'https://api.pipedrive.com/v1' diff --git a/config/secrets.yml b/config/secrets.yml index a8720e014..7a704b25b 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -31,7 +31,6 @@ defaults: &defaults secret_key: <%= ENV['MAILJET_SECRET_KEY'] %> api_entreprise: key: <%= ENV['API_ENTREPRISE_KEY'] %> - base_url: <%= ENV['API_ENTREPRISE_BASE_URL'] %> pipedrive: key: <%= ENV['PIPEDRIVE_KEY'] %> fog: @@ -57,7 +56,6 @@ test: signing_key: aef3153a9829fa4ba10acb02927ac855df6b92795b1ad265d654443c4b14a017 api_entreprise: key: api_entreprise_test_key - base_url: https://entreprise.api.gouv.fr/v2 fog: base_url: https://storage.apientreprise.fr directory: tps_dev From 5085357db9bb2de44ea62db83b29bca621a690ce Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 16:12:57 +0200 Subject: [PATCH 09/11] Improve the formatting of the urls.rb file --- config/initializers/urls.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config/initializers/urls.rb b/config/initializers/urls.rb index 27281f6fe..1c084d8fc 100644 --- a/config/initializers/urls.rb +++ b/config/initializers/urls.rb @@ -1,14 +1,12 @@ +# API URLs API_CARTO_URL = "https://apicarto.sgmap.fr" - API_ENTREPRISE_URL = "https://entreprise.api.gouv.fr/v2" - API_GEO_URL = "https://geo.api.gouv.fr" - PIPEDRIVE_API_URL = 'https://api.pipedrive.com/v1' +# External services URLs DOC_URL = "https://doc.demarches-simplifiees.fr" LISTE_DES_DEMARCHES_URL = [DOC_URL, "listes-des-demarches"].join("/") CGU_URL = [DOC_URL, "cgu"].join("/") MENTIONS_LEGALES_URL = [CGU_URL, "4-mentions-legales"].join("#") - FAQ_URL = "https://faq.demarches-simplifiees.fr" From a005ec61994a19c9a1cd4520bbe8fe8ccefaf309 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 16:47:13 +0200 Subject: [PATCH 10/11] Rename an env var --- config/env.example | 2 +- config/secrets.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/env.example b/config/env.example index adeedfa2b..beccf16ce 100644 --- a/config/env.example +++ b/config/env.example @@ -7,7 +7,7 @@ GITHUB_CLIENT_SECRET="" FC_PARTICULIER_ID="" FC_PARTICULIER_SECRET="" FC_PARTICULIER_REDIRECT_URI="" -FC_PARTICULIER_HOST="" +FC_PARTICULIER_BASE_URL="" API_ENTREPRISE_KEY="" API_ENTREPRISE_BASE_URL="https://entreprise.api.gouv.fr/v2" diff --git a/config/secrets.yml b/config/secrets.yml index 7a704b25b..64505e388 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -19,10 +19,10 @@ defaults: &defaults identifier: <%= ENV['FC_PARTICULIER_ID'] %> secret: <%= ENV['FC_PARTICULIER_SECRET'] %> redirect_uri: <%= ENV['FC_PARTICULIER_REDIRECT_URI'] %> - authorization_endpoint: <%= ENV['FC_PARTICULIER_HOST'] %>/api/v1/authorize - token_endpoint: <%= ENV['FC_PARTICULIER_HOST'] %>/api/v1/token - userinfo_endpoint: <%= ENV['FC_PARTICULIER_HOST'] %>/api/v1/userinfo - logout_endpoint: <%= ENV['FC_PARTICULIER_HOST'] %>/api/v1/logout + authorization_endpoint: <%= ENV['FC_PARTICULIER_BASE_URL'] %>/api/v1/authorize + token_endpoint: <%= ENV['FC_PARTICULIER_BASE_URL'] %>/api/v1/token + userinfo_endpoint: <%= ENV['FC_PARTICULIER_BASE_URL'] %>/api/v1/userinfo + logout_endpoint: <%= ENV['FC_PARTICULIER_BASE_URL'] %>/api/v1/logout github: client_id: <%= ENV['GITHUB_CLIENT_ID'] %> client_secret: <%= ENV['GITHUB_CLIENT_SECRET'] %> From 437da7a4ae92f08f805d80dac56ffe924f8d006a Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 16:52:42 +0200 Subject: [PATCH 11/11] Remove a now useless env var --- config/env.example | 1 - config/secrets.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/config/env.example b/config/env.example index beccf16ce..fe6b8be02 100644 --- a/config/env.example +++ b/config/env.example @@ -6,7 +6,6 @@ GITHUB_CLIENT_SECRET="" FC_PARTICULIER_ID="" FC_PARTICULIER_SECRET="" -FC_PARTICULIER_REDIRECT_URI="" FC_PARTICULIER_BASE_URL="" API_ENTREPRISE_KEY="" diff --git a/config/secrets.yml b/config/secrets.yml index 64505e388..24c0c5f34 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -18,7 +18,7 @@ defaults: &defaults france_connect_particulier: identifier: <%= ENV['FC_PARTICULIER_ID'] %> secret: <%= ENV['FC_PARTICULIER_SECRET'] %> - redirect_uri: <%= ENV['FC_PARTICULIER_REDIRECT_URI'] %> + redirect_uri: https://{{ <%= ENV['APP_HOST'] %> }}/france_connect/particulier/callback authorization_endpoint: <%= ENV['FC_PARTICULIER_BASE_URL'] %>/api/v1/authorize token_endpoint: <%= ENV['FC_PARTICULIER_BASE_URL'] %>/api/v1/token userinfo_endpoint: <%= ENV['FC_PARTICULIER_BASE_URL'] %>/api/v1/userinfo