Skip to content

Commit

Permalink
Fix and adapt OECM attributes for import
Browse files Browse the repository at this point in the history
  • Loading branch information
Levia committed Sep 18, 2020
1 parent d7134fd commit ac57b79
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
9 changes: 0 additions & 9 deletions app/models/protected_area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/modules/download/queries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions lib/modules/wdpa/data_standard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ac57b79

Please sign in to comment.