diff --git a/lib/helpers.rb b/lib/helpers.rb index 1d29c0d..9b2c8e5 100644 --- a/lib/helpers.rb +++ b/lib/helpers.rb @@ -21,6 +21,10 @@ def authority_url(authority_name) "/authorities/#{slug(authority_name)}/" end +def download_button(filename, label='Download CSV data') + "#{label}" +end + def normalise_decision(d) # https://schemas.opendata.esd.org.uk/PlanningApplications/LocalOpenDataIncentiveSchemePlanningApplicationsSchemaGuidance.pdf diff --git a/views/appeals.haml b/views/appeals.haml index 310b5e0..58a9451 100644 --- a/views/appeals.haml +++ b/views/appeals.haml @@ -36,10 +36,7 @@ %h2 Appealed applications -%p - - csv_fn = 'inlink-appeals.csv' - %a.button{ :href => csv_fn, :download => csv_fn } - Download CSV data +%p= download_button('inlink-appeals.csv') %table#applications %thead diff --git a/views/authority.haml b/views/authority.haml index 8ed18b8..6c08791 100644 --- a/views/authority.haml +++ b/views/authority.haml @@ -23,10 +23,7 @@ %h2 Applications -%p - - csv_fn = slug(auth['authority_name']) + '.csv' - %a.button{ :href => csv_fn, :download => csv_fn } - Download CSV data +%p= download_button(slug(auth['authority_name']) + '.csv') %table#applications %thead diff --git a/views/index.haml b/views/index.haml index 30b9f95..e2652fe 100644 --- a/views/index.haml +++ b/views/index.haml @@ -2,10 +2,7 @@ %p.warning There are typically two applications per kiosk: one for full planning permission or telecoms prior approval, and one for advertisement consent. So the number of kiosks applied for is half the number of applications. -%p - - csv_fn = 'inlink-summary.csv' - %a.button{ :href => csv_fn, :download => csv_fn } - Download summary CSV data +%p= download_button('inlink-summary.csv') %table#summary %thead