Commit fdb1397ce50e952e92796a91a01474e5aa0420c9

Authored by Evandro Junior
2 parents 80b8212d 966b86fb

Merge branch 'api' of https://gitlab.com/participa/noosfero into api

lib/noosfero/api/api.rb
... ... @@ -9,7 +9,7 @@ module Noosfero
9 9  
10 10 logger = Logger.new(File.join(Rails.root, 'log', "#{ENV['RAILS_ENV'] || 'production'}_api.log"))
11 11 logger.formatter = GrapeLogging::Formatters::Default.new
12   - use RequestLogger, { logger: logger }
  12 + use GrapeLogging::Middleware::RequestLogger, { logger: logger }
13 13  
14 14 rescue_from :all do |e|
15 15 logger.error e
... ... @@ -45,6 +45,7 @@ module Noosfero
45 45 mount V1::Enterprises
46 46 mount V1::Categories
47 47 mount V1::Tasks
  48 + mount V1::Environments
48 49 mount Session
49 50  
50 51 # hook point which allow plugins to add Grape::API extensions to API::API
... ...
lib/noosfero/api/entities.rb
... ... @@ -114,6 +114,10 @@ module Noosfero
114 114 expose :type
115 115 end
116 116  
  117 + class Environment < Entity
  118 + expose :name
  119 + end
  120 +
117 121 end
118 122 end
119 123 end
... ...
lib/noosfero/api/session.rb
... ... @@ -37,7 +37,7 @@ module Noosfero
37 37 end
38 38 post "/register" do
39 39 unique_attributes! User, [:email, :login]
40   - attrs = attributes_for_keys [:email, :login, :password]
  40 + attrs = attributes_for_keys [:email, :login, :password] + environment.signup_person_fields
41 41 attrs[:password_confirmation] = attrs[:password]
42 42 remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR'])
43 43 private_key = API.NOOSFERO_CONF['api_recaptcha_private_key']
... ...
lib/noosfero/api/v1/environments.rb 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +module Noosfero
  2 + module API
  3 + module V1
  4 + class Environments < Grape::API
  5 +
  6 + resource :environment do
  7 +
  8 + desc "Return the person information"
  9 + get '/signup_person_fields' do
  10 + present environment.signup_person_fields
  11 + end
  12 +
  13 + end
  14 +
  15 + end
  16 + end
  17 + end
  18 +end
... ...