From 9a7a82c2f2e8be157127fb9cb849afdb7e2a5a04 Mon Sep 17 00:00:00 2001 From: Evandro Jr Date: Wed, 17 Jun 2015 19:06:05 -0300 Subject: [PATCH] Returns the total followers for the article Add a follower for the article the commit message for your changes. Lines starting --- lib/noosfero/api/v1/articles.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+), 0 deletions(-) diff --git a/lib/noosfero/api/v1/articles.rb b/lib/noosfero/api/v1/articles.rb index 4f82588..bbf7a61 100644 --- a/lib/noosfero/api/v1/articles.rb +++ b/lib/noosfero/api/v1/articles.rb @@ -28,6 +28,23 @@ module Noosfero article = find_article(environment.articles, params[:id]) present article, :with => Entities::Article, :fields => params[:fields] end + + desc "Returns the total followers for the article" + get ':id/followers' do + article = find_article(environment.articles, params[:id]) + total = article.person_followers.size + {:total_followers => total} + end + + desc "Add a follower for the article" + get ':id/follow' do + article = find_article(environment.articles, params[:id]) + article_follower = ArticleFollower.new + article_follower.article = article + article_follower.person = current_person + article_follower.save! + end + post ':id/vote' do value = (params[:value] || 1).to_i -- libgit2 0.21.2