adds votes to spending proposals

This commit is contained in:
rgarcia
2016-03-29 14:53:46 +02:00
parent e52004edc3
commit ed1ec1c553
18 changed files with 327 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ class SpendingProposal < ActiveRecord::Base
include Taggable
apply_simple_captcha
acts_as_votable
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
belongs_to :geozone
@@ -80,6 +81,10 @@ class SpendingProposal < ActiveRecord::Base
valuation_finished
end
def total_votes
cached_votes_up
end
def code
"#{id}" + (administrator.present? ? "-A#{administrator.id}" : "")
end
@@ -89,4 +94,14 @@ class SpendingProposal < ActiveRecord::Base
update(unfeasible_email_sent_at: Time.now)
end
def votable_by?(user)
user && user.level_two_or_three_verified?
end
def register_vote(user, vote_value)
if votable_by?(user)
vote_by(voter: user, vote: vote_value)
end
end
end