diff --git a/lib/site.rb b/lib/site.rb index eaecd91..846cbcd 100644 --- a/lib/site.rb +++ b/lib/site.rb @@ -20,6 +20,24 @@ class Site # Latest decisions page apps = ScraperWiki.select("* from `applications` order by date_decision desc limit 30") Petrify.page('decisions', 'decisions', { apps: apps }) + + # Appeals page + summary = ScraperWiki.select(" + authority_name, appeal_status, appeal_decision, count(*) as applications + from applications + where appeal_status is not null + and appeal_status != 'Unknown' + group by authority_name, appeal_status, appeal_decision + ") + + apps = ScraperWiki.select(" + * from applications + where appeal_status is not null + and appeal_status != 'Unknown' + ") + + Petrify.page('appeals', 'appeals', { summary: summary, apps: apps }) + Petrify.csv('appeals', 'inlink-appeals', apps) # Page and CSV file for each authority auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications") diff --git a/views/appeals.haml b/views/appeals.haml new file mode 100644 index 0000000..24b9527 --- /dev/null +++ b/views/appeals.haml @@ -0,0 +1,65 @@ +%h1 Appeals + +.warning + %p + The applicant has the right to appeal against a council's decision to refuse planning permission. An independent planning inspector reviews the case and decides whether to uphold the original decision or to overturn it. + + %p + Appeals are decided by the + %a( href = "https://www.gov.uk/government/organisations/planning-inspectorate")< + Planning Inspectorate for England and Wales, + the + %a( href = "https://www.dpea.scotland.gov.uk")< + Planning and Environmental Appeals Division of the Scottish government, + and the + %a( href = "https://www.pacni.gov.uk")< + Planning Appeals Commission for Northern Ireland. + +%h2 Summary + +%table#summary + %thead + %tr + %th Authority name + %th Appeal status + %th Appeal decision + %th Applications appealed + %tbody + - summary.each do |row| + %tr + %td.nowrap + %a{ href: authority_url(row['authority_name']) } + = row['authority_name'] + %td= cleanup(row['appeal_status']) + %td= cleanup(row['appeal_decision']) + %td.right= row['applications'] + +%h2 Appealed applications + +%p + - csv_fn = 'inlink-appeals.csv' + %a.button{ :href => csv_fn, :download => csv_fn } + Download CSV data + +%table#applications + %thead + %tr + %th Authority + %th Reference + %th Council decision + %th Address + %th Appeal status + %th Appeal decision + %tbody + - apps.each do |app| + %tr + %td.nowrap + %a{ href: authority_url(app['authority_name']) } + = app['authority_name'] + %td + %a{ href: app['info_url']} + = app['council_reference'] + %td.nowrap= short_date(app['date_decision']) + %td= app['address'] + %td= cleanup(app['appeal_status']) + %td= cleanup(app['appeal_decision']) diff --git a/views/layout.haml b/views/layout.haml index 5876be7..1bb7abe 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -18,6 +18,9 @@ %li %a{ :href => '/decisions/' }< Latest decisions + %li + %a{ :href => '/appeals/' }< + Appeals = yield %footer