From 6f970e581b086e7a52938581aa41c26d79300eeb Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Wed, 23 Apr 2014 10:45:08 +0100 Subject: [PATCH] Merge Labour/Co-operative candidacies into Labour. Fixes #12 --- app.rb | 5 +++++ models.rb | 1 + views/candidate.haml | 2 +- views/resultsdistrict.haml | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app.rb b/app.rb index e03f1ca..61f9713 100644 --- a/app.rb +++ b/app.rb @@ -54,6 +54,11 @@ helpers do d.strftime("%e %B %Y") end + # Exception for Labour/Co-operative candidacies + def party_name(labcoop, party_name) + labcoop ? "Labour and Co-operative Party" : party_name + end + end get '/' do diff --git a/models.rb b/models.rb index f7fecb6..f2757dc 100644 --- a/models.rb +++ b/models.rb @@ -88,6 +88,7 @@ class Candidacy property :postcode, String 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 :labcoop, Boolean # Candidacy is for joint Labour/Co-op party belongs_to :election belongs_to :candidate diff --git a/views/candidate.haml b/views/candidate.haml index 9825a8e..8392ae0 100644 --- a/views/candidate.haml +++ b/views/candidate.haml @@ -24,7 +24,7 @@ %a{ :href => "/bodies/#{ccy['body_slug']}/elections/#{ccy['d']}" } -# Postgres returns ccy['d'] as a Date and sqlite returns it as a String = long_date(ccy['d'].to_time) - %td= ccy['party_name'] + %td= party_name(ccy['labcoop'], ccy['party_name']) %td %a{ :href => "/bodies/#{ccy['body_slug']}" } = ccy['body_name'] diff --git a/views/resultsdistrict.haml b/views/resultsdistrict.haml index ff0cfb0..f2f5c0b 100644 --- a/views/resultsdistrict.haml +++ b/views/resultsdistrict.haml @@ -81,7 +81,7 @@ %th   - count = 0 - - for candidacy in @candidacies + - @candidacies.each do |candidacy| - count += 1 %tr.vcard %td= count @@ -90,7 +90,7 @@ %a{ :href => "/candidates/#{candidacy.candidate.id}" } = candidacy.candidate.short_name %td.org - = candidacy.party.name + = party_name(candidacy.labcoop, candidacy.party.name) %td.right= commify(candidacy.votes)