From ac57b7973ba6fe7d2c0bbe0aedc3313dd121b6ae Mon Sep 17 00:00:00 2001 From: Ferdinando Primerano Date: Fri, 18 Sep 2020 11:14:47 +0100 Subject: [PATCH] Fix and adapt OECM attributes for import --- app/models/protected_area.rb | 9 --------- lib/modules/download/queries.rb | 4 ++-- lib/modules/wdpa/data_standard.rb | 12 +++--------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/app/models/protected_area.rb b/app/models/protected_area.rb index 815ea6bba..730272298 100644 --- a/app/models/protected_area.rb +++ b/app/models/protected_area.rb @@ -24,8 +24,6 @@ class ProtectedArea < ApplicationRecord after_create :create_slug - validate :oecm_attributes - scope :all_except, -> (pa) { where.not(id: pa) } scope :oecms, -> { where(is_oecm: true) } @@ -306,11 +304,4 @@ def self.with_valid_iucn_categories "iucn_categories.name IN (#{valid_categories})" ) end - - OECM_ATTRS_ERROR = "'conservation_objectives' and 'supplementary_info' can only be assigned if this is an OECM area".freeze - def oecm_attributes - return if is_oecm - - errors.add(:oecm_attributes, OECM_ATTRS_ERROR) if supplementary_info || conservation_objectives - end end diff --git a/lib/modules/download/queries.rb b/lib/modules/download/queries.rb index bd0d31fd3..7f4f8711b 100644 --- a/lib/modules/download/queries.rb +++ b/lib/modules/download/queries.rb @@ -9,8 +9,8 @@ module Queries :no_tk_area, :status, :status_yr, :gov_type, :own_type, :mang_auth, :mang_plan, :verif, :metadataid, - :sub_loc, :parent_iso3, :iso3#, - #:supp_info, :cons_obj #TODO Ensure these OECM attributes are working ok here after importing DB with OECMs + :sub_loc, :parent_iso3, :iso3, + :supp_info, :cons_obj ] POLYGONS_COLUMNS = POINTS_COLUMNS.clone diff --git a/lib/modules/wdpa/data_standard.rb b/lib/modules/wdpa/data_standard.rb index e5450790d..fc9c47fce 100644 --- a/lib/modules/wdpa/data_standard.rb +++ b/lib/modules/wdpa/data_standard.rb @@ -26,8 +26,8 @@ class Wdpa::DataStandard :metadataid => {name: :sources, type: :integer, label: 'Source'}, :own_type => {name: :owner_type, type: :string, label: 'Owner Type'}, :pa_def => {name: :is_oecm, type: :oecm, label: 'PA Def'}, - :supp_info => {name: :supp_info, type: :string, label: 'Supplementary Info'}, - :cons_obj => {name: :cons_obj, type: :string, label: 'Conservation objectives'} + :supp_info => {name: :supplementary_info, type: :string, label: 'Supplementary Info'}, + :cons_obj => {name: :conservation_objectives, type: :string, label: 'Conservation objectives'} } POLYGON_ATTRIBUTES = [ @@ -37,11 +37,6 @@ class Wdpa::DataStandard :shape_length ] - OECM_ATTRIBUTES = [ - :supp_info, - :cons_obj - ] - module Matchers GEOMETRY_TABLE = /wdpa_?(wdoecm_)?po/i POLYGON_TABLE = /poly/i @@ -61,9 +56,8 @@ def self.standard_attributes STANDARD_ATTRIBUTES end - # TODO Ensure OECM attributes are included when importing a release with OECM areas def self.common_attributes - STANDARD_ATTRIBUTES.keys - POLYGON_ATTRIBUTES - OECM_ATTRIBUTES + STANDARD_ATTRIBUTES.keys - POLYGON_ATTRIBUTES end def self.standard_geometry_attributes