diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 043223ef9..41213ba9c 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -239,7 +239,7 @@ private end def authenticate_scope! - if %w[create new download_lettings_csv email_lettings_csv email_sales_csv download_sales_csv].include? action_name + if %w[create new lettings_logs sales_logs download_lettings_csv email_lettings_csv email_sales_csv download_sales_csv].include? action_name head :unauthorized and return unless current_user.support? elsif current_user.organisation != @organisation && !current_user.support? render_not_found diff --git a/app/helpers/logs_helper.rb b/app/helpers/logs_helper.rb index 12bca5d24..f1c3760c6 100644 --- a/app/helpers/logs_helper.rb +++ b/app/helpers/logs_helper.rb @@ -3,15 +3,6 @@ module LogsHelper case controller.class.name when "LettingsLogsController" then "lettings" when "SalesLogsController" then "sales" - else - raise "Log type not found for #{controller.class}" - end - end - - def page_title - case controller.class.name - when "LettingsLogsController" then "Lettings logs" - when "SalesLogsController" then "Sales logs" else case action_name when "lettings_logs" then "Lettings logs" diff --git a/app/helpers/navigation_items_helper.rb b/app/helpers/navigation_items_helper.rb index 5597b2e0f..6cacaaa18 100644 --- a/app/helpers/navigation_items_helper.rb +++ b/app/helpers/navigation_items_helper.rb @@ -12,9 +12,9 @@ module NavigationItemsHelper ].compact else [ - NavigationItem.new("Lettings logs", lettings_logs_organisation_path(current_user.organisation), lettings_logs_current?(path)), - NavigationItem.new("Sales logs", sales_logs_organisation_path(current_user.organisation), sales_logs_current?(path)), - (NavigationItem.new("Schemes", schemes_organisation_path(current_user.organisation), non_support_supported_housing_schemes_current?(path)) if current_user.organisation.holds_own_stock? || current_user.organisation.stock_owners.present?), + NavigationItem.new("Lettings logs", lettings_logs_path, lettings_logs_current?(path)), + NavigationItem.new("Sales logs", sales_logs_path, sales_logs_current?(path)), + (NavigationItem.new("Schemes", schemes_path, non_support_supported_housing_schemes_current?(path)) if current_user.organisation.holds_own_stock? || current_user.organisation.stock_owners.present?), NavigationItem.new("Users", users_organisation_path(current_user.organisation), subnav_users_path?(path)), NavigationItem.new("About your organisation", details_organisation_path(current_user.organisation.id), subnav_details_path?(path)), NavigationItem.new("Stock owners", stock_owners_organisation_path(current_user.organisation), stock_owners_path?(path)), diff --git a/app/views/logs/index.html.erb b/app/views/logs/index.html.erb index edc87d562..b0f7de6e0 100644 --- a/app/views/logs/index.html.erb +++ b/app/views/logs/index.html.erb @@ -1,5 +1,5 @@ <% item_label = format_label(@pagy.count, "logs") %> -<% title = format_title(@searched, page_title, current_user, item_label, @pagy.count, nil) %> +<% title = format_title(@searched, "#{log_type_for_controller(controller).capitalize} logs", current_user, item_label, @pagy.count, nil) %> <% content_for :title, title %> diff --git a/app/views/organisations/logs.html.erb b/app/views/organisations/logs.html.erb index d84a2c2d8..d7dce249a 100644 --- a/app/views/organisations/logs.html.erb +++ b/app/views/organisations/logs.html.erb @@ -1,5 +1,5 @@ <% item_label = format_label(@pagy.count, "logs") %> -<% title = format_title(@searched, page_title, current_user, item_label, @pagy.count, @organisation.name) %> +<% title = format_title(@searched, "#{log_type_for_controller(controller).capitalize} logs", current_user, item_label, @pagy.count, @organisation.name) %> <% content_for :title, title %>