Browse Source

Removed Candidacy.elected attribute as it was effectively a duplicate of Candidacy.seats

tags/last-sinatra-version
Adrian Short 12 years ago
parent
commit
b1c505eaa5
4 changed files with 7 additions and 11 deletions
  1. +1
    -5
      models.rb
  2. +4
    -4
      scripts/setpositions.rb
  3. +1
    -1
      views/candidate.haml
  4. +1
    -1
      views/district.haml

+ 1
- 5
models.rb View File

@@ -74,7 +74,6 @@ class Candidacy
property :address, String, :length => 200 property :address, String, :length => 200
property :postcode, String property :postcode, String
property :position, Integer property :position, Integer
property :elected, Boolean
property :seats, Integer property :seats, Integer


belongs_to :election belongs_to :election
@@ -141,10 +140,7 @@ class Party
property :name, String, :required => true property :name, String, :required => true
property :colour, String property :colour, String
has n, :candidates, :order => ['surname']
has n, :councilcandidates, :order => ['surname']
has n, :parliamentcandidates, :order => ['surname']
has n, :candidacies
end end


# These models are now redundant # These models are now redundant


+ 4
- 4
scripts/setpositions.rb View File

@@ -1,4 +1,4 @@
require './lib/models'
require_relative '../models'
require 'pp' require 'pp'


# Set position and elected for each candidacy # Set position and elected for each candidacy
@@ -10,10 +10,10 @@ Election.all.each do |election|
puts puts
pos = 1 pos = 1
cands.each do |cand| cands.each do |cand|
pos <= district.seats ? elected = true : elected = false
print cand.candidate.surname, ' ', cand.votes, ' ', pos, ' ', elected, "\n"
pos <= district.seats ? seats = 1 : seats = 0
print cand.candidate.surname, ' ', cand.votes, ' ', pos, ' ', seats, "\n"
cand.position = pos cand.position = pos
cand.elected = elected
cand.seats = seats
cand.save cand.save
pos += 1 pos += 1
end end


+ 1
- 1
views/candidate.haml View File

@@ -33,7 +33,7 @@
= ccy.district.body.district_name = ccy.district.body.district_name
%td.right= commify(ccy.votes) %td.right= commify(ccy.votes)
%td.right= to_ordinal(ccy.position) %td.right= to_ordinal(ccy.position)
%td= ccy.elected? ? "Elected" : "Not elected"
%td= ccy.seats == 1 ? "Elected" : "Not elected"
.warning .warning
This might not be the complete electoral history for this candidate. They might have stood in elections outside Sutton and / or in Sutton elections for which we don't have data. This might not be the complete electoral history for this candidate. They might have stood in elections outside Sutton and / or in Sutton elections for which we don't have data.

+ 1
- 1
views/district.haml View File

@@ -14,7 +14,7 @@
%h2 Candidates elected %h2 Candidates elected


- Election.all(:body => @district.body, :order => [:d.desc]).each do |election| - Election.all(:body => @district.body, :order => [:d.desc]).each do |election|
- ccys = Candidacy.all(:election_id => election.id, :district_id => @district.id, :elected => true, :order => [:votes.desc])
- ccys = Candidacy.all(:election_id => election.id, :district_id => @district.id, :seats => 1, :order => [:votes.desc])
- unless ccys == [] - unless ccys == []
%h3 %h3


Loading…
Cancel
Save