From b8f71bd52cc9d0e52a196723d6db92eaa6d571c8 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 6 May 2021 12:27:34 +0200 Subject: [PATCH 1/5] i18n: fix enum values for Dossier.state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to Rails i18n guide, enum values should be localized as `/`, not as sub-values to the attribute. This fixes an exception in administrate when displaying a Dossier in the Manager. Note: we need to change the way GraphQL attributes are generated, because `AASM::Core::State#display_name` doesn’t honor the `model/attribute.value` convention (and instead tries to localize as `model.attribute/value`). So instead we lookup the localized name using ActiveRecord. --- app/graphql/schema.graphql | 2 +- app/graphql/types/dossier_type.rb | 2 +- app/helpers/dossier_helper.rb | 2 +- config/locales/models/dossier/fr.yml | 26 +++++++++++--------------- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index c81a8d142..6e0df05e6 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -1088,7 +1088,7 @@ enum DossierState { refuse """ - Sans suite + Classé sans suite """ sans_suite } diff --git a/app/graphql/types/dossier_type.rb b/app/graphql/types/dossier_type.rb index 57811a75e..3e9ecec5a 100644 --- a/app/graphql/types/dossier_type.rb +++ b/app/graphql/types/dossier_type.rb @@ -2,7 +2,7 @@ module Types class DossierType < Types::BaseObject class DossierState < Types::BaseEnum Dossier.aasm.states.reject { |state| state.name == :brouillon }.each do |state| - value(state.name.to_s, state.display_name, value: state.name.to_s) + value(state.name.to_s, Dossier.human_attribute_name("state.#{state.name}"), value: state.name.to_s) end end diff --git a/app/helpers/dossier_helper.rb b/app/helpers/dossier_helper.rb index 3812af890..6d6b85884 100644 --- a/app/helpers/dossier_helper.rb +++ b/app/helpers/dossier_helper.rb @@ -51,7 +51,7 @@ module DossierHelper def dossier_display_state(dossier_or_state, lower: false) state = dossier_or_state.is_a?(Dossier) ? dossier_or_state.state : dossier_or_state - display_state = I18n.t(state, scope: [:activerecord, :attributes, :dossier, :state]) + display_state = Dossier.human_attribute_name("state.#{state}") lower ? display_state.downcase : display_state end diff --git a/config/locales/models/dossier/fr.yml b/config/locales/models/dossier/fr.yml index d79072067..1fb503dff 100644 --- a/config/locales/models/dossier/fr.yml +++ b/config/locales/models/dossier/fr.yml @@ -9,20 +9,16 @@ fr: montant_projet: 'Le montant du projet' montant_aide_demande: "Le montant d’aide demandée" date_previsionnelle: "La date de début prévisionnelle" - state: &state - brouillon: "Brouillon" - en_construction: "En construction" - en_instruction: "En instruction" - accepte: "Accepté" - refuse: "Refusé" - sans_suite: "Classé sans suite" + state: "État" autorisation_donnees: Acceptation des CGU - state/brouillon: Brouillon - state/en_construction: En construction - state/en_instruction: En instruction - state/accepte: Accepté - state/refuse: Refusé - state/sans_suite: Sans suite + dossier/state: &state + brouillon: "Brouillon" + en_construction: "En construction" + en_instruction: "En instruction" + accepte: "Accepté" + refuse: "Refusé" + sans_suite: "Classé sans suite" traitement: - state: - <<: *state + state: "État" + traitement/state: + <<: *state From b398485d9719268eae2d5ab8b6689e76d5fd667b Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 6 May 2021 10:29:52 +0000 Subject: [PATCH 2/5] manager: localize dossier enums In the previous commit, we cleaned up the localization of the Dossier.state enum. This prevented administrate from crashing, but now the dossier enum are no longer localized in the Manager. By using a `Field::Enum` type, we instruct the administrate plugin to look up our localized name for the Dossier state enum. --- Gemfile | 1 + Gemfile.lock | 3 +++ app/dashboards/dossier_dashboard.rb | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 6c50d0d32..b75222113 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gem 'active_model_serializers' gem 'activestorage-openstack' gem 'active_storage_validations' gem 'administrate', git: 'https://github.com/thoughtbot/administrate.git', ref: 'refs/pull/1972/head' # Provides an administration UI (pull request #1972 has fixes for Rails 6.1.3.2) +gem 'administrate-field-enum' # Allow using Field::Enum in administrate gem 'after_party' gem 'anchored' gem 'bcrypt' diff --git a/Gemfile.lock b/Gemfile.lock index adf2a9b6e..1643c8608 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,6 +102,8 @@ GEM zeitwerk (~> 2.3) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) + administrate-field-enum (0.0.9) + administrate (~> 0.12) aes_key_wrap (1.1.0) after_party (1.11.2) anchored (1.1.0) @@ -776,6 +778,7 @@ DEPENDENCIES active_storage_validations activestorage-openstack administrate! + administrate-field-enum after_party anchored annotate diff --git a/app/dashboards/dossier_dashboard.rb b/app/dashboards/dossier_dashboard.rb index 698106704..6c102b209 100644 --- a/app/dashboards/dossier_dashboard.rb +++ b/app/dashboards/dossier_dashboard.rb @@ -10,7 +10,7 @@ class DossierDashboard < Administrate::BaseDashboard ATTRIBUTE_TYPES = { id: Field::Number.with_options(searchable: true), procedure: Field::HasOne, - state: Field::String, + state: Field::Enum, user: Field::BelongsTo, text_summary: Field::String.with_options(searchable: false), created_at: Field::DateTime, From 77b65f3aa0d9cc0c9125d83aa2d70c892634a62d Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 6 May 2021 07:20:42 +0000 Subject: [PATCH 3/5] tasks: remove older after_party tasks --- ...200326133630_cleanup_deleted_dossiers.rake | 10 --- ...cess_expired_dossiers_en_construction.rake | 27 ------- ...0200527124112_fix_champ_etablissement.rake | 35 --------- ...00528124044_fix_dossier_etablissement.rake | 20 ------ ...121241_drop_down_list_options_to_json.rake | 25 ------- .../20200625113026_migrate_revisions.rake | 22 ------ ...0154829_add_traitements_from_dossiers.rake | 18 ----- ...kip_validation_to_piece_justificative.rake | 18 ----- .../20200728150458_fix_cloned_revisions.rake | 25 ------- ...20200813111957_fix_geo_areas_geometry.rake | 71 ------------------- ...1931_migrate_filters_to_use_stable_id.rake | 50 ------------- .../20201006123842_setup_first_stats.rake | 11 --- ...18163035_fix_types_de_champ_revisions.rake | 19 ----- ...dation_to_piece_justificative.rake_spec.rb | 25 ------- ...1_migrate_filters_to_use_stable_id_spec.rb | 60 ---------------- 15 files changed, 436 deletions(-) delete mode 100644 lib/tasks/deployment/20200326133630_cleanup_deleted_dossiers.rake delete mode 100644 lib/tasks/deployment/20200401123317_process_expired_dossiers_en_construction.rake delete mode 100644 lib/tasks/deployment/20200527124112_fix_champ_etablissement.rake delete mode 100644 lib/tasks/deployment/20200528124044_fix_dossier_etablissement.rake delete mode 100644 lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake delete mode 100644 lib/tasks/deployment/20200625113026_migrate_revisions.rake delete mode 100644 lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake delete mode 100644 lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake delete mode 100644 lib/tasks/deployment/20200728150458_fix_cloned_revisions.rake delete mode 100644 lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake delete mode 100644 lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id.rake delete mode 100644 lib/tasks/deployment/20201006123842_setup_first_stats.rake delete mode 100644 lib/tasks/deployment/20201218163035_fix_types_de_champ_revisions.rake delete mode 100644 spec/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake_spec.rb delete mode 100644 spec/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id_spec.rb diff --git a/lib/tasks/deployment/20200326133630_cleanup_deleted_dossiers.rake b/lib/tasks/deployment/20200326133630_cleanup_deleted_dossiers.rake deleted file mode 100644 index 64bdb9bdb..000000000 --- a/lib/tasks/deployment/20200326133630_cleanup_deleted_dossiers.rake +++ /dev/null @@ -1,10 +0,0 @@ -namespace :after_party do - desc 'Deployment task: cleanup_deleted_dossiers' - task cleanup_deleted_dossiers: :environment do - puts "Running deploy task 'cleanup_deleted_dossiers'" - - DeletedDossier.where(state: :brouillon).destroy_all - - AfterParty::TaskRecord.create version: '20200326133630' - end -end diff --git a/lib/tasks/deployment/20200401123317_process_expired_dossiers_en_construction.rake b/lib/tasks/deployment/20200401123317_process_expired_dossiers_en_construction.rake deleted file mode 100644 index cf7113c98..000000000 --- a/lib/tasks/deployment/20200401123317_process_expired_dossiers_en_construction.rake +++ /dev/null @@ -1,27 +0,0 @@ -namespace :after_party do - desc 'Deployment task: process_expired_dossiers_en_construction' - task process_expired_dossiers_en_construction: :environment do - puts "Running deploy task 'process_expired_dossiers_en_construction'" - - if ENV['APP_NAME'] == 'tps' - dossiers_close_to_expiration = Dossier - .en_construction_close_to_expiration - .without_en_construction_expiration_notice_sent - - ExpiredDossiersDeletionService.send_expiration_notices(dossiers_close_to_expiration) - - BATCH_SIZE = 1000 - - ((dossiers_close_to_expiration.count / BATCH_SIZE).ceil + 1).times do |n| - dossiers_close_to_expiration - .offset(n * BATCH_SIZE) - .limit(BATCH_SIZE) - .update_all(en_construction_close_to_expiration_notice_sent_at: Time.zone.now + n.days) - end - end - - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord.create version: '20200401123317' - end -end diff --git a/lib/tasks/deployment/20200527124112_fix_champ_etablissement.rake b/lib/tasks/deployment/20200527124112_fix_champ_etablissement.rake deleted file mode 100644 index e8e011970..000000000 --- a/lib/tasks/deployment/20200527124112_fix_champ_etablissement.rake +++ /dev/null @@ -1,35 +0,0 @@ -namespace :after_party do - desc 'Deployment task: fix_champ_etablissement' - task fix_champ_etablissement: :environment do - puts "Running deploy task 'fix_champ_etablissement'" - - etablissements = Etablissement.joins(:champ).where.not(dossier_id: nil).where('etablissements.created_at > ?', 1.month.ago) - dossiers_modif = [] - etablissements.find_each do |e| - if e.dossier - user = e.dossier.user - dossier = e.dossier - if user.dossiers.count == 1 && user.siret == e.champ.value - e.update!(dossier_id: nil) - dossier.reload.etablissement = e.reload.dup - dossier.save! - dossiers_modif << dossier.id - fetch_api_entreprise_infos(dossier.etablissement.id, dossier.procedure.id, user.id) - end - end - end - puts "Nb dossiers modifiés: #{dossiers_modif.size}" - AfterParty::TaskRecord.create version: '20200527124112' - end - - def fetch_api_entreprise_infos(etablissement_id, procedure_id, user_id) - [ - APIEntreprise::EntrepriseJob, APIEntreprise::AssociationJob, APIEntreprise::ExercicesJob, - APIEntreprise::EffectifsJob, APIEntreprise::EffectifsAnnuelsJob, APIEntreprise::AttestationSocialeJob, - APIEntreprise::BilansBdfJob - ].each do |job| - job.perform_later(etablissement_id, procedure_id) - end - APIEntreprise::AttestationFiscaleJob.perform_later(etablissement_id, procedure_id, user_id) - end -end diff --git a/lib/tasks/deployment/20200528124044_fix_dossier_etablissement.rake b/lib/tasks/deployment/20200528124044_fix_dossier_etablissement.rake deleted file mode 100644 index 3df50df86..000000000 --- a/lib/tasks/deployment/20200528124044_fix_dossier_etablissement.rake +++ /dev/null @@ -1,20 +0,0 @@ -namespace :after_party do - desc 'Deployment task: fix_dossier_etablissement' - task fix_dossier_etablissement: :environment do - puts "Running deploy task 'fix_dossier_etablissement'" - - etablissements = Etablissement.joins(:champ).where.not(dossier_id: nil).where('etablissements.created_at > ?', 1.month.ago) - dossiers_modif = [] - etablissements.find_each do |e| - if e.dossier - dossier = e.dossier - e.update!(dossier_id: nil) - dossier.reload.etablissement = e.reload.dup - dossier.save! - dossiers_modif << dossier.id - end - end - puts "Nb dossiers modifiés: #{dossiers_modif.size}" - AfterParty::TaskRecord.create version: '20200528124044' - end -end diff --git a/lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake b/lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake deleted file mode 100644 index a96758e98..000000000 --- a/lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake +++ /dev/null @@ -1,25 +0,0 @@ -namespace :after_party do - desc 'Deployment task: drop_down_list_options_to_json' - task drop_down_list_options_to_json: :environment do - puts "Running deploy task 'drop_down_list_options_to_json'" - - types_de_champ = TypeDeChamp.joins(:drop_down_list).where(type_champ: [ - TypeDeChamp.type_champs.fetch(:drop_down_list), - TypeDeChamp.type_champs.fetch(:multiple_drop_down_list), - TypeDeChamp.type_champs.fetch(:linked_drop_down_list) - ]) - progress = ProgressReport.new(types_de_champ.count) - types_de_champ.find_each do |type_de_champ| - type_de_champ.drop_down_list_value = type_de_champ.drop_down_list_value - if type_de_champ.save - type_de_champ.drop_down_list.destroy - end - progress.inc - end - progress.finish - - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord.create version: '20200618121241' - end -end diff --git a/lib/tasks/deployment/20200625113026_migrate_revisions.rake b/lib/tasks/deployment/20200625113026_migrate_revisions.rake deleted file mode 100644 index ffa7c986b..000000000 --- a/lib/tasks/deployment/20200625113026_migrate_revisions.rake +++ /dev/null @@ -1,22 +0,0 @@ -namespace :after_party do - desc 'Deployment task: migrate_revisions' - task migrate_revisions: :environment do - puts "Running deploy task 'migrate_revisions'" - - procedures = Procedure.with_discarded.where(draft_revision_id: nil) - progress = ProgressReport.new(procedures.count) - - puts "Processing procedures" - procedures.find_each do |procedure| - RevisionsMigration.add_revisions(procedure) - progress.inc - end - progress.finish - - TmpDossiersMigrateRevisionsJob.perform_later([]) - - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord.create version: '20200625113026' - end -end diff --git a/lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake b/lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake deleted file mode 100644 index 9940c9843..000000000 --- a/lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake +++ /dev/null @@ -1,18 +0,0 @@ -namespace :after_party do - desc 'Deployment task: add_traitements_from_dossiers' - task add_traitements_from_dossiers: :environment do - puts "Running deploy task 'add_traitements_from_dossiers'" - - dossiers_termines = Dossier.state_termine - progress = ProgressReport.new(dossiers_termines.count) - dossiers_termines.find_each do |dossier| - dossier.traitements.create!(state: dossier.state, motivation: dossier.motivation, processed_at: dossier.processed_at) - progress.inc - end - progress.finish - - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord.create version: '20200630154829' - end -end diff --git a/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake b/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake deleted file mode 100644 index 7bd74babb..000000000 --- a/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake +++ /dev/null @@ -1,18 +0,0 @@ -namespace :after_party do - desc 'Deployment task: add_default_skip_validation_to_piece_justificative' - task add_default_skip_validation_to_piece_justificative: :environment do - puts "Running deploy task 'add_default_skip_validation_to_piece_justificative'" - - tdcs = TypeDeChamp.where(type_champ: TypeDeChamp.type_champs.fetch(:piece_justificative)) - progress = ProgressReport.new(tdcs.count) - tdcs.find_each do |tdc| - tdc.update(skip_pj_validation: true) - progress.inc - end - progress.finish - - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord.create version: '20200708101123' - end -end diff --git a/lib/tasks/deployment/20200728150458_fix_cloned_revisions.rake b/lib/tasks/deployment/20200728150458_fix_cloned_revisions.rake deleted file mode 100644 index abfb8b23a..000000000 --- a/lib/tasks/deployment/20200728150458_fix_cloned_revisions.rake +++ /dev/null @@ -1,25 +0,0 @@ -namespace :after_party do - desc 'Deployment task: fix_cloned_revisions' - task fix_cloned_revisions: :environment do - puts "Running deploy task 'fix_cloned_revisions'" - - Procedure.with_discarded.where(aasm_state: :brouillon).where.not(published_revision_id: nil).update_all(published_revision_id: nil) - - types_de_champ = TypeDeChamp.joins(:revision).where('types_de_champ.procedure_id != procedure_revisions.procedure_id') - progress = ProgressReport.new(types_de_champ.count) - - types_de_champ.find_each do |type_de_champ| - procedure = type_de_champ.procedure ? type_de_champ.procedure : Procedure.with_discarded.find(type_de_champ.procedure_id) - revision_id = procedure.published_revision_id || procedure.draft_revision_id - type_de_champ.update_column(:revision_id, revision_id) - progress.inc - end - - progress.finish - - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord - .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp - end -end diff --git a/lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake b/lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake deleted file mode 100644 index 3969494b9..000000000 --- a/lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake +++ /dev/null @@ -1,71 +0,0 @@ -namespace :after_party do - desc 'Deployment task: fix_geo_areas_geometry' - task fix_geo_areas_geometry: :environment do - puts "Running deploy task 'fix_geo_areas_geometry'" - - geometry_collections = GeoArea.where("geometry -> 'type' = '\"GeometryCollection\"'") - multi_polygons = GeoArea.where("geometry -> 'type' = '\"MultiPolygon\"'") - multi_line_strings = GeoArea.where("geometry -> 'type' = '\"MultiLineString\"'") - - def valid_geometry?(geometry) - RGeo::GeoJSON.decode(geometry.to_json, geo_factory: RGeo::Geographic.simple_mercator_factory) - true - rescue - false - end - - progress = ProgressReport.new(geometry_collections.count) - geometry_collections.find_each do |geometry_collection| - geometry_collection.geometry['geometries'].each do |geometry| - if valid_geometry?(geometry) - geometry_collection.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur') - end - end - - geometry_collection.destroy - progress.inc - end - progress.finish - - progress = ProgressReport.new(multi_line_strings.count) - multi_line_strings.find_each do |multi_line_string| - multi_line_string.geometry['coordinates'].each do |coordinates| - geometry = { - type: 'LineString', - coordinates: coordinates - } - - if valid_geometry?(geometry) - multi_line_string.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur') - end - end - - multi_line_string.destroy - progress.inc - end - progress.finish - - progress = ProgressReport.new(multi_polygons.count) - multi_polygons.find_each do |multi_polygon| - multi_polygon.geometry['coordinates'].each do |coordinates| - geometry = { - type: 'Polygon', - coordinates: coordinates - } - - if valid_geometry?(geometry) - multi_polygon.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur') - end - end - - multi_polygon.destroy - progress.inc - end - progress.finish - - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord - .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp - end -end diff --git a/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id.rake b/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id.rake deleted file mode 100644 index d4df6b6e6..000000000 --- a/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id.rake +++ /dev/null @@ -1,50 +0,0 @@ -namespace :after_party do - desc 'Deployment task: migrate_filters_to_use_stable_id' - task migrate_filters_to_use_stable_id: :environment do - puts "Running deploy task 'migrate_filters_to_use_stable_id'" - - procedure_presentations = ProcedurePresentation.where("filters -> 'migrated' IS NULL") - progress = ProgressReport.new(procedure_presentations.count) - procedure_presentations.find_each do |procedure_presentation| - filters = procedure_presentation.filters - sort = procedure_presentation.sort - displayed_fields = procedure_presentation.displayed_fields - - ['tous', 'suivis', 'traites', 'a-suivre', 'archives'].each do |statut| - filters[statut] = filters[statut].map do |filter| - table, column = filter.values_at('table', 'column') - if table && (table == 'type_de_champ' || table == 'type_de_champ_private') - type_de_champ = TypeDeChamp.find_by(id: column) - filter['column'] = type_de_champ&.stable_id&.to_s - end - filter - end - end - - table, column = sort.values_at('table', 'column') - if table && (table == 'type_de_champ' || table == 'type_de_champ_private') - type_de_champ = TypeDeChamp.find_by(id: column) - sort['column'] = type_de_champ&.stable_id&.to_s - end - - displayed_fields = displayed_fields.map do |displayed_field| - table, column = displayed_field.values_at('table', 'column') - if table && (table == 'type_de_champ' || table == 'type_de_champ_private') - type_de_champ = TypeDeChamp.find_by(id: column) - displayed_field['column'] = type_de_champ&.stable_id&.to_s - end - displayed_field - end - - filters['migrated'] = true - procedure_presentation.update_columns(filters: filters, sort: sort, displayed_fields: displayed_fields) - progress.inc - end - progress.finish - - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord - .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp - end -end diff --git a/lib/tasks/deployment/20201006123842_setup_first_stats.rake b/lib/tasks/deployment/20201006123842_setup_first_stats.rake deleted file mode 100644 index cfe4c93af..000000000 --- a/lib/tasks/deployment/20201006123842_setup_first_stats.rake +++ /dev/null @@ -1,11 +0,0 @@ -namespace :after_party do - desc 'Deployment task: setup_first_stats' - task setup_first_stats: :environment do - Stat.update_stats - - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord - .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp - end -end diff --git a/lib/tasks/deployment/20201218163035_fix_types_de_champ_revisions.rake b/lib/tasks/deployment/20201218163035_fix_types_de_champ_revisions.rake deleted file mode 100644 index c4c118ce0..000000000 --- a/lib/tasks/deployment/20201218163035_fix_types_de_champ_revisions.rake +++ /dev/null @@ -1,19 +0,0 @@ -namespace :after_party do - desc 'Deployment task: fix_types_de_champ_revisions' - task fix_types_de_champ_revisions: :environment do - puts "Running deploy task 'fix_types_de_champ_revisions'" - - types_de_champ = TypeDeChamp.joins(:parent).where('types_de_champ.revision_id != parents_types_de_champ.revision_id') - progress = ProgressReport.new(types_de_champ.count) - types_de_champ.find_each do |type_de_champ| - type_de_champ.update_column(:revision_id, type_de_champ.parent.revision_id) - progress.inc - end - progress.finish - - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord - .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp - end -end diff --git a/spec/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake_spec.rb b/spec/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake_spec.rb deleted file mode 100644 index 93ed3bdef..000000000 --- a/spec/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -describe '20200708101123_add_default_skip_validation_to_piece_justificative.rake' do - let(:rake_task) { Rake::Task['after_party:add_default_skip_validation_to_piece_justificative'] } - let!(:pj_type_de_champ) { create(:type_de_champ_piece_justificative) } - let!(:text_type_de_champ) { create(:type_de_champ_text) } - - before do - rake_task.invoke - text_type_de_champ.reload - pj_type_de_champ.reload - end - - after { rake_task.reenable } - - context 'on a piece_justificative type de champ' do - it 'sets the skip_pj_validation option' do - expect(pj_type_de_champ.skip_pj_validation).to be_truthy - end - end - - context 'on a non piece_justificative type de champ' do - it 'does not set the skip_pj_validation option' do - expect(text_type_de_champ.skip_pj_validation).to be_blank - end - end -end diff --git a/spec/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id_spec.rb b/spec/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id_spec.rb deleted file mode 100644 index 02c51be49..000000000 --- a/spec/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -describe '20201001161931_migrate_filters_to_use_stable_id' do - let(:rake_task) { Rake::Task['after_party:migrate_filters_to_use_stable_id'] } - - let(:procedure) { create(:procedure, :with_instructeur, :with_type_de_champ) } - let(:type_de_champ) { procedure.types_de_champ.first } - let(:sort) do - { - "table" => "type_de_champ", - "column" => type_de_champ.id.to_s, - "order" => "asc" - } - end - let(:filters) do - { - 'tous' => [ - { - "label" => "test", - "table" => "type_de_champ", - "column" => type_de_champ.id.to_s, - "value" => "test" - } - ], - 'suivis' => [], - 'traites' => [], - 'a-suivre' => [], - 'archives' => [] - } - end - let(:displayed_fields) do - [ - { - "label" => "test", - "table" => "type_de_champ", - "column" => type_de_champ.id.to_s - } - ] - end - let!(:procedure_presentation) do - type_de_champ.update_column(:stable_id, 13) - procedure_presentation = create(:procedure_presentation, procedure: procedure, assign_to: procedure.groupe_instructeurs.first.assign_tos.first) - procedure_presentation.update_columns(sort: sort, filters: filters, displayed_fields: displayed_fields) - procedure_presentation - end - - before do - rake_task.invoke - procedure_presentation.reload - end - - after { rake_task.reenable } - - context "should migrate procedure_presentation" do - it "columns are updated" do - expect(procedure_presentation.sort['column']).to eq(type_de_champ.stable_id.to_s) - expect(procedure_presentation.filters['tous'][0]['column']).to eq(type_de_champ.stable_id.to_s) - expect(procedure_presentation.displayed_fields[0]['column']).to eq(type_de_champ.stable_id.to_s) - expect(procedure_presentation.filters['migrated']).to eq(true) - end - end -end From e8cdded515385aaf53bb803afcca3e7b93d91e90 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 6 May 2021 16:10:48 +0200 Subject: [PATCH 4/5] Use explicit name to avoid unknown constant errors --- config/environments/development.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index fa779f52c..2b0f92cbc 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -91,7 +91,7 @@ Rails.application.configure do if ENV['HELO_ENABLED'] == 'enabled' config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { - user_name: APPLICATION_NAME, + user_name: 'demarches-simplifiees', password: '', address: '127.0.0.1', domain: '127.0.0.1', From 19aefa1fd02ec7aca221ab234b01471fe63c1349 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 7 May 2021 11:15:22 +0200 Subject: [PATCH 5/5] update administrate --- Gemfile | 2 +- Gemfile.lock | 30 ++++++++++++------------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index b75222113..8f1078b2d 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ gem 'active_link_to' # Automatically set a class on active links gem 'active_model_serializers' gem 'activestorage-openstack' gem 'active_storage_validations' -gem 'administrate', git: 'https://github.com/thoughtbot/administrate.git', ref: 'refs/pull/1972/head' # Provides an administration UI (pull request #1972 has fixes for Rails 6.1.3.2) +gem 'administrate' gem 'administrate-field-enum' # Allow using Field::Enum in administrate gem 'after_party' gem 'anchored' diff --git a/Gemfile.lock b/Gemfile.lock index 1643c8608..3c58933a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,22 +6,6 @@ GIT open4 (~> 1.3.4) rake -GIT - remote: https://github.com/thoughtbot/administrate.git - revision: 27404f6bbbfa8ae7227ff205ac8cc4ad194194dd - ref: refs/pull/1972/head - specs: - administrate (0.15.0) - actionpack (>= 5.0) - actionview (>= 5.0) - activerecord (>= 5.0) - datetime_picker_rails (~> 0.0.7) - jquery-rails (>= 4.0) - kaminari (>= 1.0) - momentjs-rails (~> 2.8) - sassc-rails (~> 2.1) - selectize-rails (~> 0.6) - GEM remote: https://rubygems.org/ specs: @@ -102,6 +86,16 @@ GEM zeitwerk (~> 2.3) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) + administrate (0.16.0) + actionpack (>= 5.0) + actionview (>= 5.0) + activerecord (>= 5.0) + datetime_picker_rails (~> 0.0.7) + jquery-rails (>= 4.0) + kaminari (>= 1.0) + momentjs-rails (~> 2.8) + sassc-rails (~> 2.1) + selectize-rails (~> 0.6) administrate-field-enum (0.0.9) administrate (~> 0.12) aes_key_wrap (1.1.0) @@ -255,7 +249,7 @@ GEM multipart-post (>= 1.2, < 3) ruby2_keywords faraday-net_http (1.0.1) - ffi (1.14.2) + ffi (1.15.0) flipper (0.20.3) flipper-active_record (0.20.3) activerecord (>= 5.0, < 7) @@ -777,7 +771,7 @@ DEPENDENCIES active_model_serializers active_storage_validations activestorage-openstack - administrate! + administrate administrate-field-enum after_party anchored