Commit 6ed5333155731407f5358fc649478eff3087d705
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'api' into stable
Showing
2 changed files
with
8 additions
and
16 deletions
Show diff stats
lib/noosfero/api/entities.rb
... | ... | @@ -53,7 +53,7 @@ module Noosfero |
53 | 53 | expose :image, :using => Image |
54 | 54 | end |
55 | 55 | |
56 | - class ArticleChild < Entity | |
56 | + class ArticleBase < Entity | |
57 | 57 | root 'articles', 'article' |
58 | 58 | expose :id, :body, :abstract |
59 | 59 | expose :created_at, :format_with => :timestamp |
... | ... | @@ -64,18 +64,10 @@ module Noosfero |
64 | 64 | expose :image, :using => Image |
65 | 65 | end |
66 | 66 | |
67 | - class Article < Entity | |
67 | + class Article < ArticleBase | |
68 | 68 | root 'articles', 'article' |
69 | - expose :id, :body, :abstract | |
70 | - expose :created_at, :format_with => :timestamp | |
71 | - expose :title, :documentation => {:type => "String", :desc => "Title of the article"} | |
72 | - expose :created_by, :as => :author, :using => Profile | |
73 | - expose :profile, :using => Profile | |
74 | - expose :categories, :using => Category | |
75 | - # FIXME: create a method that overrides expose and include conditions for return attributes | |
76 | - expose :parent, :using => Article | |
77 | - expose :children, :using => ArticleChild | |
78 | - expose :image, :using => Image | |
69 | + expose :parent, :using => ArticleBase | |
70 | + expose :children, :using => ArticleBase | |
79 | 71 | end |
80 | 72 | |
81 | 73 | class Comment < Entity | ... | ... |
lib/noosfero/api/v1/articles.rb
... | ... | @@ -71,7 +71,7 @@ module Noosfero |
71 | 71 | if !article.save |
72 | 72 | render_api_errors!(article.errors.full_messages) |
73 | 73 | end |
74 | - present article, :with => Entities::Article | |
74 | + present article, :with => Entities::Article, :fields => params[:fields] | |
75 | 75 | end |
76 | 76 | |
77 | 77 | |
... | ... | @@ -110,7 +110,7 @@ module Noosfero |
110 | 110 | if !article.save |
111 | 111 | render_api_errors!(article.errors.full_messages) |
112 | 112 | end |
113 | - present article, :with => Entities::Article | |
113 | + present article, :with => Entities::Article, :fields => params[:fields] | |
114 | 114 | end |
115 | 115 | |
116 | 116 | end |
... | ... | @@ -149,7 +149,7 @@ module Noosfero |
149 | 149 | if !article.save |
150 | 150 | render_api_errors!(article.errors.full_messages) |
151 | 151 | end |
152 | - present article, :with => Entities::Article | |
152 | + present article, :with => Entities::Article, :fields => params[:fields] | |
153 | 153 | end |
154 | 154 | |
155 | 155 | end |
... | ... | @@ -188,7 +188,7 @@ module Noosfero |
188 | 188 | if !article.save |
189 | 189 | render_api_errors!(article.errors.full_messages) |
190 | 190 | end |
191 | - present article, :with => Entities::Article | |
191 | + present article, :with => Entities::Article, :fields => params[:fields] | |
192 | 192 | end |
193 | 193 | |
194 | 194 | end | ... | ... |