Commit f19bda317c30156b406a33d6b87188e474f5ca7d

Authored by Victor Costa
Committed by Rodrigo Souto
1 parent a7b2bd76

api: limit returned fields in articles children

lib/noosfero/api/entities.rb
... ... @@ -68,7 +68,8 @@ module Noosfero
68 68 expose :created_by, :as => :author, :using => Profile
69 69 expose :profile, :using => Profile
70 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 73 expose :children, :using => ArticleChild
73 74 expose :image, :using => Image
74 75 end
... ...
lib/noosfero/api/v1/articles.rb
... ... @@ -33,7 +33,7 @@ module Noosfero
33 33 article = find_article(environment.articles, params[:id])
34 34 articles = select_filtered_collection_of(article, 'children', params)
35 35 articles = articles.display_filter(current_person, nil)
36   - present articles, :with => Entities::Article
  36 + present articles, :with => Entities::Article, :fields => [:id, :name, :abstract, :author]
37 37 end
38 38  
39 39 get ':id/children/:child_id' do
... ...