Commit d75b4fbd3cabc2ea6d7299a085e98a28b24cf6ea
1 parent
062c5cea
Exists in
staging
and in
3 other branches
adds support for voting without login
Showing
1 changed file
with
6 additions
and
9 deletions
Show diff stats
lib/noosfero/api/v1/articles.rb
... | ... | @@ -156,15 +156,12 @@ module Noosfero |
156 | 156 | if vote |
157 | 157 | @current_tmp_user.data << article.id |
158 | 158 | @current_tmp_user.store |
159 | - begin | |
160 | - vote = Vote.new(:voteable => article, :voter => current_person, :vote => value) | |
161 | - {:vote => vote.save} | |
162 | - rescue ActiveRecord::RecordInvalid => e | |
163 | - render_api_error!(e.message, 400) | |
164 | - end | |
165 | 159 | {:vote => do_vote(article, current_person, value)} |
166 | - vote = Vote.new(:voteable => article, :voter => current_person, :vote => value) | |
167 | - {:vote => vote.save} | |
160 | + else | |
161 | + {:vote => false} | |
162 | + end | |
163 | + else | |
164 | + {:vote => do_vote(article, current_person, value)} | |
168 | 165 | end |
169 | 166 | end |
170 | 167 | |
... | ... | @@ -206,7 +203,7 @@ module Noosfero |
206 | 203 | child.hit |
207 | 204 | present_partial child, :with => Entities::Article |
208 | 205 | end |
209 | - | |
206 | + | |
210 | 207 | desc 'Suggest a article to another profile' do |
211 | 208 | detail 'Suggest a article to another profile (person, community...)' |
212 | 209 | params Noosfero::API::Entities::Article.documentation | ... | ... |