From 19789b6848e32e64a0625548ba1dd64909ab8387 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 15:17:23 +0200 Subject: [PATCH 1/5] Remove the stats part of the procedure info page for admins - the numbers are wrong (:termine state does not exist) - the chart does not work --- app/facades/admin_procedures_show_facades.rb | 25 -------------- app/views/admin/procedures/show.html.haml | 34 ------------------- config/locales/dynamics/fr.yml | 2 -- .../admin_procedures_show_facades_spec.rb | 33 ------------------ 4 files changed, 94 deletions(-) diff --git a/app/facades/admin_procedures_show_facades.rb b/app/facades/admin_procedures_show_facades.rb index 34dbd2d3e..96aa59704 100644 --- a/app/facades/admin_procedures_show_facades.rb +++ b/app/facades/admin_procedures_show_facades.rb @@ -10,29 +10,4 @@ class AdminProceduresShowFacades def dossiers @procedure.dossiers.state_not_brouillon end - - def dossiers_for_pie_highchart - dossiers.state_not_brouillon.not_archived.group(:state).count - .reduce({}) do |acc, (key, val)| - translated_key = DossierDecorator.case_state_fr(key) - acc[translated_key].nil? ? acc[translated_key] = val : acc[translated_key] += val - acc - end - end - - def dossiers_archived_by_state_total - dossiers.select('state, count(*) as total').archived.where.not(state: :termine).group(:state).order(:state).decorate - end - - def dossiers_archived_total - dossiers.archived.where.not(state: :termine).size - end - - def dossiers_total - dossiers.size - end - - def dossiers_termine_total - dossiers.where(state: :termine).size - end end diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index 471bd5efa..eb1a330ba 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -106,40 +106,6 @@ - durees_de_conservation.each do |text| %p= text - %br - %h3 - = t('dynamics.admin.procedure.stats.title') - - .row - .col-xs-6{ style: 'margin-left: 3%;' } - %h4 Total - %div - = @facade.dossiers_total - - %h4.text-success Terminé - %div - = @facade.dossiers_termine_total - - %h4 Archivé - - - if @facade.dossiers_archived_total != 0 - %ul - - @facade.dossiers_archived_by_state_total.each do |dossier| - %li - = dossier.display_state - \: - = dossier.total - - else - %p - 0 - - .col-xs-5 - %h4 Non archivés - - if @facade.dossiers_for_pie_highchart.blank? - Aucune statistique pour le moment - - else - = pie_chart @facade.dossiers_for_pie_highchart - - if procedure.publiee_ou_archivee? %h3 Supprimer la procédure .alert.alert-danger diff --git a/config/locales/dynamics/fr.yml b/config/locales/dynamics/fr.yml index b725f6cf8..782381f27 100644 --- a/config/locales/dynamics/fr.yml +++ b/config/locales/dynamics/fr.yml @@ -24,8 +24,6 @@ fr: procedure: onglets: accompagnateurs: Accompagnateurs - stats: - title: Dossiers onglet_accompagnateurs: add: title: 'Ajouter un accompagnateur' diff --git a/spec/facades/admin_procedures_show_facades_spec.rb b/spec/facades/admin_procedures_show_facades_spec.rb index 502f137bc..3b4fadbbf 100644 --- a/spec/facades/admin_procedures_show_facades_spec.rb +++ b/spec/facades/admin_procedures_show_facades_spec.rb @@ -21,37 +21,4 @@ describe AdminProceduresShowFacades do it { expect(subject.size).to eq(3) } end - - describe '#dossiers_for_pie_highchart' do - subject { super().dossiers_for_pie_highchart } - - it { expect(subject).to eq({ 'En construction' => 2 }) } - end - - describe '#dossiers_archived_by_state_total' do - subject { super().dossiers_archived_by_state_total } - - it { expect(subject.size).to eq(1) } - - it { expect(subject.first.state).to eq('en_construction') } - it { expect(subject.first.total).to eq(1) } - end - - describe '#dossiers_archived_total' do - subject { super().dossiers_archived_total } - - it { is_expected.to eq(1) } - end - - describe '#dossiers_total' do - subject { super().dossiers_total } - - it { is_expected.to eq(3) } - end - - describe '#dossiers_termine_total' do - subject { super().dossiers_termine_total } - - it { is_expected.to eq(0) } - end end From cccad7dbdfce8723c9ed8afeac422f847ec14635 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 15:17:50 +0200 Subject: [PATCH 2/5] Remove a now useless method --- app/facades/admin_procedures_show_facades.rb | 4 ---- spec/facades/admin_procedures_show_facades_spec.rb | 6 ------ 2 files changed, 10 deletions(-) diff --git a/app/facades/admin_procedures_show_facades.rb b/app/facades/admin_procedures_show_facades.rb index 96aa59704..acbd9f9e3 100644 --- a/app/facades/admin_procedures_show_facades.rb +++ b/app/facades/admin_procedures_show_facades.rb @@ -6,8 +6,4 @@ class AdminProceduresShowFacades def procedure @procedure end - - def dossiers - @procedure.dossiers.state_not_brouillon - end end diff --git a/spec/facades/admin_procedures_show_facades_spec.rb b/spec/facades/admin_procedures_show_facades_spec.rb index 3b4fadbbf..91f4b63d7 100644 --- a/spec/facades/admin_procedures_show_facades_spec.rb +++ b/spec/facades/admin_procedures_show_facades_spec.rb @@ -15,10 +15,4 @@ describe AdminProceduresShowFacades do it { is_expected.to eq(procedure) } end - - describe '#dossiers' do - subject { super().dossiers } - - it { expect(subject.size).to eq(3) } - end end From 6b1ab9b55219195475749eb60fb8e146b0109491 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 15:23:45 +0200 Subject: [PATCH 3/5] Remove a now useless facade --- .../admin/procedures_controller.rb | 1 - app/facades/admin_procedures_show_facades.rb | 9 ---- app/views/admin/procedures/show.html.haml | 48 +++++++++---------- .../admin_procedures_show_facades_spec.rb | 18 ------- .../admin/procedures/show.html.haml_spec.rb | 1 - 5 files changed, 23 insertions(+), 54 deletions(-) delete mode 100644 app/facades/admin_procedures_show_facades.rb delete mode 100644 spec/facades/admin_procedures_show_facades_spec.rb diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index df2f7d3a7..ef68211f0 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -36,7 +36,6 @@ class Admin::ProceduresController < AdminController end def show - @facade = AdminProceduresShowFacades.new @procedure.decorate end def edit diff --git a/app/facades/admin_procedures_show_facades.rb b/app/facades/admin_procedures_show_facades.rb deleted file mode 100644 index acbd9f9e3..000000000 --- a/app/facades/admin_procedures_show_facades.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AdminProceduresShowFacades - def initialize(procedure) - @procedure = procedure - end - - def procedure - @procedure - end -end diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index eb1a330ba..a77693c21 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -1,17 +1,15 @@ -- procedure = @facade.procedure - = render partial: 'admin/closed_mail_template_attestation_inconsistency_alert' .row.white-back #procedure_show = render partial: '/admin/procedures/modal_publish' = render partial: '/admin/procedures/modal_transfer' - - if procedure.brouillon? - - if procedure.gestionnaires.empty? || procedure.service.nil? + - if @procedure.brouillon? + - if @procedure.gestionnaires.empty? || @procedure.service.nil? - missing_elements = [] - - if procedure.gestionnaires.empty? + - if @procedure.gestionnaires.empty? - missing_elements << 'des accompagnateurs' - - if procedure.service.nil? + - if @procedure.service.nil? - missing_elements << 'un service' - message = "Affectez #{missing_elements.join(' et ')} à votre procédure." %a.action_button.btn.btn-success#disabled-publish-procedure{ data: { toggle: :tooltip, placement: :bottom }, style: 'float: right; margin-top: 10px;', disabled: true, title: message } @@ -26,13 +24,13 @@ %i.fa.fa-exchange Envoyer une copie - - if procedure.archivee? + - if @procedure.archivee? %a.btn.btn-default#reopen-procedure{ data: { target: '#publish-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px; margin-right: 10px;' } %i.fa.fa-rocket Réactiver - - elsif procedure.publiee? - = form_tag admin_procedure_archive_path(procedure_id: procedure.id), method: :put, style: 'float: right; margin-top: 10px;' do + - elsif @procedure.publiee? + = form_tag admin_procedure_archive_path(procedure_id: @procedure.id), method: :put, style: 'float: right; margin-top: 10px;' do %button#archive-procedure.btn.btn-small.btn-default.text-info{ type: :button } %i.fa.fa-eraser Archiver @@ -44,7 +42,7 @@ %i.fa.fa-remove Annuler - - if procedure.locked? + - if @procedure.locked? #procedure_locked .alert.alert-info Cette procédure a été publiée, certains éléments ne peuvent plus être modifiés. @@ -52,11 +50,11 @@ %div %h3 Lien procédure %div{ style: 'margin-left: 3%;' } - - if procedure.archivee? + - if @procedure.archivee? %b Cette procédure est archivée et n’est donc pas accessible par le public. - - elsif procedure.brouillon_avec_lien? || procedure.publiee? - = link_to procedure_lien(procedure), sanitize_url(procedure_lien(procedure)), target: :blank + - elsif @procedure.brouillon_avec_lien? || @procedure.publiee? + = link_to procedure_lien(@procedure), sanitize_url(procedure_lien(@procedure)), target: :blank - else %b Cette procédure n’a pas encore de lien, et n’est donc pas accessible par le public. @@ -67,38 +65,38 @@ .row{ style: 'margin-right: 3%; margin-left: 3%;' } .description.col-xs-6.col-md-3.procedure-description %h4.text-info - = procedure.libelle + = @procedure.libelle - = h string_to_html(procedure.description) + = h string_to_html(@procedure.description) .champs.col-xs-6.col-md-3 %h4.text-info Champs .badge.progress-bar-info - = procedure.types_de_champ.size + = @procedure.types_de_champ.size %ul - - procedure.types_de_champ.order(:order_place).each do |champ| + - @procedure.types_de_champ.order(:order_place).each do |champ| %li= champ.libelle .champs_private.col-xs-6.col-md-3 %h4.text-info Annotations privées .badge.progress-bar-info - = procedure.types_de_champ_private.size + = @procedure.types_de_champ_private.size %ul - - procedure.types_de_champ_private.order(:order_place).each do |champ| + - @procedure.types_de_champ_private.order(:order_place).each do |champ| %li= champ.libelle .pieces-justificatives.col-xs-6.col-md-3 %h4.text-info Pièces jointes .badge.progress-bar-info - = procedure.types_de_piece_justificative.size - - procedure.types_de_piece_justificative.each do |piece_justificative| + = @procedure.types_de_piece_justificative.size + - @procedure.types_de_piece_justificative.each do |piece_justificative| = piece_justificative.libelle %br - - durees_de_conservation = politiques_conservation_de_donnees(procedure) + - durees_de_conservation = politiques_conservation_de_donnees(@procedure) - if durees_de_conservation.present? .row{ style: 'margin-right: 3%; margin-left: 3%;' } .col-xs-6.col-md-3 @@ -106,19 +104,19 @@ - durees_de_conservation.each do |text| %p= text - - if procedure.publiee_ou_archivee? + - if @procedure.publiee_ou_archivee? %h3 Supprimer la procédure .alert.alert-danger %p Attention : la suppression d’une procédure est définitive. - - dossiers_count = procedure.dossiers.count + - dossiers_count = @procedure.dossiers.count - if dossiers_count > 0 %p = pluralize(dossiers_count, "dossier est rattaché", "dossiers sont rattachés") à cette procédure, la suppression de cette procédure entrainera également leur suppression. %p.text-right = link_to "J'ai compris, je supprime la procédure", - hide_admin_procedure_path(procedure), + hide_admin_procedure_path(@procedure), method: :post, class: "btn btn-danger", data: { confirm: "Voulez-vous supprimer la procédure ?", disable: true } diff --git a/spec/facades/admin_procedures_show_facades_spec.rb b/spec/facades/admin_procedures_show_facades_spec.rb deleted file mode 100644 index 91f4b63d7..000000000 --- a/spec/facades/admin_procedures_show_facades_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe AdminProceduresShowFacades do - let!(:procedure) { create(:procedure) } - - let!(:dossier_0) { create(:dossier, procedure: procedure, state: 'brouillon') } - let!(:dossier_1) { create(:dossier, procedure: procedure, state: 'en_construction') } - let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'en_construction') } - let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'en_construction') } - - subject { AdminProceduresShowFacades.new procedure } - - describe '#procedure' do - subject { super().procedure } - - it { is_expected.to eq(procedure) } - end -end diff --git a/spec/views/admin/procedures/show.html.haml_spec.rb b/spec/views/admin/procedures/show.html.haml_spec.rb index 241f53f49..18762a41c 100644 --- a/spec/views/admin/procedures/show.html.haml_spec.rb +++ b/spec/views/admin/procedures/show.html.haml_spec.rb @@ -5,7 +5,6 @@ describe 'admin/procedures/show.html.haml', type: :view do let(:procedure) { create(:procedure, :with_service, archived_at: archived_at) } before do - assign(:facade, AdminProceduresShowFacades.new(procedure.decorate)) assign(:procedure, procedure) end From 70d5f1deac04b6cb46c517b290e0977833048971 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 29 Aug 2018 10:01:13 +0100 Subject: [PATCH 4/5] Fix France Connect --- config/env.example | 2 +- config/secrets.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/env.example b/config/env.example index fe6b8be02..9d46cc0d7 100644 --- a/config/env.example +++ b/config/env.example @@ -1,5 +1,5 @@ APP_NAME="tps_local" -APP_HOST="http://localhost:3000/" +APP_HOST="localhost:3000" GITHUB_CLIENT_ID="" GITHUB_CLIENT_SECRET="" diff --git a/config/secrets.yml b/config/secrets.yml index 24c0c5f34..9678196ce 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: https://{{ <%= ENV['APP_HOST'] %> }}/france_connect/particulier/callback + 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 From 5dcc74fcbe165790910334a48a07ab2a509111f1 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 23 Aug 2018 15:00:21 +0200 Subject: [PATCH 5/5] Stop using staging environement --- config/cable.yml | 4 -- config/database.yml | 4 -- config/deploy.rb | 2 +- config/environments/staging.rb | 110 --------------------------------- config/secrets.yml | 4 -- config/webpacker.yml | 9 --- 6 files changed, 1 insertion(+), 132 deletions(-) delete mode 100644 config/environments/staging.rb diff --git a/config/cable.yml b/config/cable.yml index 33e584883..1aeb76f7c 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -2,10 +2,6 @@ production: adapter: redis url: redis://localhost:6379 -staging: - adapter: redis - url: redis://localhost:6379 - development: adapter: redis url: redis://localhost:6379 diff --git a/config/database.yml b/config/database.yml index 37d319404..cd1f7fcf8 100644 --- a/config/database.yml +++ b/config/database.yml @@ -24,7 +24,3 @@ production: &production host: <%= ENV["DB_HOST"] %> username: <%= ENV["DB_USERNAME"] %> password: <%= ENV["DB_PASSWORD"] %> - -# Alias for production -staging: - <<: *production diff --git a/config/deploy.rb b/config/deploy.rb index 2aa98afd8..08489b8d8 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -37,7 +37,7 @@ end print "Deploy to #{ENV['to']} environment branch #{branch}\n" -set :rails_env, ENV["to"] +set :rails_env, 'production' # For system-wide RVM install. # set :rvm_path, '/usr/local/rvm/bin/rvm' diff --git a/config/environments/staging.rb b/config/environments/staging.rb deleted file mode 100644 index 4bcbef198..000000000 --- a/config/environments/staging.rb +++ /dev/null @@ -1,110 +0,0 @@ -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # Verifies that versions and hashed value of the package contents in the project's package.json - config.webpacker.check_yarn_integrity = false - - # Code is not reloaded between requests. - config.cache_classes = true - - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true - - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true - - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? - - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier - # config.assets.css_compressor = :sass - - # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false - - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb - - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - config.force_ssl = true - - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug - - # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - - # Use a different cache store in production. - # config.cache_store = :memory_store - - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false - - if ENV['MAILTRAP_ENABLED'] == 'enabled' - config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { - user_name: Rails.application.secrets.mailtrap[:username], - password: Rails.application.secrets.mailtrap[:password], - address: 'smtp.mailtrap.io', - domain: 'smtp.mailtrap.io', - port: '2525', - authentication: :cram_md5 - } - else - config.action_mailer.delivery_method = :mailjet - end - - config.action_mailer.default_url_options = { - protocol: :https, - host: ENV['APP_HOST'] - } - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true - - config.active_storage.service = :clever_cloud - - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - - # Do not dump schema after migrations. - config.active_record.dump_schema_after_migration = false - - Rails.application.routes.default_url_options = { - protocol: :https, - host: ENV['APP_HOST'] - } - - config.lograge.enabled = ENV['LOGRAGE_ENABLED'] == 'enabled' -end diff --git a/config/secrets.yml b/config/secrets.yml index 9678196ce..895c3a8a7 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -74,7 +74,3 @@ test: # instead read values from the environment. production: &production <<: *defaults - -# Alias for production -staging: - <<: *production diff --git a/config/webpacker.yml b/config/webpacker.yml index a44ac42bf..6da493bcb 100644 --- a/config/webpacker.yml +++ b/config/webpacker.yml @@ -58,15 +58,6 @@ test: # Compile test packs to a separate directory public_output_path: packs-test -staging: - <<: *default - - # Production depends on precompilation of packs prior to booting for performance. - compile: false - - # Cache manifest.json for performance - cache_manifest: true - production: <<: *default