Selaa lähdekoodia

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

tags/last-sinatra-version
Adrian Short 12 vuotta sitten
vanhempi
commit
b1c505eaa5
4 muutettua tiedostoa jossa 7 lisäystä ja 11 poistoa
  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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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


Ladataan…
Peruuta
Tallenna