mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
refactoring
This commit is contained in:
parent
4501463434
commit
419e5a587d
3 changed files with 29 additions and 9 deletions
|
@ -16,19 +16,39 @@ class ReplaceUpdToObjUpdProhibitedJob < ApplicationJob
|
|||
domain_batches.each do |domain|
|
||||
if domain.locked_by_registrant?
|
||||
if rollback
|
||||
domain.statuses = domain.statuses + ["serverUpdateProhibited"] if mode == 'add' and !domain.statuses.include? "serverUpdateProhibited"
|
||||
domain.statuses = domain.statuses - ["serverObjUpdateProhibited"] if mode == 'remove' and domain.statuses.include? "serverObjUpdateProhibited"
|
||||
domain = rollback_actions(mode, domain)
|
||||
else
|
||||
domain.statuses = domain.statuses + ["serverObjUpdateProhibited"] if mode == 'add' and !domain.statuses.include? "serverObjUpdateProhibited"
|
||||
domain.statuses = domain.statuses - ["serverUpdateProhibited"] if mode == 'remove' and domain.statuses.include? "serverUpdateProhibited"
|
||||
domain = add_actions(mode, domain)
|
||||
end
|
||||
|
||||
domain.save!
|
||||
end
|
||||
end
|
||||
|
||||
logger.info "Successfully proccesed #{count} domains of #{Domain.count}"
|
||||
end
|
||||
end
|
||||
|
||||
def rollback_actions(mode, domain)
|
||||
if mode == 'add' and !domain.statuses.include? 'serverUpdateProhibited'
|
||||
domain.statuses = domain.statuses + ['serverUpdateProhibited']
|
||||
elsif mode == 'remove' and domain.statuses.include? 'serverObjUpdateProhibited'
|
||||
domain.statuses = domain.statuses - ['serverObjUpdateProhibited']
|
||||
end
|
||||
|
||||
domain
|
||||
end
|
||||
|
||||
def add_actions(mode, domain)
|
||||
if mode == 'add' and !domain.statuses.include? 'serverObjUpdateProhibited'
|
||||
domain.statuses = domain.statuses + ['serverObjUpdateProhibited']
|
||||
elsif mode == 'remove' and domain.statuses.include? 'serverUpdateProhibited'
|
||||
domain.statuses = domain.statuses - ['serverUpdateProhibited']
|
||||
end
|
||||
|
||||
domain
|
||||
end
|
||||
|
||||
def logger
|
||||
@logger ||= Logger.new(Rails.root.join('log/migrate_before_force_delete_statuses.log'))
|
||||
end
|
||||
|
|
|
@ -17,13 +17,13 @@ class RegistrantUser < User
|
|||
Country.new(alpha2_code)
|
||||
end
|
||||
|
||||
def companies(company_register = nil)
|
||||
def companies(company_register = CompanyRegister::Client.new)
|
||||
return [] if ident.include?('-')
|
||||
|
||||
[OpenStruct.new(registration_number: '43344412', company_name: 'TestFirma'),
|
||||
OpenStruct.new(registration_number: '12345678', company_name: 'SuperFirma OU')]
|
||||
company_register.representation_rights(citizen_personal_code: ident,
|
||||
citizen_country_code: country.alpha3)
|
||||
end
|
||||
|
||||
|
||||
def contacts(representable: true)
|
||||
Contact.registrant_user_contacts(self, representable: representable)
|
||||
end
|
||||
|
|
|
@ -69,4 +69,4 @@ class ReplaceUpdToObjUpdProhibitedJobTest < ActiveSupport::TestCase
|
|||
|
||||
assert @domain.statuses.include? "serverUpdateProhibited"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue