Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pame evaluations #5

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/test/tmp/
/test/version_tmp/
/tmp/
/log
/log/*.log

## Specific to RubyMotion:
.dat*
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0
2.3.1
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ gem "grape", "~> 0.17.0"
gem "grape-rabl", "~> 0.4.1"
gem "grape-kaminari", "~> 0.1.8"
gem "grape_logging", '~> 1.3.0'
gem "kaminari", "0.16.3"
gem "sinatra", "~> 1.4.6"
gem "kramdown", "~> 1.9.0"

Expand Down Expand Up @@ -33,16 +34,17 @@ gem "activesupport", "~> 4.2.5"

# Testing
group :test, :development do
gem "rack-console", '~> 1.3.1'
gem "minitest"
gem "minitest-around", "~> 0.3.2"
gem "database_cleaner", "~> 1.5.1"
gem "factory_girl", "~> 4.0"
gem "factory_bot", '~> 4.10.0'
gem "rack-test", "~> 0.6.3"
end

# Deploy
group :development do
gem 'capistrano', '~> 3.4', require: false
gem 'capistrano', '~> 3.4.1', require: false
gem 'capistrano-bundler', '~> 1.1.4', require: false
gem 'capistrano-rvm', '~> 0.1', require: false
gem 'capistrano-maintenance', '~> 1.0', require: false
Expand Down
103 changes: 56 additions & 47 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ GEM
activemodel (= 4.2.5.1)
activesupport (= 4.2.5.1)
arel (~> 6.0)
activerecord-postgis-adapter (3.1.4)
activerecord-postgis-adapter (3.1.5)
activerecord (~> 4.2)
rgeo-activerecord (>= 4.0.4)
activesupport (4.2.5.1)
Expand All @@ -43,26 +43,26 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
appsignal (1.1.0.beta.5)
appsignal (1.1.9)
rack
thread_safe
arel (6.0.3)
arel (6.0.4)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
builder (3.2.2)
builder (3.2.3)
byebug (3.1.2)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
capistrano (3.4.0)
capistrano (3.4.1)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.4)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-maintenance (1.0.0)
capistrano-maintenance (1.2.0)
capistrano (>= 3.0)
capistrano-passenger (0.2.0)
capistrano (~> 3.0)
Expand All @@ -72,21 +72,23 @@ GEM
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
columnize (0.9.0)
database_cleaner (1.5.1)
concurrent-ruby (1.0.5)
crass (1.0.4)
database_cleaner (1.5.3)
debugger-linecache (1.2.0)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
dotenv (2.1.0)
enumerable-lazy (0.0.1)
dotenv (2.1.2)
enumerable-lazy (0.0.2)
equalizer (0.0.11)
erubis (2.7.0)
exception_notification (4.1.4)
actionmailer (~> 4.0)
activesupport (~> 4.0)
factory_girl (4.5.0)
factory_girl (4.9.0)
activesupport (>= 3.0.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
grape (0.17.0)
activesupport
builder
Expand All @@ -97,87 +99,92 @@ GEM
rack (>= 1.3.0)
rack-accept
virtus (>= 1.0.0)
grape-kaminari (0.1.8)
grape-kaminari (0.1.9)
grape
kaminari
grape-rabl (0.4.1)
grape-rabl (0.4.3)
grape
i18n
rabl
tilt
grape_logging (1.3.0)
grape
hashie (3.4.6)
i18n (0.7.0)
hashie (3.5.7)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
json (1.8.3)
json (1.8.6)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kramdown (1.9.0)
loofah (2.0.3)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.99)
mini_portile2 (2.0.0)
minitest (5.9.0)
mail (2.7.0)
mini_mime (>= 0.1.1)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
minitest-around (0.3.2)
minitest (~> 5.0)
multi_json (1.12.1)
multi_xml (0.5.5)
multi_json (1.13.1)
multi_xml (0.6.0)
mustermann19 (0.4.4)
enumerable-lazy
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (3.0.2)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
net-ssh (4.2.0)
nokogiri (1.8.3)
mini_portile2 (~> 2.3.0)
pg (0.18.4)
pony (1.11)
pony (1.12)
mail (>= 2.0)
rabl (0.11.8)
rabl (0.13.1)
activesupport (>= 2.3.14)
rack (1.6.4)
rack (1.6.10)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cors (0.4.0)
rack-protection (1.5.3)
rack-console (1.3.1)
rack (>= 1.1)
rack-test
rack-cors (1.0.2)
rack-protection (1.5.5)
rack
rack-test (0.6.3)
rack (>= 1.0)
rack_csrf (2.5.0)
rack (>= 1.1.0)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-dom-testing (1.0.9)
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (4.2.5.1)
actionpack (= 4.2.5.1)
activesupport (= 4.2.5.1)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.5.0)
rgeo (0.5.2)
rgeo (0.6.0)
rgeo-activerecord (4.0.5)
activerecord (~> 4.2)
rgeo (~> 0.3)
sinatra (1.4.7)
sinatra (1.4.8)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
slack-notifier (1.5.1)
sshkit (1.8.1)
sshkit (1.16.1)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.2)
tzinfo (1.2.2)
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.8)
tzinfo (1.2.5)
thread_safe (~> 0.1)
virtus (1.0.5)
axiom-types (~> 0.1)
Expand All @@ -195,7 +202,7 @@ DEPENDENCIES
activesupport (~> 4.2.5)
appsignal (~> 1.1.0.beta.5)
byebug (~> 3.1.2)
capistrano (~> 3.4)
capistrano (~> 3.4.1)
capistrano-bundler (~> 1.1.4)
capistrano-maintenance (~> 1.0)
capistrano-passenger (~> 0.2.0)
Expand All @@ -208,11 +215,13 @@ DEPENDENCIES
grape-kaminari (~> 0.1.8)
grape-rabl (~> 0.4.1)
grape_logging (~> 1.3.0)
kaminari (= 0.16.3)
kramdown (~> 1.9.0)
minitest
minitest-around (~> 0.3.2)
pg (~> 0.18.4)
pony (~> 1.11)
rack-console (~> 1.3.1)
rack-cors
rack-test (~> 0.6.3)
rack_csrf (~> 2.5.0)
Expand All @@ -221,4 +230,4 @@ DEPENDENCIES
slack-notifier (~> 1.5.1)

BUNDLED WITH
1.11.2
1.16.2
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,21 @@ $ rackup
```

Now fire up your browser at `localhost:9292`!

## Development

The `rails c` of the rack world...

```
bundle exec rack-console
```

Then make an api user (assuming you also have the PP database set up)

```
user = ApiUser.create(email: "test@test.com", full_name: "Test")
user.activate!
```

Retrieve your token with `user.token`

6 changes: 6 additions & 0 deletions api/v3/views/protected_area.rabl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ if @current_user.access_to?(ProtectedArea, :designation)
end
end

if @current_user.access_to?(ProtectedArea, :pame_evaluations)
child :pame_evaluations, object_root: false do
attributes :id, :method, :year
end
end

if @current_user.access_to?(ProtectedArea, :no_take_status)
child :no_take_status, object_root: false do
attributes :id, :name, :area
Expand Down
2 changes: 1 addition & 1 deletion config/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# config valid only for current version of Capistrano
lock '3.4.0'
lock '3.4.1'

set :application, 'protectedplanet-api'
set :repo_url, 'git@github.com:unepwcmc/protectedplanet-api.git'
Expand Down
2 changes: 2 additions & 0 deletions lib/mailer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'erb'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept running into an error that ERB was being used without explicitly being required, this fixes it. Might be a ruby version thing, can't see the harm in being cautious


module Mailer
NEW_REQUEST_TEMPLATE = ERB.new(File.read("lib/templates/new_request_notification.erb"))
def self.send_new_request_notification api_user, activation_url
Expand Down
4 changes: 2 additions & 2 deletions test/factories/api_users.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :api_user do
email "test@user.com"
full_name "Test User"
Expand Down
4 changes: 2 additions & 2 deletions test/factories/countries.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :country do
name "MyText"
iso "MyString"
Expand Down
6 changes: 3 additions & 3 deletions test/factories/country_statistic.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :country_statistic do
end
end
end
4 changes: 2 additions & 2 deletions test/factories/designations.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :designation do
name "MyString"
association :jurisdiction, factory: :jurisdiction, name: 'My jurisdiction'
Expand Down
4 changes: 2 additions & 2 deletions test/factories/governances.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :governance do
name "MyString"
end
Expand Down
4 changes: 2 additions & 2 deletions test/factories/iucn_categories.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :iucn_category do
name "MyString"
end
Expand Down
4 changes: 2 additions & 2 deletions test/factories/jurisdictions.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :jurisdiction do
name "MyString"
end
Expand Down
4 changes: 2 additions & 2 deletions test/factories/legal_statuses.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :legal_status do
name "MyString"
end
Expand Down
7 changes: 7 additions & 0 deletions test/factories/pame_evaluations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryBot.define do
factory :pame_evaluation do
method "METT"
year 1999
protected_area
end
end
Loading