- @page_title = "#{@district.name} #{@district.body.district_name}, #{@district.body.name}"

.nav
  %p
    %a{ :href => "/bodies/#{@district.body.slug}" }
      &laquo;&nbsp;
      = @district.body.name

%h1= "#{@district.name} #{@district.body.district_name}"

-#
  - @election = Election.get(9) # FIXME magic number

  %h2
    = @district.name
    ward candidates for the
    %a{ :href => "/bodies/#{@election.body.slug}/elections/#{@election.d}"}
      = @election.body.name
      election on
      = long_date(@election.d)

%table
  - Candidacy.all(:election => @election, :district => @district, :order => [:party_id]).each do |c|
    - campaign = Campaign.first(:party => c.party, :election => @election)
    %tr.vcard
      %td{ :style => "background-color: #{c.party.colour}" } &nbsp;
      %td.candidate_name.fn
        %a{ :href => "/candidates/#{c.candidate.id}" }
          = c.candidate.short_name
      %td.org
        - if campaign && campaign.party_url
          %a{ :href => campaign.party_url }
            = party_name(c.labcoop, c.party.name)
        - else
          = party_name(c.labcoop, c.party.name)
      %td
        - if campaign && campaign.manifesto_html_url
          %a{ :href => campaign.manifesto_html_url }
            manifesto
        - else
          &nbsp;

-# TODO % turnout plotted over time
-# TODO map of district shown within Sutton boundary

%h2
  Candidates elected previously in
  = @district.name
  = @district.body.district_name

- Election.all(:body => @district.body, :order => [:d.desc]).each do |election|
  - ccys = Candidacy.all(:election_id => election.id, :district_id => @district.id, :seats => 1, :order => [:votes.desc])
  
  - unless ccys == []  
    %h3
      %a{ :href => "/bodies/#{@district.body.slug}/elections/#{election.d}/#{election.body.districts_name}/#{@district.slug}"}
        = long_date election.d
        = election.kind
  
    %table
      %tr
        %th
        %th
        %th
        %th
  
      - ccys.each do |ccy|
        %tr
          %td= ccy.position
          %td{ :style => "background-color: #{ccy.party.colour}" } &nbsp;
          %td
            %a{ :href => "/candidates/#{ccy.candidate.id}" }
              = ccy.candidate.short_name
          %td= ccy.party.name
          