Commit 9a7a82c2f2e8be157127fb9cb849afdb7e2a5a04

Authored by Evandro Jr
1 parent 33d70c93

Returns the total followers for the article

Add a follower for the article
the commit message for your changes. Lines starting
Showing 1 changed file with 17 additions and 0 deletions   Show diff stats
lib/noosfero/api/v1/articles.rb
... ... @@ -28,6 +28,23 @@ module Noosfero
28 28 article = find_article(environment.articles, params[:id])
29 29 present article, :with => Entities::Article, :fields => params[:fields]
30 30 end
  31 +
  32 + desc "Returns the total followers for the article"
  33 + get ':id/followers' do
  34 + article = find_article(environment.articles, params[:id])
  35 + total = article.person_followers.size
  36 + {:total_followers => total}
  37 + end
  38 +
  39 + desc "Add a follower for the article"
  40 + get ':id/follow' do
  41 + article = find_article(environment.articles, params[:id])
  42 + article_follower = ArticleFollower.new
  43 + article_follower.article = article
  44 + article_follower.person = current_person
  45 + article_follower.save!
  46 + end
  47 +
31 48  
32 49 post ':id/vote' do
33 50 value = (params[:value] || 1).to_i
... ...