diff --git a/app/controllers/lettings_logs_controller.rb b/app/controllers/lettings_logs_controller.rb index 0c2b9e3f4..030b9aacd 100644 --- a/app/controllers/lettings_logs_controller.rb +++ b/app/controllers/lettings_logs_controller.rb @@ -54,7 +54,7 @@ class LettingsLogsController < LogsController @log = current_user.lettings_logs.find_by(id: params[:id]) if @log if @log.unresolved - redirect_to(send("lettings_log_#{@log.form.unresolved_log_redirect_page_id}_path", @log)) + redirect_to(send(@log.form.unresolved_log_path, @log)) else render("logs/edit", locals: { current_user: }) end @@ -116,7 +116,7 @@ private end def resolve_logs! - if @log&.unresolved == true && @log.location.present? && @log.scheme.present? && @log.update(unresolved: false) + if @log&.unresolved && @log.location.present? && @log.scheme.present? && @log&.update(unresolved: false) unresolved_logs_count_for_user = current_user.lettings_logs.unresolved.created_by(current_user).count flash.now[:notice] = helpers.flash_notice_for_resolved_logs(unresolved_logs_count_for_user) end diff --git a/app/models/form.rb b/app/models/form.rb index 74ac0c8be..f597c8c0e 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -87,6 +87,10 @@ class Form "#{log.class.name.underscore}_#{page.subsection.id}_check_answers_path" end + def unresolved_log_path + "#{form_type}_#{unresolved_log_redirect_page_id}_path" + end + def next_incomplete_section_redirect_path(subsection, log) subsection_ids = subsections.map(&:id) diff --git a/app/views/logs/index.html.erb b/app/views/logs/index.html.erb index c770a9e20..3f0d2031d 100644 --- a/app/views/logs/index.html.erb +++ b/app/views/logs/index.html.erb @@ -12,7 +12,7 @@ ) do |notification_banner| %> <% notification_banner.heading(text: "A scheme has changed and it has affected #{@unresolved_count} #{'log'.pluralize(@unresolved_count)}") %>
- Update logs + <%= govuk_link_to "Update logs", update_logs_lettings_logs_path, class: "govuk-notification-banner__link" %>
<% end %> <% end %> diff --git a/app/views/logs/update_logs.html.erb b/app/views/logs/update_logs.html.erb index 4546d1041..1b744beb6 100644 --- a/app/views/logs/update_logs.html.erb +++ b/app/views/logs/update_logs.html.erb @@ -35,7 +35,7 @@ scope: "row", class: "govuk-!-text-align-right", }) do %> - <%= govuk_link_to("Update now", send("lettings_log_#{log.form.unresolved_log_redirect_page_id}_path", log)) %> + <%= govuk_link_to("Update now", send(log.form.unresolved_log_path, log)) %> <% end %> <% end %> <% end %>