Commit a9b65794ba867b09a1b2c5453076da03b5ea49c2
Committed by
Rodrigo Souto
1 parent
56033c5e
Exists in
master
and in
12 other branches
vote_plugin: allow anonymous votes
Showing
1 changed file
with
5 additions
and
1 deletions
Show diff stats
lib/noosfero/vote_ext.rb
@@ -2,6 +2,10 @@ require_dependency 'models/vote' | @@ -2,6 +2,10 @@ require_dependency 'models/vote' | ||
2 | 2 | ||
3 | class Vote | 3 | class Vote |
4 | 4 | ||
5 | - validates_uniqueness_of :voteable_id, :scope => [:voteable_type, :voter_type, :voter_id] | 5 | + validates_uniqueness_of :voteable_id, :scope => [:voteable_type, :voter_type, :voter_id], :if => :allow_duplicated_vote? |
6 | + | ||
7 | + def allow_duplicated_vote? | ||
8 | + voter.present? | ||
9 | + end | ||
6 | 10 | ||
7 | end | 11 | end |