| @@ -54,6 +54,11 @@ helpers do | |||||
| d.strftime("%e %B %Y") | d.strftime("%e %B %Y") | ||||
| end | end | ||||
| # Exception for Labour/Co-operative candidacies | |||||
| def party_name(labcoop, party_name) | |||||
| labcoop ? "Labour and Co-operative Party" : party_name | |||||
| end | |||||
| end | end | ||||
| get '/' do | get '/' do | ||||
| @@ -88,6 +88,7 @@ class Candidacy | |||||
| property :postcode, String | property :postcode, String | ||||
| property :position, Integer # Position of this candidate in this district. (1..n) | property :position, Integer # Position of this candidate in this district. (1..n) | ||||
| property :seats, Integer # Number of seats won by this candidacy (0 or 1) | property :seats, Integer # Number of seats won by this candidacy (0 or 1) | ||||
| property :labcoop, Boolean # Candidacy is for joint Labour/Co-op party | |||||
| belongs_to :election | belongs_to :election | ||||
| belongs_to :candidate | belongs_to :candidate | ||||
| @@ -24,7 +24,7 @@ | |||||
| %a{ :href => "/bodies/#{ccy['body_slug']}/elections/#{ccy['d']}" } | %a{ :href => "/bodies/#{ccy['body_slug']}/elections/#{ccy['d']}" } | ||||
| -# Postgres returns ccy['d'] as a Date and sqlite returns it as a String | -# Postgres returns ccy['d'] as a Date and sqlite returns it as a String | ||||
| = long_date(ccy['d'].to_time) | = long_date(ccy['d'].to_time) | ||||
| %td= ccy['party_name'] | |||||
| %td= party_name(ccy['labcoop'], ccy['party_name']) | |||||
| %td | %td | ||||
| %a{ :href => "/bodies/#{ccy['body_slug']}" } | %a{ :href => "/bodies/#{ccy['body_slug']}" } | ||||
| = ccy['body_name'] | = ccy['body_name'] | ||||
| @@ -81,7 +81,7 @@ | |||||
| %th | %th | ||||
| - count = 0 | - count = 0 | ||||
| - for candidacy in @candidacies | |||||
| - @candidacies.each do |candidacy| | |||||
| - count += 1 | - count += 1 | ||||
| %tr.vcard | %tr.vcard | ||||
| %td= count | %td= count | ||||
| @@ -90,7 +90,7 @@ | |||||
| %a{ :href => "/candidates/#{candidacy.candidate.id}" } | %a{ :href => "/candidates/#{candidacy.candidate.id}" } | ||||
| = candidacy.candidate.short_name | = candidacy.candidate.short_name | ||||
| %td.org | %td.org | ||||
| = candidacy.party.name | |||||
| = party_name(candidacy.labcoop, candidacy.party.name) | |||||
| %td.right= commify(candidacy.votes) | %td.right= commify(candidacy.votes) | ||||