瀏覽代碼

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

tags/last-sinatra-version
Adrian Short 12 年之前
父節點
當前提交
b1c505eaa5
共有 4 個文件被更改,包括 7 次插入11 次删除
  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 查看文件

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

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

# These models are now redundant


+ 4
- 4
scripts/setpositions.rb 查看文件

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

# Set position and elected for each candidacy
@@ -10,10 +10,10 @@ Election.all.each do |election|
puts
pos = 1
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.elected = elected
cand.seats = seats
cand.save
pos += 1
end


+ 1
- 1
views/candidate.haml 查看文件

@@ -33,7 +33,7 @@
= ccy.district.body.district_name
%td.right= commify(ccy.votes)
%td.right= to_ordinal(ccy.position)
%td= ccy.elected? ? "Elected" : "Not elected"
%td= ccy.seats == 1 ? "Elected" : "Not elected"
.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.

+ 1
- 1
views/district.haml 查看文件

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

- 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 == []
%h3


Loading…
取消
儲存