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,7 +53,7 @@ module Noosfero | ||
| 53 | expose :image, :using => Image | 53 | expose :image, :using => Image |
| 54 | end | 54 | end |
| 55 | 55 | ||
| 56 | - class ArticleChild < Entity | 56 | + class ArticleBase < Entity |
| 57 | root 'articles', 'article' | 57 | root 'articles', 'article' |
| 58 | expose :id, :body, :abstract | 58 | expose :id, :body, :abstract |
| 59 | expose :created_at, :format_with => :timestamp | 59 | expose :created_at, :format_with => :timestamp |
| @@ -64,18 +64,10 @@ module Noosfero | @@ -64,18 +64,10 @@ module Noosfero | ||
| 64 | expose :image, :using => Image | 64 | expose :image, :using => Image |
| 65 | end | 65 | end |
| 66 | 66 | ||
| 67 | - class Article < Entity | 67 | + class Article < ArticleBase |
| 68 | root 'articles', 'article' | 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 | end | 71 | end |
| 80 | 72 | ||
| 81 | class Comment < Entity | 73 | class Comment < Entity |
lib/noosfero/api/v1/articles.rb
| @@ -71,7 +71,7 @@ module Noosfero | @@ -71,7 +71,7 @@ module Noosfero | ||
| 71 | if !article.save | 71 | if !article.save |
| 72 | render_api_errors!(article.errors.full_messages) | 72 | render_api_errors!(article.errors.full_messages) |
| 73 | end | 73 | end |
| 74 | - present article, :with => Entities::Article | 74 | + present article, :with => Entities::Article, :fields => params[:fields] |
| 75 | end | 75 | end |
| 76 | 76 | ||
| 77 | 77 | ||
| @@ -110,7 +110,7 @@ module Noosfero | @@ -110,7 +110,7 @@ module Noosfero | ||
| 110 | if !article.save | 110 | if !article.save |
| 111 | render_api_errors!(article.errors.full_messages) | 111 | render_api_errors!(article.errors.full_messages) |
| 112 | end | 112 | end |
| 113 | - present article, :with => Entities::Article | 113 | + present article, :with => Entities::Article, :fields => params[:fields] |
| 114 | end | 114 | end |
| 115 | 115 | ||
| 116 | end | 116 | end |
| @@ -149,7 +149,7 @@ module Noosfero | @@ -149,7 +149,7 @@ module Noosfero | ||
| 149 | if !article.save | 149 | if !article.save |
| 150 | render_api_errors!(article.errors.full_messages) | 150 | render_api_errors!(article.errors.full_messages) |
| 151 | end | 151 | end |
| 152 | - present article, :with => Entities::Article | 152 | + present article, :with => Entities::Article, :fields => params[:fields] |
| 153 | end | 153 | end |
| 154 | 154 | ||
| 155 | end | 155 | end |
| @@ -188,7 +188,7 @@ module Noosfero | @@ -188,7 +188,7 @@ module Noosfero | ||
| 188 | if !article.save | 188 | if !article.save |
| 189 | render_api_errors!(article.errors.full_messages) | 189 | render_api_errors!(article.errors.full_messages) |
| 190 | end | 190 | end |
| 191 | - present article, :with => Entities::Article | 191 | + present article, :with => Entities::Article, :fields => params[:fields] |
| 192 | end | 192 | end |
| 193 | 193 | ||
| 194 | end | 194 | end |