Skip to content

Commit

Permalink
fixed voting problem #2
Browse files Browse the repository at this point in the history
  • Loading branch information
edmagne committed Jan 27, 2012
1 parent 1447146 commit bf0cc97
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/bet.rb
Expand Up @@ -28,7 +28,7 @@ class Bet < ActiveRecord::Base
acts_as_activity_provider :timestamp => "#{table_name}.created_at",
:find_options => {:include => [{:issue => :project}, :author]},
:author_key => :user_id,
:permission => :permission_bet
:permission => :issues_poll_bet


validates_presence_of :votes, :author, :issue
Expand Down
4 changes: 2 additions & 2 deletions lib/issues_poll_user_patch.rb
Expand Up @@ -32,13 +32,13 @@ module ClassMethods
module InstanceMethods
def polls_votes_project(project_id)
votes = poll_votes.find(:first, :conditions => ["project_id = ?", project_id])
votes.nil? ? nil : votes.votes
votes.nil? ? nil : votes.votes.to_i
end

def can_bet?(project_id, bet_votes)
project = Project.find(project_id)
available_votes = self.polls_votes_project(project_id)
project.enabled_module_names.include?('issues_poll') and available_votes and available_votes > bet_votes
project.enabled_module_names.include?('issues_poll') and available_votes and available_votes >= bet_votes
end

def votes_bet_by_issue(issue_id)
Expand Down

0 comments on commit bf0cc97

Please sign in to comment.