Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Hasjanov committed Apr 8, 2021
1 parent 1cc6f25 commit 441a191
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions app/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 441a191

Please sign in to comment.