Commit 168fcdaeca2c076d0e9f6ecd044b3ca9edc849e3
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'api' into stable
Showing
2 changed files
with
3 additions
and
2 deletions
Show diff stats
lib/noosfero/api/entities.rb
@@ -68,7 +68,8 @@ module Noosfero | @@ -68,7 +68,8 @@ module Noosfero | ||
68 | expose :created_by, :as => :author, :using => Profile | 68 | expose :created_by, :as => :author, :using => Profile |
69 | expose :profile, :using => Profile | 69 | expose :profile, :using => Profile |
70 | expose :categories, :using => Category | 70 | expose :categories, :using => Category |
71 | - expose :parent, :using => Article | 71 | + # FIXME: create a method that overrides expose and include conditions for return attributes |
72 | + expose :parent, :using => Article, :if => lambda { |article, options| options[:fields].blank? || options[:fields].include?(:parent) } | ||
72 | expose :children, :using => ArticleChild | 73 | expose :children, :using => ArticleChild |
73 | expose :image, :using => Image | 74 | expose :image, :using => Image |
74 | end | 75 | end |
lib/noosfero/api/v1/articles.rb
@@ -42,7 +42,7 @@ module Noosfero | @@ -42,7 +42,7 @@ module Noosfero | ||
42 | article = find_article(environment.articles, params[:id]) | 42 | article = find_article(environment.articles, params[:id]) |
43 | articles = select_filtered_collection_of(article, 'children', params) | 43 | articles = select_filtered_collection_of(article, 'children', params) |
44 | articles = articles.display_filter(current_person, nil) | 44 | articles = articles.display_filter(current_person, nil) |
45 | - present articles, :with => Entities::Article | 45 | + present articles, :with => Entities::Article, :fields => [:id, :name, :abstract, :author] |
46 | end | 46 | end |
47 | 47 | ||
48 | get ':id/children/:child_id' do | 48 | get ':id/children/:child_id' do |