diff --git a/lib/noosfero/api/v1/comments.rb b/lib/noosfero/api/v1/comments.rb index 3b88259..2d456a5 100644 --- a/lib/noosfero/api/v1/comments.rb +++ b/lib/noosfero/api/v1/comments.rb @@ -38,7 +38,8 @@ module Noosfero # POST api/v1/articles/12/comments?private_toke=234298743290432&body=new comment post ":id/comments" do article = find_article(environment.articles, params[:id]) - present article.comments.create(:author => current_person, :body => params[:body]), :with => Entities::Comment + options = params[:comment].merge(:author => current_person) + present article.comments.create(options), :with => Entities::Comment end end diff --git a/lib/noosfero/api/v1/communities.rb b/lib/noosfero/api/v1/communities.rb index 17d0fe2..7899269 100644 --- a/lib/noosfero/api/v1/communities.rb +++ b/lib/noosfero/api/v1/communities.rb @@ -19,6 +19,7 @@ module Noosfero get do communities = select_filtered_collection_of(environment, 'communities', params) communities = communities.visible_for_person(current_person) + communities = communities.by_location(params) # Must be the last. May return Exception obj. present communities, :with => Entities::Community end @@ -41,7 +42,10 @@ module Noosfero end get ':id' do - community = environment.communities.visible.find_by_id(params[:id]) + community = environment.communities.find_by_id(params[:id]) + unless community.nil? + community = nil unless community.display_info_to?(current_person) + end present community, :with => Entities::Community end diff --git a/lib/noosfero/api/v1/enterprises.rb b/lib/noosfero/api/v1/enterprises.rb index 6e267c8..4426479 100644 --- a/lib/noosfero/api/v1/enterprises.rb +++ b/lib/noosfero/api/v1/enterprises.rb @@ -5,7 +5,7 @@ module Noosfero before { authenticate! } resource :enterprises do - + # Collect enterprises from environment # # Parameters: @@ -26,7 +26,10 @@ module Noosfero desc "Return one enterprise by id" get ':id' do - enterprise = environment.enterprises.visible.find_by_id(params[:id]) + enterprise = environment.enterprises.find_by_id(params[:id]) + unless enterprise.nil? + enterprise = nil unless enterprise.display_info_to?(current_person) + end present enterprise, :with => Entities::Enterprise end -- libgit2 0.21.2