Kaynağa Gözat

Added explanatory message to home page

pull/3/head
Adrian Short 14 yıl önce
ebeveyn
işleme
ab32013424
4 değiştirilmiş dosya ile 58 ekleme ve 3 silme
  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 Dosyayı Görüntüle

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

get '/' do
@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
end

@@ -61,6 +69,11 @@ end
get '/services/:slug' do
@service = Service.first(:slug => params[:slug])
@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
end



+ 9
- 0
public/style.css Dosyayı Görüntüle

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

.callout
{

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

+ 22
- 1
views/home.haml Dosyayı Görüntüle

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

-#
%ul#breadcrumb
%li.home

.clear

.grid_6
%h2 Directorates
- for directorate in @directorates
%p
%a{ :href=> "/directorates/#{directorate.slug}" }
= 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 Dosyayı Görüntüle

@@ -24,7 +24,7 @@
- for payment in @service.payments
%tr
%td= payment.d.strftime("%d %b %Y")
%td
%td.right
%a{ :href => "/payments/#{payment.id}" }
= payment.id
%td
@@ -42,5 +42,17 @@
%td
%strong 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)

Yükleniyor…
İptal
Kaydet