Skip to content

Commit 6f3efdc

Browse files
authored
Merge pull request #6 from unepwcmc/Feature/Initial-work-to-add-pame-evaluations-field-to-protectedplanet-api
Feature/Initial work to add pame evaluations field to protectedplanet api
2 parents bd1853c + e3e04d2 commit 6f3efdc

File tree

9 files changed

+708
-123
lines changed

9 files changed

+708
-123
lines changed

.gitmodules

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[submodule "db"]
2-
path = db
3-
url = https://github.com/unepwcmc/protectedplanet-db
2+
path = db
3+
url = https://github.com/unepwcmc/protectedplanet-db
4+
branch = develop

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
language: ruby
2+
before_install:
3+
- sed -i 's/[email protected]:/https:\/\/github.com\//' .gitmodules
4+
- git submodule update --init --recursive
25
install:
36
- sudo apt-get install -y postgresql-9.3-postgis-2.3
47
before_script:

api/v3/views/protected_area.rabl

+12
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,15 @@ end
9797
if @current_user.access_to?(ProtectedArea, :owner_type)
9898
attribute :owner_type
9999
end
100+
101+
if @current_user.access_to?(ProtectedArea, :pame_evaluations)
102+
child :pame_evaluations do
103+
attributes :id, :metadata_id,
104+
:url, :year,
105+
:methodology
106+
child :pame_source => :source do
107+
attributes :data_title, :resp_party,
108+
:year, :language
109+
end
110+
end
111+
end

models/pame_evaluation.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class PameEvaluation < ActiveRecord::Base
2+
belongs_to :protected_area
3+
belongs_to :pame_source
4+
end

models/pame_source.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class PameSource < ActiveRecord::Base
2+
has_many :pame_evaluations
3+
end

models/protected_area.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ProtectedArea < ActiveRecord::Base
1515
:legal_status, :legal_status_updated_at,
1616
:management_plan, :management_authority,
1717
:governance, :reported_area, :reported_marine_area,
18-
:owner_type
18+
:owner_type, :pame_evaluations
1919
]
2020

2121
belongs_to :iucn_category
@@ -26,6 +26,7 @@ class ProtectedArea < ActiveRecord::Base
2626
belongs_to :management_authority
2727
has_and_belongs_to_many :countries, -> { select(:id, :name, :iso_3) }
2828
has_and_belongs_to_many :sub_locations
29+
has_many :pame_evaluations
2930

3031
delegate :jurisdiction, to: :designation, allow_nil: true
3132

test/models/api_user_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_access_to_return_false_if_user_has_no_attribute_access
5050
ATTRIBUTES = [
5151
"no_take_status", "legal_status", "management_authority",
5252
"reported_area", "reported_marine_area", "legal_status_updated_at",
53-
"management_plan", "is_green_list"
53+
"management_plan", "is_green_list", "pame_evaluations"
5454
]
5555
ATTRIBUTES.each do |attribute|
5656
define_method("test_access_to_return_true_if_user_has_#{attribute}_attribute_access") do

0 commit comments

Comments
 (0)