Skip to content

Commit

Permalink
Merge branch 'release-0.4.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomarrocoli committed Mar 21, 2022
2 parents 1deff44 + fdb62ac commit 2865cff
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 0.4.0

**Add new fields to Protected Areas JSON**
* Add :green_list_status, :is_oecm, :supplementary_info, :conservation_objectives, and :green_list_url
* Update documentation

### 0.3.2

* Update the introduction text
Expand Down
26 changes: 24 additions & 2 deletions api/v3/views/protected_area.rabl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ if @current_user.access_to?(ProtectedArea, :is_green_list)
attribute :is_green_list
end

if @current_user.access_to?(ProtectedArea, :is_oecm)
attribute :is_oecm
end

if @current_user.access_to?(ProtectedArea, :supplementary_info)
attribute :supplementary_info
end

if @current_user.access_to?(ProtectedArea, :conservation_objectives)
attribute :conservation_objectives
end

if @current_user.access_to?(ProtectedArea, :green_list_url)
attribute :green_list_url
end

# Relations
if @current_user.access_to?(ProtectedArea, :countries)
child :countries, object_root: false do
Expand All @@ -49,8 +65,8 @@ if @current_user.access_to?(ProtectedArea, :countries)
end
end

if @current_user.access_to?(ProtectedArea, :sublocations)
child :sublocations, object_root: false do
if @current_user.access_to?(ProtectedArea, :sub_locations)
child :sub_locations, object_root: false do
attributes :id, :english_name
end
end
Expand Down Expand Up @@ -109,3 +125,9 @@ if @current_user.access_to?(ProtectedArea, :pame_evaluations)
end
end
end

if @current_user.access_to?(ProtectedArea, :green_list_status)
child :green_list_status, object_root: false do
attributes :id, :status, :expiry_date
end
end
3 changes: 3 additions & 0 deletions models/green_list_status.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class GreenListStatus < ActiveRecord::Base
has_one :protected_area
end
9 changes: 8 additions & 1 deletion models/protected_area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class ProtectedArea < ActiveRecord::Base
:legal_status, :legal_status_updated_at,
:management_plan, :management_authority,
:governance, :reported_area, :reported_marine_area,
:owner_type, :pame_evaluations
:owner_type, :pame_evaluations, :sub_locations,
:green_list_status, :is_oecm, :supplementary_info,
:conservation_objectives, :green_list_url
]

belongs_to :iucn_category
Expand All @@ -24,6 +26,7 @@ class ProtectedArea < ActiveRecord::Base
belongs_to :governance
belongs_to :no_take_status
belongs_to :management_authority
belongs_to :green_list_status
has_and_belongs_to_many :countries, -> { select(:id, :name, :iso_3) }
has_and_belongs_to_many :sub_locations
has_many :pame_evaluations
Expand Down Expand Up @@ -56,4 +59,8 @@ def self.search params
def link_to_pp
File.join($secrets[:host], self.wdpa_id.to_s)
end

def is_green_list
green_list_status_id.present?
end
end
40 changes: 29 additions & 11 deletions web/views/documentation/protected_areas.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ Sample response:
"reported_area": "0.3933",
"management_plan": "Not Reported",
"is_green_list": false,
"is_oecm": false,
"supplementary_info": "Not Applicable",
"conservation_objectives": "Not Applicable",
"green_list_url": null,
"owner_type": "Not Reported",
"countries": [
{
Expand All @@ -79,20 +83,21 @@ Sample response:
"id": "UGA"
}
],
"sub_locations": [],
"iucn_category": {
"id": 8,
"name": "Not Reported"
},
"designation": {
"id": 12,
"id": 13,
"name": "Forest Reserve",
"jurisdiction": {
"id": 1,
"name": "National"
}
},
"no_take_status": {
"id": 11851,
"id": 11293,
"name": "Not Applicable",
"area": "0.0"
},
Expand All @@ -109,6 +114,7 @@ Sample response:
"governance_type": "Governance by Government"
},
"pame_evaluations": [],
"green_list_status": null,
"links": {
"protected_planet": "http://protectedplanet.net/40366"
},
Expand Down Expand Up @@ -265,6 +271,10 @@ Sample response:
"reported_area": "484.6",
"management_plan": "Not Reported",
"is_green_list": false,
"is_oecm": false,
"supplementary_info": "Not Applicable",
"conservation_objectives": "Not Applicable",
"green_list_url": null,
"owner_type": "Not Reported",
"countries": [
{
Expand All @@ -273,6 +283,7 @@ Sample response:
"id": "MAR"
}
],
"sub_locations": [],
"iucn_category": {
"id": 10,
"name": "Not Assigned"
Expand All @@ -286,12 +297,12 @@ Sample response:
}
},
"no_take_status": {
"id": 157133,
"id": 148453,
"name": "Not Reported",
"area": "0.0"
},
"legal_status": {
"id": 5,
"id": 6,
"name": "Adopted"
},
"management_authority": {
Expand All @@ -304,19 +315,20 @@ Sample response:
},
"pame_evaluations": [
{
"id": 55317,
"metadata_id": 42,
"url": "Not Reported",
"id": 29653,
"metadata_id": 27,
"url": "Not reported",
"year": 2018,
"methodology": "IMET",
"source": {
"data_title": "List of protected areas assessed with the Integrated Management Effectiveness Tool (IMET)",
"resp_party": "European Commission",
"data_title": "JRC IMET information",
"resp_party": "JRC",
"year": 2019,
"language": "English"
}
}
],
"green_list_status": null,
"links": {
"protected_planet": "http://protectedplanet.net/555547509"
},
Expand Down Expand Up @@ -391,6 +403,10 @@ Sample response:
"reported_area": "0.3933",
"management_plan": "Not Reported",
"is_green_list": false,
"is_oecm": false,
"supplementary_info": "Not Applicable",
"conservation_objectives": "Not Applicable",
"green_list_url": null,
"owner_type": "Not Reported",
"countries": [
{
Expand All @@ -399,20 +415,21 @@ Sample response:
"id": "UGA"
}
],
"sub_locations": [],
"iucn_category": {
"id": 8,
"name": "Not Reported"
},
"designation": {
"id": 12,
"id": 13,
"name": "Forest Reserve",
"jurisdiction": {
"id": 1,
"name": "National"
}
},
"no_take_status": {
"id": 11851,
"id": 11293,
"name": "Not Applicable",
"area": "0.0"
},
Expand All @@ -429,6 +446,7 @@ Sample response:
"governance_type": "Governance by Government"
},
"pame_evaluations": [],
"green_list_status": null,
"links": {
"protected_planet": "http://protectedplanet.net/40366"
},
Expand Down

0 comments on commit 2865cff

Please sign in to comment.