Browse Source

Added explanatory message to home page

pull/3/head
Adrian Short 14 years ago
parent
commit
ab32013424
4 changed files with 58 additions and 3 deletions
  1. +13
    -0
      app.rb
  2. +9
    -0
      public/style.css
  3. +22
    -1
      views/home.haml
  4. +14
    -2
      views/service.haml

+ 13
- 0
app.rb View File

@@ -6,6 +6,14 @@ require 'lib/models'


get '/' do get '/' do
@directorates = Directorate.all( :order => ['name'] ) @directorates = Directorate.all( :order => ['name'] )
# @payments_count = Payment.all.size
# @suppliers_count = Supplier.all.size
@results = repository(:default).adapter.query("SELECT COUNT(*) FROM payments")
@payments_count = @results[0]
@results = repository(:default).adapter.query("SELECT COUNT(*) FROM suppliers")
@suppliers_count = @results[0]
@results = repository(:default).adapter.query("SELECT COUNT(*) FROM services")
@services_count = @results[0]
haml :home haml :home
end end


@@ -61,6 +69,11 @@ end
get '/services/:slug' do get '/services/:slug' do
@service = Service.first(:slug => params[:slug]) @service = Service.first(:slug => params[:slug])
@total = @service.payments.sum(:amount) @total = @service.payments.sum(:amount)
@count = @service.payments.size
@avg = @service.payments.avg(:amount)
@max = @service.payments.max(:amount)
@min = @service.payments.min(:amount)

haml :service haml :service
end end




+ 9
- 0
public/style.css View File

@@ -134,3 +134,12 @@ tr
background-color: #eee; background-color: #eee;
color: red; color: red;
} }

.callout
{

background-color: beige;
padding: 0px;
font-size: 150%;
line-height: 1.5em;
}

+ 22
- 1
views/home.haml View File

@@ -1,11 +1,32 @@
.grid_12 .grid_12


-#
%ul#breadcrumb %ul#breadcrumb
%li.home %li.home

.clear

.grid_6
%h2 Directorates %h2 Directorates
- for directorate in @directorates - for directorate in @directorates
%p %p
%a{ :href=> "/directorates/#{directorate.slug}" } %a{ :href=> "/directorates/#{directorate.slug}" }
= directorate.name = directorate.name

.grid_6
.callout
%p
Armchair Auditor lets you see how your council spends your money.
%p
We've got
= @payments_count
payments from
%a{ :href => "/services" }
= @services_count
services
at the Royal Borough of Windsor and Maidenhead to
%a{ :href => "/suppliers" }
= @suppliers_count
suppliers.

+ 14
- 2
views/service.haml View File

@@ -24,7 +24,7 @@
- for payment in @service.payments - for payment in @service.payments
%tr %tr
%td= payment.d.strftime("%d %b %Y") %td= payment.d.strftime("%d %b %Y")
%td
%td.right
%a{ :href => "/payments/#{payment.id}" } %a{ :href => "/payments/#{payment.id}" }
= payment.id = payment.id
%td %td
@@ -42,5 +42,17 @@
%td %td
%strong TOTAL %strong TOTAL
%td.right= sprintf("%0d", @total) %td.right= sprintf("%0d", @total)
%table
%tr
%th.right Count
%th.right Max
%th.right Min
%th.right Average

%tr
%td.right= @count
%td.right= sprintf("%0d", @max)
%td.right= sprintf("%0d", @min)
%td.right= sprintf("%0d", @avg)

Loading…
Cancel
Save