From 42942540a89ba3b72a97879345057a1a80c2bf12 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Thu, 25 May 2023 16:09:47 +0100 Subject: [PATCH] feat: add a few more missing log_filter_managers --- app/controllers/lettings_logs_controller.rb | 2 +- app/controllers/organisations_controller.rb | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/controllers/lettings_logs_controller.rb b/app/controllers/lettings_logs_controller.rb index 7d352460f..3ca0aa104 100644 --- a/app/controllers/lettings_logs_controller.rb +++ b/app/controllers/lettings_logs_controller.rb @@ -94,7 +94,7 @@ class LettingsLogsController < LogsController def email_csv all_orgs = params["organisation_select"] == "all" - EmailCsvJob.perform_later(current_user, search_term, @session_filters, all_orgs, nil, codes_only_export?) + EmailCsvJob.perform_later(current_user, search_term, @log_filter_manager.applied_filters, all_orgs, nil, codes_only_export?) redirect_to csv_confirmation_lettings_logs_path end diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index db31fb12a..8aa97a153 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -8,6 +8,7 @@ class OrganisationsController < ApplicationController before_action :authenticate_scope!, except: [:index] before_action -> { session_filters(specific_org: true) }, if: -> { current_user.support? || current_user.organisation.has_managing_agents? }, only: %i[lettings_logs sales_logs email_lettings_csv download_lettings_csv email_sales_csv download_sales_csv] before_action :set_session_filters, if: -> { current_user.support? || current_user.organisation.has_managing_agents? }, only: %i[lettings_logs sales_logs email_lettings_csv download_lettings_csv email_sales_csv download_sales_csv] + before_action :log_filter_manager, if: -> { current_user.support? || current_user.organisation.has_managing_agents? }, only: %i[lettings_logs sales_logs email_lettings_csv download_lettings_csv email_sales_csv download_sales_csv] def index redirect_to organisation_path(current_user.organisation) unless current_user.support? @@ -91,7 +92,7 @@ class OrganisationsController < ApplicationController def lettings_logs organisation_logs = LettingsLog.visible.where(owning_organisation_id: @organisation.id) - unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @session_filters) + unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @log_filter_manager.applied_filters) respond_to do |format| format.html do @@ -107,7 +108,7 @@ class OrganisationsController < ApplicationController def download_lettings_csv organisation_logs = LettingsLog.visible.where(owning_organisation_id: @organisation.id) - unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @session_filters) + unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @log_filter_manager.applied_filters) codes_only = params.require(:codes_only) == "true" render "logs/download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: lettings_logs_email_csv_organisation_path, codes_only: } @@ -120,7 +121,7 @@ class OrganisationsController < ApplicationController def sales_logs organisation_logs = SalesLog.where(owning_organisation_id: @organisation.id) - unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @session_filters) + unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @log_filter_manager.applied_filters) respond_to do |format| format.html do @@ -140,7 +141,7 @@ class OrganisationsController < ApplicationController def download_sales_csv organisation_logs = SalesLog.visible.where(owning_organisation_id: @organisation.id) - unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @session_filters) + unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @log_filter_manager.applied_filters) codes_only = params.require(:codes_only) == "true" render "logs/download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: sales_logs_email_csv_organisation_path, codes_only: } @@ -157,6 +158,10 @@ class OrganisationsController < ApplicationController private + def log_filter_manager + @log_filter_manager = LogsFilterManager.new(@session_filters, current_user) + end + def org_params params.require(:organisation).permit(:name, :address_line1, :address_line2, :postcode, :phone, :holds_own_stock, :provider_type, :housing_registration_no) end