Browse Source

Bugfix. Check all candidacies have got votes for this poll.

tags/last-sinatra-version
Adrian Short 6 years ago
parent
commit
45cb023daf
1 changed files with 1 additions and 3 deletions
  1. +1
    -3
      models.rb

+ 1
- 3
models.rb View File

@@ -40,9 +40,7 @@ class Poll
# Returns array of candidacies, or false if we don't have results for this poll
def set_positions
# Check that every candidacy for this poll has its votes recorded (ie that the election results are known)
if Candidacy.count(:conditions => { :district_id => @district_id, :election_id => @election_id, :votes => nil }) == 0
return false
end
return false if Candidacy.count(:conditions => { :district_id => @district_id, :election_id => @election_id, :votes => nil }) > 0

# Get the candidacies for this poll
ccys = Candidacy.all(:conditions => { :district_id => @district_id, :election_id => @election_id }, :order => [:votes.desc])


Loading…
Cancel
Save