Stop using legacy api carto after migration

This commit is contained in:
Paul Chavard 2018-10-31 11:32:41 +01:00
parent 44ca6a2d02
commit 2462e42b53
8 changed files with 14 additions and 8 deletions

View file

@ -61,7 +61,7 @@ module NewUser
@dossier.update!(autorisation_donnees: true) @dossier.update!(autorisation_donnees: true)
flash.notice = "Identité enregistrée" flash.notice = "Identité enregistrée"
if @dossier.procedure.module_api_carto.use_api_carto if @dossier.use_legacy_carto?
redirect_to users_dossier_carte_path(@dossier.id) redirect_to users_dossier_carte_path(@dossier.id)
else else
redirect_to brouillon_dossier_path(@dossier) redirect_to brouillon_dossier_path(@dossier)

View file

@ -245,6 +245,10 @@ class Dossier < ApplicationRecord
end end
end end
def use_legacy_carto?
procedure.use_legacy_carto?
end
def user_geometry def user_geometry
if json_latlngs.present? if json_latlngs.present?
UserGeometry.new(json_latlngs) UserGeometry.new(json_latlngs)

View file

@ -30,8 +30,6 @@ class Procedure < ApplicationRecord
has_one_attached :notice has_one_attached :notice
has_one_attached :deliberation has_one_attached :deliberation
delegate :use_api_carto, to: :module_api_carto
accepts_nested_attributes_for :types_de_champ, :reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true accepts_nested_attributes_for :types_de_champ, :reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true
accepts_nested_attributes_for :types_de_piece_justificative, :reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true accepts_nested_attributes_for :types_de_piece_justificative, :reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true
accepts_nested_attributes_for :module_api_carto accepts_nested_attributes_for :module_api_carto
@ -133,6 +131,10 @@ class Procedure < ApplicationRecord
publiee? || archivee? publiee? || archivee?
end end
def use_legacy_carto?
module_api_carto.use_api_carto? && !module_api_carto.migrated?
end
# Warning: dossier after_save build_default_champs must be removed # Warning: dossier after_save build_default_champs must be removed
# to save a dossier created from this method # to save a dossier created from this method
def new_dossier def new_dossier

View file

@ -3,6 +3,6 @@ class UserRoutesAuthorizationService
auth = controller.route_authorization auth = controller.route_authorization
auth[:states].include?(dossier.state) && auth[:states].include?(dossier.state) &&
(auth[:api_carto].nil? ? true : auth[:api_carto] == dossier.procedure.use_api_carto) (auth[:api_carto].nil? ? true : auth[:api_carto] == dossier.use_legacy_carto?)
end end
end end

View file

@ -17,7 +17,7 @@
- if champs.any? - if champs.any?
= render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' } = render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' }
- if @dossier.procedure.use_api_carto - if @dossier.use_legacy_carto?
%h3 Cartographie %h3 Cartographie
- if @dossier.quartier_prioritaires.any? - if @dossier.quartier_prioritaires.any?
%h4 Quartiers prioritaires %h4 Quartiers prioritaires

View file

@ -25,7 +25,7 @@
.actions .actions
= link_to 'Utiliser un autre numéro SIRET', siret_dossier_path(@dossier), class: 'button' = link_to 'Utiliser un autre numéro SIRET', siret_dossier_path(@dossier), class: 'button'
- if @dossier.procedure.use_api_carto - if @dossier.use_legacy_carto?
/ Until the old layout is gone, we need to disable turbolinks / Until the old layout is gone, we need to disable turbolinks
/ to avoid the map loading twice (once for the turbolinks preview, / to avoid the map loading twice (once for the turbolinks preview,
/ once when turbolinks notices the layout are differents and reloads / once when turbolinks notices the layout are differents and reloads

View file

@ -15,7 +15,7 @@
.card .card
= render partial: "shared/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at, profile: profile } = render partial: "shared/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at, profile: profile }
- if dossier.procedure.use_api_carto - if dossier.use_legacy_carto?
.tab-title Cartographie .tab-title Cartographie
.card .card
= render partial: "shared/dossiers/map", locals: { dossier: dossier } = render partial: "shared/dossiers/map", locals: { dossier: dossier }

View file

@ -346,7 +346,7 @@ describe Admin::ProceduresController, type: :controller do
it { expect(subject.for_individual).not_to eq procedure_params[:for_individual] } it { expect(subject.for_individual).not_to eq procedure_params[:for_individual] }
it { expect(subject.individual_with_siret).not_to eq procedure_params[:individual_with_siret] } it { expect(subject.individual_with_siret).not_to eq procedure_params[:individual_with_siret] }
it { expect(subject.use_api_carto).not_to eq procedure_params[:module_api_carto_attributes][:use_api_carto] } it { expect(subject.use_legacy_carto?).not_to eq procedure_params[:module_api_carto_attributes][:use_api_carto] }
end end
end end
end end