From d75b4fbd3cabc2ea6d7299a085e98a28b24cf6ea Mon Sep 17 00:00:00 2001 From: Evandro Junior Date: Tue, 19 Jan 2016 14:43:40 -0300 Subject: [PATCH] adds support for voting without login --- lib/noosfero/api/v1/articles.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/noosfero/api/v1/articles.rb b/lib/noosfero/api/v1/articles.rb index 7c06029..69e4ee5 100644 --- a/lib/noosfero/api/v1/articles.rb +++ b/lib/noosfero/api/v1/articles.rb @@ -156,15 +156,12 @@ module Noosfero if vote @current_tmp_user.data << article.id @current_tmp_user.store - begin - vote = Vote.new(:voteable => article, :voter => current_person, :vote => value) - {:vote => vote.save} - rescue ActiveRecord::RecordInvalid => e - render_api_error!(e.message, 400) - end {:vote => do_vote(article, current_person, value)} - vote = Vote.new(:voteable => article, :voter => current_person, :vote => value) - {:vote => vote.save} + else + {:vote => false} + end + else + {:vote => do_vote(article, current_person, value)} end end @@ -206,7 +203,7 @@ module Noosfero child.hit present_partial child, :with => Entities::Article end - + desc 'Suggest a article to another profile' do detail 'Suggest a article to another profile (person, community...)' params Noosfero::API::Entities::Article.documentation -- libgit2 0.21.2