[Git][noosfero/noosfero][api] 2 commits: API improvements
Rodrigo Souto
gitlab at gitlab.com
Mon Jun 29 15:58:33 BRT 2015
Rodrigo Souto pushed to branch api at Noosfero / noosfero
Commits:
532cef67 by Tallys Martins at 2015-06-24T12:11:56Z
API improvements
- Fixed bug on GET enterprise API showing communities and vice-versa.
- Improved POST comment API to recieve multiple params, such as Title.
Signed-off-by: André Bernardes <andrebsguedes at gmail.com>
Signed-off-by: Tallys Martins <tallysmartins at gmail.com>
- - - - -
c05d4206 by Rodrigo Souto at 2015-06-29T18:58:30Z
Merge branch 'api_fixies' into 'api'
API improvements
- Fixed bug on GET enterprise API showing communities and vice-versa.
- Improved POST comment API to recieve multiple params, such as Title.
See merge request !610
- - - - -
3 changed files:
- lib/noosfero/api/v1/comments.rb
- lib/noosfero/api/v1/communities.rb
- lib/noosfero/api/v1/enterprises.rb
Changes:
=====================================
lib/noosfero/api/v1/comments.rb
=====================================
--- a/lib/noosfero/api/v1/comments.rb
+++ b/lib/noosfero/api/v1/comments.rb
@@ -30,7 +30,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
=====================================
lib/noosfero/api/v1/communities.rb
=====================================
--- 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
=====================================
lib/noosfero/api/v1/enterprises.rb
=====================================
--- 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
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/6dbdae926759ffdefb9678b2c39208279a1057af...c05d42061a98fbe9944af790b68f676a20930404
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150629/e1fbba03/attachment.html>
More information about the Noosfero-dev
mailing list