Remove unused carto models
This commit is contained in:
parent
5632929d3d
commit
36f6f54337
17 changed files with 3 additions and 263 deletions
|
@ -1,7 +0,0 @@
|
||||||
class Cadastre < ApplicationRecord
|
|
||||||
belongs_to :dossier, touch: true
|
|
||||||
|
|
||||||
def geometry
|
|
||||||
JSON.parse(read_attribute(:geometry))
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -20,8 +20,6 @@ class Dossier < ApplicationRecord
|
||||||
has_many :pieces_justificatives, dependent: :destroy
|
has_many :pieces_justificatives, dependent: :destroy
|
||||||
has_many :champs, -> { public_only.ordered }, dependent: :destroy
|
has_many :champs, -> { public_only.ordered }, dependent: :destroy
|
||||||
has_many :champs_private, -> { private_only.ordered }, class_name: 'Champ', dependent: :destroy
|
has_many :champs_private, -> { private_only.ordered }, class_name: 'Champ', dependent: :destroy
|
||||||
has_many :quartier_prioritaires, dependent: :destroy
|
|
||||||
has_many :cadastres, dependent: :destroy
|
|
||||||
has_many :commentaires, dependent: :destroy
|
has_many :commentaires, dependent: :destroy
|
||||||
has_many :invites, dependent: :destroy
|
has_many :invites, dependent: :destroy
|
||||||
has_many :follows
|
has_many :follows
|
||||||
|
@ -74,8 +72,6 @@ class Dossier < ApplicationRecord
|
||||||
piece_justificative_file_attachment: :blob
|
piece_justificative_file_attachment: :blob
|
||||||
],
|
],
|
||||||
pieces_justificatives: [],
|
pieces_justificatives: [],
|
||||||
quartier_prioritaires: [],
|
|
||||||
cadastres: [],
|
|
||||||
etablissement: [],
|
etablissement: [],
|
||||||
individual: [],
|
individual: [],
|
||||||
user: [])
|
user: [])
|
||||||
|
@ -247,20 +243,10 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def use_legacy_carto?
|
|
||||||
procedure.use_legacy_carto?
|
|
||||||
end
|
|
||||||
|
|
||||||
def expose_legacy_carto_api?
|
def expose_legacy_carto_api?
|
||||||
procedure.expose_legacy_carto_api?
|
procedure.expose_legacy_carto_api?
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_geometry
|
|
||||||
if json_latlngs.present?
|
|
||||||
UserGeometry.new(json_latlngs)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def geo_position
|
def geo_position
|
||||||
if etablissement.present?
|
if etablissement.present?
|
||||||
point = ApiAdresse::PointAdapter.new(etablissement.geo_adresse).geocode
|
point = ApiAdresse::PointAdapter.new(etablissement.geo_adresse).geocode
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
class ModuleAPICarto < ApplicationRecord
|
class ModuleAPICarto < ApplicationRecord
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
|
|
||||||
validates :use_api_carto, presence: true, allow_blank: true, allow_nil: false
|
|
||||||
validates :quartiers_prioritaires, presence: true, allow_blank: true, allow_nil: false
|
|
||||||
validates :cadastre, presence: true, allow_blank: true, allow_nil: false
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,6 @@ class Procedure < ApplicationRecord
|
||||||
|
|
||||||
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 :types_de_champ_private
|
accepts_nested_attributes_for :types_de_champ_private
|
||||||
|
|
||||||
mount_uploader :logo, ProcedureLogoUploader
|
mount_uploader :logo, ProcedureLogoUploader
|
||||||
|
@ -131,12 +130,8 @@ class Procedure < ApplicationRecord
|
||||||
publiee? || archivee?
|
publiee? || archivee?
|
||||||
end
|
end
|
||||||
|
|
||||||
def use_legacy_carto?
|
|
||||||
module_api_carto.use_api_carto? && !module_api_carto.migrated?
|
|
||||||
end
|
|
||||||
|
|
||||||
def expose_legacy_carto_api?
|
def expose_legacy_carto_api?
|
||||||
module_api_carto.use_api_carto? && module_api_carto.migrated?
|
module_api_carto&.use_api_carto? && module_api_carto&.migrated?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Warning: dossier after_save build_default_champs must be removed
|
# Warning: dossier after_save build_default_champs must be removed
|
||||||
|
@ -207,7 +202,6 @@ class Procedure < ApplicationRecord
|
||||||
procedure = self.deep_clone(include:
|
procedure = self.deep_clone(include:
|
||||||
{
|
{
|
||||||
types_de_piece_justificative: nil,
|
types_de_piece_justificative: nil,
|
||||||
module_api_carto: nil,
|
|
||||||
attestation_template: nil,
|
attestation_template: nil,
|
||||||
types_de_champ: :drop_down_list,
|
types_de_champ: :drop_down_list,
|
||||||
types_de_champ_private: :drop_down_list
|
types_de_champ_private: :drop_down_list
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
class QuartierPrioritaire < ApplicationRecord
|
|
||||||
belongs_to :dossier, touch: true
|
|
||||||
|
|
||||||
def geometry
|
|
||||||
JSON.parse(read_attribute(:geometry))
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,40 +0,0 @@
|
||||||
class UserGeometry
|
|
||||||
alias :read_attribute_for_serialization :send
|
|
||||||
|
|
||||||
def initialize(json_latlngs)
|
|
||||||
@json_latlngs = json_latlngs
|
|
||||||
end
|
|
||||||
|
|
||||||
def geometry
|
|
||||||
to_geo_json(@json_latlngs)
|
|
||||||
end
|
|
||||||
|
|
||||||
def type_de_champ
|
|
||||||
{
|
|
||||||
id: -1,
|
|
||||||
libelle: 'user_geometry',
|
|
||||||
type_champ: 'user_geometry',
|
|
||||||
order_place: -1,
|
|
||||||
descripton: ''
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def to_geo_json(json_latlngs)
|
|
||||||
json = JSON.parse(json_latlngs)
|
|
||||||
|
|
||||||
coordinates = json.map do |lat_longs|
|
|
||||||
outbounds = lat_longs.map do |lat_long|
|
|
||||||
[lat_long['lng'], lat_long['lat']]
|
|
||||||
end
|
|
||||||
|
|
||||||
[outbounds]
|
|
||||||
end
|
|
||||||
|
|
||||||
{
|
|
||||||
type: 'MultiPolygon',
|
|
||||||
coordinates: coordinates
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :cadastre do
|
|
||||||
numero { '001' }
|
|
||||||
feuille { 1 }
|
|
||||||
section { 'OM' }
|
|
||||||
geometry { '{"type": "MultiPolygon", "coordinates": [[[[2.37112834276229, 48.8773116214902], [2.37163254350824, 48.8775780792784], [2.37112834276229, 48.8773116214902]]]]}' }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -31,20 +31,6 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :with_two_quartier_prioritaires do
|
|
||||||
after(:build) do |dossier, _evaluator|
|
|
||||||
dossier.quartier_prioritaires << create(:quartier_prioritaire)
|
|
||||||
dossier.quartier_prioritaires << create(:quartier_prioritaire)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
trait :with_two_cadastres do
|
|
||||||
after(:build) do |dossier, _evaluator|
|
|
||||||
dossier.cadastres << create(:cadastre)
|
|
||||||
dossier.cadastres << create(:cadastre)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
trait :archived do
|
trait :archived do
|
||||||
archived { true }
|
archived { true }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :module_api_carto do
|
|
||||||
use_api_carto { false }
|
|
||||||
quartiers_prioritaires { false }
|
|
||||||
cadastre { false }
|
|
||||||
|
|
||||||
trait :with_api_carto do
|
|
||||||
use_api_carto { true }
|
|
||||||
end
|
|
||||||
|
|
||||||
trait :with_quartiers_prioritaires do
|
|
||||||
use_api_carto { true }
|
|
||||||
quartiers_prioritaires { true }
|
|
||||||
end
|
|
||||||
|
|
||||||
trait :with_cadastre do
|
|
||||||
use_api_carto { true }
|
|
||||||
cadastre { true }
|
|
||||||
end
|
|
||||||
|
|
||||||
trait :with_qp_and_cadastre do
|
|
||||||
use_api_carto { true }
|
|
||||||
quartiers_prioritaires { true }
|
|
||||||
cadastre { true }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -29,13 +29,6 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:build) do |procedure, _evaluator|
|
|
||||||
if procedure.module_api_carto.nil?
|
|
||||||
module_api_carto = create(:module_api_carto)
|
|
||||||
procedure.module_api_carto = module_api_carto
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
trait :with_path do
|
trait :with_path do
|
||||||
path { generate(:published_path) }
|
path { generate(:published_path) }
|
||||||
end
|
end
|
||||||
|
@ -52,12 +45,6 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :with_api_carto do
|
|
||||||
after(:build) do |procedure, _evaluator|
|
|
||||||
procedure.module_api_carto.use_api_carto = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
trait :for_individual do
|
trait :for_individual do
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, _evaluator|
|
||||||
procedure.for_individual = true
|
procedure.for_individual = true
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :quartier_prioritaire do
|
|
||||||
code { 'QPcode' }
|
|
||||||
commune { 'Paris' }
|
|
||||||
nom { 'Test des QP' }
|
|
||||||
geometry { '{"type": "MultiPolygon", "coordinates": [[[[2.37112834276229, 48.8773116214902], [2.37163254350824, 48.8775780792784], [2.37112834276229, 48.8773116214902]]]]}' }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -11,7 +11,7 @@ feature 'Creating a new dossier:' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the procedure has identification by individual' do
|
context 'when the procedure has identification by individual' do
|
||||||
let(:procedure) { create(:procedure, :published, :for_individual, :with_api_carto, :with_type_de_champ, :with_two_type_de_piece_justificative, ask_birthday: ask_birthday) }
|
let(:procedure) { create(:procedure, :published, :for_individual, :with_type_de_champ, :with_two_type_de_piece_justificative, ask_birthday: ask_birthday) }
|
||||||
let(:ask_birthday) { false }
|
let(:ask_birthday) { false }
|
||||||
let(:expected_birthday) { nil }
|
let(:expected_birthday) { nil }
|
||||||
|
|
||||||
|
@ -25,9 +25,6 @@ feature 'Creating a new dossier:' do
|
||||||
it do
|
it do
|
||||||
click_button('Continuer')
|
click_button('Continuer')
|
||||||
|
|
||||||
expect(page).to have_current_path(users_dossier_carte_path(procedure.dossiers.last.id))
|
|
||||||
click_button('Etape suivante')
|
|
||||||
|
|
||||||
expect(page).to have_current_path(brouillon_dossier_path(procedure.dossiers.last))
|
expect(page).to have_current_path(brouillon_dossier_path(procedure.dossiers.last))
|
||||||
|
|
||||||
expect(user.dossiers.first.individual.birthdate).to eq(expected_birthday)
|
expect(user.dossiers.first.individual.birthdate).to eq(expected_birthday)
|
||||||
|
@ -61,7 +58,7 @@ feature 'Creating a new dossier:' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when identifying through SIRET' do
|
context 'when identifying through SIRET' do
|
||||||
let(:procedure) { create(:procedure, :published, :with_api_carto, :with_type_de_champ, :with_two_type_de_piece_justificative) }
|
let(:procedure) { create(:procedure, :published, :with_type_de_champ, :with_two_type_de_piece_justificative) }
|
||||||
let(:dossier) { procedure.dossiers.last }
|
let(:dossier) { procedure.dossiers.last }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -86,9 +83,6 @@ feature 'Creating a new dossier:' do
|
||||||
expect(page).to have_content('OCTO-TECHNOLOGY')
|
expect(page).to have_content('OCTO-TECHNOLOGY')
|
||||||
click_on 'Continuer avec ces informations'
|
click_on 'Continuer avec ces informations'
|
||||||
|
|
||||||
expect(page).to have_current_path(users_dossier_carte_path(dossier))
|
|
||||||
click_button('Etape suivante')
|
|
||||||
|
|
||||||
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Cadastre do
|
|
||||||
it { is_expected.to have_db_column(:surface_intersection) }
|
|
||||||
it { is_expected.to have_db_column(:surface_parcelle) }
|
|
||||||
it { is_expected.to have_db_column(:numero) }
|
|
||||||
it { is_expected.to have_db_column(:feuille) }
|
|
||||||
it { is_expected.to have_db_column(:section) }
|
|
||||||
it { is_expected.to have_db_column(:code_dep) }
|
|
||||||
it { is_expected.to have_db_column(:nom_com) }
|
|
||||||
it { is_expected.to have_db_column(:code_com) }
|
|
||||||
it { is_expected.to have_db_column(:code_arr) }
|
|
||||||
it { is_expected.to have_db_column(:geometry) }
|
|
||||||
|
|
||||||
it { is_expected.to belong_to(:dossier) }
|
|
||||||
end
|
|
|
@ -754,18 +754,6 @@ describe Dossier do
|
||||||
it { is_expected.to eq(modif_date) }
|
it { is_expected.to eq(modif_date) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a quartier_prioritaire is modified' do
|
|
||||||
before { dossier.quartier_prioritaires << create(:quartier_prioritaire) }
|
|
||||||
|
|
||||||
it { is_expected.to eq(modif_date) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when a cadastre is modified' do
|
|
||||||
before { dossier.cadastres << create(:cadastre) }
|
|
||||||
|
|
||||||
it { is_expected.to eq(modif_date) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when a commentaire is modified' do
|
context 'when a commentaire is modified' do
|
||||||
before { dossier.commentaires << create(:commentaire) }
|
before { dossier.commentaires << create(:commentaire) }
|
||||||
|
|
||||||
|
@ -802,51 +790,6 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'geometry' do
|
|
||||||
let(:dossier) { create(:dossier, json_latlngs: json_latlngs) }
|
|
||||||
let(:json_latlngs) { nil }
|
|
||||||
|
|
||||||
subject{ dossier.user_geometry }
|
|
||||||
|
|
||||||
context 'when there are no map' do
|
|
||||||
it { is_expected.to eq(nil) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when there are 2 polygones' do
|
|
||||||
let(:json_latlngs) do
|
|
||||||
'[[{"lat": 2.0, "lng": 102.0}, {"lat": 3.0, "lng": 103.0}, {"lat": 2.0, "lng": 102.0}],
|
|
||||||
[{"lat": 2.0, "lng": 102.0}, {"lat": 3.0, "lng": 103.0}, {"lat": 2.0, "lng": 102.0}]]'
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:expected) do
|
|
||||||
{
|
|
||||||
"type": "MultiPolygon",
|
|
||||||
"coordinates":
|
|
||||||
[
|
|
||||||
[
|
|
||||||
[
|
|
||||||
[102.0, 2.0],
|
|
||||||
[103.0, 3.0],
|
|
||||||
[102.0, 2.0]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[
|
|
||||||
[102.0, 2.0],
|
|
||||||
[103.0, 3.0],
|
|
||||||
[102.0, 2.0]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
subject{ dossier.user_geometry.geometry }
|
|
||||||
|
|
||||||
it { is_expected.to eq(expected) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#delete_and_keep_track" do
|
describe "#delete_and_keep_track" do
|
||||||
let(:dossier) { create(:dossier) }
|
let(:dossier) { create(:dossier) }
|
||||||
let(:deleted_dossier) { DeletedDossier.find_by!(dossier_id: dossier.id) }
|
let(:deleted_dossier) { DeletedDossier.find_by!(dossier_id: dossier.id) }
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe ModuleAPICarto do
|
|
||||||
describe 'assocations' do
|
|
||||||
it { is_expected.to belong_to(:procedure) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'attributes' do
|
|
||||||
it { is_expected.to have_db_column(:use_api_carto) }
|
|
||||||
it { is_expected.to have_db_column(:quartiers_prioritaires) }
|
|
||||||
it { is_expected.to have_db_column(:cadastre) }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -357,7 +357,6 @@ describe Procedure do
|
||||||
|
|
||||||
it 'should duplicate specific objects with different id' do
|
it 'should duplicate specific objects with different id' do
|
||||||
expect(subject.id).not_to eq(procedure.id)
|
expect(subject.id).not_to eq(procedure.id)
|
||||||
expect(subject.module_api_carto).to have_same_attributes_as(procedure.module_api_carto)
|
|
||||||
|
|
||||||
expect(subject.types_de_piece_justificative.size).to eq procedure.types_de_piece_justificative.size
|
expect(subject.types_de_piece_justificative.size).to eq procedure.types_de_piece_justificative.size
|
||||||
expect(subject.types_de_champ.size).to eq procedure.types_de_champ.size
|
expect(subject.types_de_champ.size).to eq procedure.types_de_champ.size
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe QuartierPrioritaire do
|
|
||||||
it { is_expected.to have_db_column(:code) }
|
|
||||||
it { is_expected.to have_db_column(:nom) }
|
|
||||||
it { is_expected.to have_db_column(:commune) }
|
|
||||||
it { is_expected.to have_db_column(:geometry) }
|
|
||||||
|
|
||||||
it { is_expected.to belong_to(:dossier) }
|
|
||||||
|
|
||||||
describe 'geometry' do
|
|
||||||
let(:qp) { create :quartier_prioritaire, geometry: qp_geometry }
|
|
||||||
let(:qp_geometry) { File.open('spec/fixtures/files/qp_geometry_value.txt').read }
|
|
||||||
|
|
||||||
subject { qp.geometry }
|
|
||||||
|
|
||||||
it { is_expected.to eq JSON.parse(qp_geometry) }
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Add table
Add a link
Reference in a new issue