From 70099a37ac77156c88eeac161ed3233744f157c2 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Wed, 5 Apr 2023 11:22:22 +0100 Subject: [PATCH] locations and schemes only affect visible logs --- app/controllers/locations_controller.rb | 4 ++-- app/controllers/schemes_controller.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 5b39fa875..50102ee17 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -158,7 +158,7 @@ class LocationsController < ApplicationController end def deactivate_confirm - @affected_logs = @location.lettings_logs.filter_by_before_startdate(params[:deactivation_date]) + @affected_logs = @location.lettings_logs.visible.filter_by_before_startdate(params[:deactivation_date]) if @affected_logs.count.zero? deactivate else @@ -260,7 +260,7 @@ private end def reset_location_and_scheme_for_logs! - logs = @location.lettings_logs.filter_by_before_startdate(params[:deactivation_date].to_time) + logs = @location.lettings_logs.visible.filter_by_before_startdate(params[:deactivation_date].to_time) logs.update!(location: nil, scheme: nil, unresolved: true) logs end diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index d23c3a8ee..f248bffe5 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -39,7 +39,7 @@ class SchemesController < ApplicationController end def deactivate_confirm - @affected_logs = @scheme.lettings_logs.filter_by_before_startdate(params[:deactivation_date]) + @affected_logs = @scheme.lettings_logs.visible.filter_by_before_startdate(params[:deactivation_date]) if @affected_logs.count.zero? deactivate else @@ -310,7 +310,7 @@ private end def reset_location_and_scheme_for_logs! - logs = @scheme.lettings_logs.filter_by_before_startdate(params[:deactivation_date].to_time) + logs = @scheme.lettings_logs.visible.filter_by_before_startdate(params[:deactivation_date].to_time) logs.update!(location: nil, scheme: nil, unresolved: true) logs end