Procházet zdrojové kódy

Added results pages for parliamentary elections

tags/last-sinatra-version
Adrian Short před 14 roky
rodič
revize
8526d3eedc
4 změnil soubory, kde provedl 34 přidání a 8 odebrání
  1. +12
    -0
      app.rb
  2. +12
    -7
      lib/models.rb
  3. +10
    -0
      public/style.css
  4. +0
    -1
      views/home.haml

+ 12
- 0
app.rb Zobrazit soubor

@@ -42,6 +42,18 @@ get '/wards/?' do
haml :wardlist
end

get '/results/uk-parliament/2010-05-06/:constituency' do
if params[:constituency] == 'carshalton-and-wallington'
const = 1
else
const = 2
end
@constituency = Constituency.get(const)
@candidates = Parliamentcandidate.all(:constituency_id => const, :order => [ :votes_2010.desc ])
@total_2010 = Parliamentcandidate.sum(:votes_2010, :constituency_id => const)
haml :resultsukparliament
end

get '/how-the-council-election-works' do
haml :election
end


+ 12
- 7
lib/models.rb Zobrazit soubor

@@ -1,6 +1,7 @@
require 'dm-core'
require 'dm-validations'
require 'dm-timestamps'
require 'dm-aggregates'
require 'pat'

class Postcode
@@ -91,13 +92,17 @@ end
class Parliamentcandidate
include DataMapper::Resource
property :id, Serial
property :constituency_id, Integer, :required => true
property :party_id, Integer, :required => true
property :forenames, String, :required => true
property :surname, String, :required => true
property :address, String, :length => 200
property :postcode, String
property :id, Serial
property :constituency_id, Integer, :required => true
property :party_id, Integer, :required => true
property :forenames, String, :required => true
property :surname, String, :required => true
property :address, String, :length => 200
property :postcode, String
property :votes_2010, Integer
property :votes_2005, Integer
property :percent_2005, Float

belongs_to :party
belongs_to :constituency


+ 10
- 0
public/style.css Zobrazit soubor

@@ -101,4 +101,14 @@ form
strong
{
color: #000;
}

td, th
{
padding: 0 15px 15px 0;
}

.right
{
text-align: right;
}

+ 0
- 1
views/home.haml Zobrazit soubor

@@ -22,4 +22,3 @@
%input{ :type => 'submit', :value => "Find it" }
.grid_3
<iframe src="http://www.thestraightchoice.org/api/call.php?method=constituency&output=html&constituency=sutton_and_cheam&count=2" style="border:none; overflow:hidden;height: 800px;"></iframe>

Načítá se…
Zrušit
Uložit