From 441a1911c48bc3d39fd3201a52b8b96484a46be3 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 8 Apr 2021 11:15:24 +0300 Subject: [PATCH] refactoring --- app/models/domain.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index e1e9777616..0348e8b34f 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -559,16 +559,24 @@ def delete_prohibited? statuses.include?(DomainStatus::FORCE_DELETE) end + def update_unless_locked_by_registrant(update) + update(admin_store_statuses_history: update) unless locked_by_registrant? + end + + def update_not_by_locked_statuses(update) + return unless locked_by_registrant? + + result = update.reject { |status| LOCK_STATUSES.include? status } + update(admin_store_statuses_history: result) + end + # special handling for admin changing status def admin_status_update(update) - # check for deleted status - update(admin_store_statuses_history: update) unless locked_by_registrant? + update_unless_locked_by_registrant(update) - if locked_by_registrant? - result = update.reject { |status| LOCK_STATUSES.include? status } - update(admin_store_statuses_history: result) - end - + update_not_by_locked_statuses(update) + + # check for deleted status statuses.each do |s| unless update.include? s case s