Browse Source

Use Rails routes instead of absolute paths for CSV download links

pull/851/head
James Rose 3 years ago
parent
commit
015347bd2c
  1. 4
      app/controllers/lettings_logs_controller.rb
  2. 2
      app/views/lettings_logs/_log_list.html.erb
  3. 4
      app/views/lettings_logs/csv_confirmation.html.erb
  4. 2
      app/views/lettings_logs/index.html.erb
  5. 2
      app/views/organisations/logs.html.erb

4
app/controllers/lettings_logs_controller.rb

@ -100,9 +100,7 @@ class LettingsLogsController < ApplicationController
redirect_to csv_confirmation_lettings_logs_path
end
def csv_confirmation
render "csv_confirmation"
end
def csv_confirmation; end
private

2
app/views/lettings_logs/_log_list.html.erb

@ -1,6 +1,6 @@
<h2 class="govuk-body">
<%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "logs", path: request.path)) %>
<%= govuk_link_to "Download (CSV)", "#{request.path}/csv-download?search=#{@search_term}", type: "text/csv" %>
<%= govuk_link_to "Download (CSV)", csv_download_url, type: "text/csv" %>
</h2>
<% lettings_logs.map do |log| %>

4
app/views/lettings_logs/csv_confirmation.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "CSV Confirmation" %>
<% content_for :title, "We've sending you an email" %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= govuk_panel(title_text: "We're sending you an email") %>
@ -9,7 +9,7 @@
<p class="govuk-body">Open your email inbox and click the link to download your CSV file.</p>
<p class="govuk-body">
<%= govuk_link_to "Return to logs", "#{request.path}/.." %>
<%= govuk_link_to "Return to logs", lettings_logs_path %>
</p>
</div>
</div>

2
app/views/lettings_logs/index.html.erb

@ -15,7 +15,7 @@
<div class="app-filter-layout__content">
<%= render SearchComponent.new(current_user:, search_label: "Search by log ID, tenant code, property reference or postcode", value: @searched) %>
<%= govuk_section_break(visible: true, size: "m") %>
<%= render partial: "log_list", locals: { lettings_logs: @lettings_logs, title: "Logs", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %>
<%= render partial: "log_list", locals: { lettings_logs: @lettings_logs, title: "Logs", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, csv_download_url: csv_download_lettings_logs_path(search: @search_term) } %>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "logs" } %>
</div>
</div>

2
app/views/organisations/logs.html.erb

@ -21,7 +21,7 @@
<div class="app-filter-layout__content">
<%= render SearchComponent.new(current_user:, search_label: "Search by log ID, tenant code, property reference or postcode", value: @searched) %>
<%= govuk_section_break(visible: true, size: "m") %>
<%= render partial: "lettings_logs/log_list", locals: { lettings_logs: @lettings_logs, title: "Logs", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %>
<%= render partial: "lettings_logs/log_list", locals: { lettings_logs: @lettings_logs, title: "Logs", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, csv_download_url: logs_csv_download_organisation_path(@organisation, search: @search_term) } %>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "logs" } %>
</div>
</div>

Loading…
Cancel
Save