Bläddra i källkod

Gracefully handle elections for which we don't yet have results

tags/last-sinatra-version
Adrian Short 10 år sedan
förälder
incheckning
0ec28551af
1 ändrade filer med 31 tillägg och 12 borttagningar
  1. +31
    -12
      views/resultsdistrict.haml

+ 31
- 12
views/resultsdistrict.haml Visa fil

@@ -33,6 +33,12 @@

%h1= @district.name + " " + @district.body.district_name

- @election_held = Candidacy.sum(:votes, :election => @election, :district => @district)

- unless @election_held
.warning
We don't have the results for this election yet.

%h2 Votes by party

%table
@@ -53,16 +59,26 @@
%td.right= count
%td{ :style => "background-color: #{row['party_colour'] }" }  
%td= row['party_name']
%td.right.highlight= row['num_seats']
- if @election_held
%td.right.highlight= row['num_seats']
- else
%td.right.highlight —
%td.right= row['num_candidates']
%td.right= commify(row['total_votes'])
%td.right= format_percent(row['total_votes'].to_f / @total_votes * 100)
- if @election_held
%td.right= commify(row['total_votes'])
%td.right= format_percent(row['total_votes'].to_f / @total_votes * 100)
- else
%td.right —
%td.right —
%tr.footer
%td  
%td  
%td  
%td.right.highlight= @total_seats
- if @election_held
%td.right.highlight= @total_seats
- else
%td.right.highlight  
%td.right= @total_candidates
%td.right= commify(@total_votes)
%td  
@@ -91,15 +107,18 @@
= candidacy.candidate.short_name
%td.org
= party_name(candidacy.labcoop, candidacy.party.name)
%td.right= commify(candidacy.votes)
%td.right= format_percent(candidacy.votes.to_f / @total_votes * 100)
- if candidacy.seats == 1
%td.elected="Elected"
- if @election_held
%td.right= commify(candidacy.votes)
%td.right= format_percent(candidacy.votes.to_f / @total_votes * 100)
- if candidacy.seats == 1
%td.elected="Elected"
- else
%td  
- else
%td  
%td.right —
%td.right —
%td

%tr.footer
%td  


Laddar…
Avbryt
Spara