From 3f0e61d2924a8a5d6e91f5dec985efbefd3c330e Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 11:34:16 +0200 Subject: [PATCH 1/8] Remove from .gitignore a line that should be in a global .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index f01467f0c..ac9f9c928 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ public/uploads public/downloads doc/*.svg uploads/* -.DS_Store .byebug_history .env Procfile.dev From 15d1b01a90e6f312dfe2e257ed34d5926849c0c1 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 22:34:01 +0200 Subject: [PATCH 2/8] Code simplification --- app/controllers/stats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 51c011012..7b7dacdc6 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -198,7 +198,7 @@ class StatsController < ApplicationController count_per_administrateur = procedures.group(:administrateur_id).count.values { 'Une procédure' => count_per_administrateur.select { |count| count == 1 }.count, - 'Entre deux et cinq procédures' => count_per_administrateur.select { |count| 2 <= count && count <= 5 }.count, + 'Entre deux et cinq procédures' => count_per_administrateur.select { |count| count.in?(2..5) }.count, 'Plus de cinq procédures' => count_per_administrateur.select { |count| 5 < count }.count } end From de48dab0310fd07a7c6015f29e820cefb1d7752f Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 11:52:15 +0200 Subject: [PATCH 3/8] Alignment --- app/controllers/root_controller.rb | 6 +++--- app/helpers/type_de_champ_helper.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 4c8a50539..54499e156 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -42,9 +42,9 @@ class RootController < ApplicationController end type_champ_values = { - TypeDeChamp.type_champs.fetch(:date) => '2016-07-26', - TypeDeChamp.type_champs.fetch(:datetime) => '26/07/2016 07:35', - TypeDeChamp.type_champs.fetch(:textarea) => 'Une description de mon projet' + TypeDeChamp.type_champs.fetch(:date) => '2016-07-26', + TypeDeChamp.type_champs.fetch(:datetime) => '26/07/2016 07:35', + TypeDeChamp.type_champs.fetch(:textarea) => 'Une description de mon projet' } type_champ_values.each do |(type_champ, value)| diff --git a/app/helpers/type_de_champ_helper.rb b/app/helpers/type_de_champ_helper.rb index 4d2ad46d9..f569382dd 100644 --- a/app/helpers/type_de_champ_helper.rb +++ b/app/helpers/type_de_champ_helper.rb @@ -1,7 +1,7 @@ module TypeDeChampHelper TOGGLES = { - TypeDeChamp.type_champs.fetch(:piece_justificative) => :champ_pj?, - TypeDeChamp.type_champs.fetch(:siret) => :champ_siret?, + TypeDeChamp.type_champs.fetch(:piece_justificative) => :champ_pj?, + TypeDeChamp.type_champs.fetch(:siret) => :champ_siret?, TypeDeChamp.type_champs.fetch(:linked_drop_down_list) => :champ_linked_dropdown? } From bf9f3b40df023d085554bf933083e20e4c822b91 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 11:56:51 +0200 Subject: [PATCH 4/8] Remove useless `.to_s` --- app/controllers/root_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 54499e156..f7e802545 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -49,7 +49,7 @@ class RootController < ApplicationController type_champ_values.each do |(type_champ, value)| all_champs - .select { |champ| champ.type_champ == type_champ.to_s } + .select { |champ| champ.type_champ == type_champ } .each { |champ| champ.value = value } end From 47962ef795db7e63f8fa80ec2d6a4e3c9dd4a431 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 14:12:48 +0200 Subject: [PATCH 5/8] Simplify route_authorization --- app/controllers/users/carte_controller.rb | 2 +- app/controllers/users/dossiers_controller.rb | 2 +- app/controllers/users/recapitulatif_controller.rb | 8 +++++++- app/services/user_routes_authorization_service.rb | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index 258299254..032883703 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -59,7 +59,7 @@ class Users::CarteController < UsersController def self.route_authorization { - states: [:brouillon, :en_construction], + states: [Dossier.states.fetch(:brouillon), Dossier.states.fetch(:en_construction)], api_carto: true } end diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index e62ef80b0..28d85cf8f 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -149,7 +149,7 @@ class Users::DossiersController < UsersController def self.route_authorization { - states: [:brouillon] + states: [Dossier.states.fetch(:brouillon)] } end diff --git a/app/controllers/users/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb index b8b7fb03a..d0657b72e 100644 --- a/app/controllers/users/recapitulatif_controller.rb +++ b/app/controllers/users/recapitulatif_controller.rb @@ -18,7 +18,13 @@ class Users::RecapitulatifController < UsersController def self.route_authorization { - states: [:en_construction, :en_instruction, :sans_suite, :accepte, :refuse] + states: [ + Dossier.states.fetch(:en_construction), + Dossier.states.fetch(:en_instruction), + Dossier.states.fetch(:sans_suite), + Dossier.states.fetch(:accepte), + Dossier.states.fetch(:refuse) + ] } end diff --git a/app/services/user_routes_authorization_service.rb b/app/services/user_routes_authorization_service.rb index a60c5b415..9fc85c97b 100644 --- a/app/services/user_routes_authorization_service.rb +++ b/app/services/user_routes_authorization_service.rb @@ -2,7 +2,7 @@ class UserRoutesAuthorizationService def self.authorized_route?(controller, dossier) auth = controller.route_authorization - auth[:states].include?(dossier.state.to_sym) && + auth[:states].include?(dossier.state) && (auth[:api_carto].nil? ? true : auth[:api_carto] == dossier.procedure.use_api_carto) end end From e60aa0c37b4ee1f93fa89daf0b7739dc32c6cfc9 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 14:50:44 +0200 Subject: [PATCH 6/8] Use scopes when possible --- app/controllers/stats_controller.rb | 2 +- app/views/root/administration.html.haml | 2 +- app/views/root/landing.html.haml | 2 +- spec/controllers/stats_controller_spec.rb | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 7b7dacdc6..c37ec9bad 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -7,7 +7,7 @@ class StatsController < ApplicationController def index procedures = Procedure.publiees_ou_archivees - dossiers = Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) + dossiers = Dossier.state_not_brouillon @procedures_numbers = procedures_numbers(procedures) @dossiers_numbers = dossiers_numbers(dossiers) diff --git a/app/views/root/administration.html.haml b/app/views/root/administration.html.haml index 63e28002f..bae00f101 100644 --- a/app/views/root/administration.html.haml +++ b/app/views/root/administration.html.haml @@ -124,7 +124,7 @@ partenaires %li.number .number-value - = number_with_delimiter(Dossier.where.not(:state => Dossier.states.fetch(:brouillon)).count, :locale => :fr) + = number_with_delimiter(Dossier.state_not_brouillon.count, :locale => :fr) .number-label< dossiers %br<> diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index 35e367765..c912c1bfa 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -50,7 +50,7 @@ partenaires %li.number .number-value - = number_with_delimiter(Dossier.where.not(:state => Dossier.states.fetch(:brouillon)).count, :locale => :fr) + = number_with_delimiter(Dossier.state_not_brouillon.count, :locale => :fr) .number-label< dossiers %br<> diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index 93e8c8f50..f4ff56dcb 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -170,7 +170,7 @@ describe StatsController, type: :controller do } end - let (:association) { Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) } + let (:association) { Dossier.state_not_brouillon } subject { StatsController.new.send(:dossier_instruction_mean_time, association) } @@ -222,7 +222,7 @@ describe StatsController, type: :controller do } end - let (:association) { Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) } + let (:association) { Dossier.state_not_brouillon } subject { StatsController.new.send(:dossier_filling_mean_time, association) } From 89af9c2b36c89cd666216a12196f0e2dd3ac9ad7 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 29 Aug 2018 15:08:26 +0200 Subject: [PATCH 7/8] Remove extra blank lines --- app/assets/stylesheets/new_design/stats.scss | 1 - app/views/new_gestionnaire/avis/show.html.haml | 1 - app/views/shared/champs/siret/_delete_etablissement.html.haml | 1 - 3 files changed, 3 deletions(-) diff --git a/app/assets/stylesheets/new_design/stats.scss b/app/assets/stylesheets/new_design/stats.scss index adea45065..c77d6ba36 100644 --- a/app/assets/stylesheets/new_design/stats.scss +++ b/app/assets/stylesheets/new_design/stats.scss @@ -144,4 +144,3 @@ $big-number-card-padding: 2 * $segmented-control-item-border-radius; text-align: center; color: $blue; } - diff --git a/app/views/new_gestionnaire/avis/show.html.haml b/app/views/new_gestionnaire/avis/show.html.haml index 6a0e2e9d8..d008c0536 100644 --- a/app/views/new_gestionnaire/avis/show.html.haml +++ b/app/views/new_gestionnaire/avis/show.html.haml @@ -3,4 +3,3 @@ = render partial: 'header', locals: { avis: @avis, dossier: @dossier } = render partial: 'shared/dossiers/show', locals: { dossier: @dossier, demande_seen_at: nil } - diff --git a/app/views/shared/champs/siret/_delete_etablissement.html.haml b/app/views/shared/champs/siret/_delete_etablissement.html.haml index 1c4a888fb..1d443c0d2 100644 --- a/app/views/shared/champs/siret/_delete_etablissement.html.haml +++ b/app/views/shared/champs/siret/_delete_etablissement.html.haml @@ -3,4 +3,3 @@ - champ_attributes = etablissement.champ.private? ? 'champs_private_attributes' : 'champs_attributes' = fields_for "dossier[#{champ_attributes}][#{position}][etablissement_attributes]", etablissement do |form| = form.hidden_field :_destroy - From 04c6a653da654374bb3ebb19f55a10e55d83c103 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 29 Aug 2018 16:27:57 +0200 Subject: [PATCH 8/8] =?UTF-8?q?Unify=20the=20CSS=20filenames=E2=80=99=20ca?= =?UTF-8?q?se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../new_design/{procedure-logo.scss => procedure_logo.scss} | 0 .../stylesheets/new_design/{rich-text.scss => rich_text.scss} | 0 .../new_design/{services-index.scss => services_index.scss} | 0 .../new_design/{table-service.scss => table_service.scss} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename app/assets/stylesheets/new_design/{procedure-logo.scss => procedure_logo.scss} (100%) rename app/assets/stylesheets/new_design/{rich-text.scss => rich_text.scss} (100%) rename app/assets/stylesheets/new_design/{services-index.scss => services_index.scss} (100%) rename app/assets/stylesheets/new_design/{table-service.scss => table_service.scss} (100%) diff --git a/app/assets/stylesheets/new_design/procedure-logo.scss b/app/assets/stylesheets/new_design/procedure_logo.scss similarity index 100% rename from app/assets/stylesheets/new_design/procedure-logo.scss rename to app/assets/stylesheets/new_design/procedure_logo.scss diff --git a/app/assets/stylesheets/new_design/rich-text.scss b/app/assets/stylesheets/new_design/rich_text.scss similarity index 100% rename from app/assets/stylesheets/new_design/rich-text.scss rename to app/assets/stylesheets/new_design/rich_text.scss diff --git a/app/assets/stylesheets/new_design/services-index.scss b/app/assets/stylesheets/new_design/services_index.scss similarity index 100% rename from app/assets/stylesheets/new_design/services-index.scss rename to app/assets/stylesheets/new_design/services_index.scss diff --git a/app/assets/stylesheets/new_design/table-service.scss b/app/assets/stylesheets/new_design/table_service.scss similarity index 100% rename from app/assets/stylesheets/new_design/table-service.scss rename to app/assets/stylesheets/new_design/table_service.scss