mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Refactor
This commit is contained in:
parent
3e983e6082
commit
0cea91a28a
3 changed files with 9 additions and 15 deletions
|
@ -3,15 +3,7 @@ module Epp::DomainsHelper
|
||||||
EppDomain.transaction do
|
EppDomain.transaction do
|
||||||
@domain = EppDomain.new(domain_create_params)
|
@domain = EppDomain.new(domain_create_params)
|
||||||
|
|
||||||
@domain.attach_owner_contact(@ph[:registrant]) if @ph[:registrant]
|
|
||||||
|
|
||||||
unless @domain.save
|
|
||||||
handle_errors(@domain)
|
|
||||||
raise ActiveRecord::Rollback and return
|
|
||||||
end
|
|
||||||
|
|
||||||
@domain.parse_and_attach_domain_dependencies(parsed_frame)
|
@domain.parse_and_attach_domain_dependencies(parsed_frame)
|
||||||
@domain.all_dependencies_valid?
|
|
||||||
|
|
||||||
if @domain.errors.any?
|
if @domain.errors.any?
|
||||||
handle_errors(@domain)
|
handle_errors(@domain)
|
||||||
|
|
|
@ -103,13 +103,6 @@ class Domain < ActiveRecord::Base
|
||||||
errors.add(:period, :out_of_range) unless valid_values.include?(period.to_s)
|
errors.add(:period, :out_of_range) unless valid_values.include?(period.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_dependencies_valid?
|
|
||||||
validate_nameservers_count
|
|
||||||
validate_admin_contacts_count
|
|
||||||
|
|
||||||
errors.empty?
|
|
||||||
end
|
|
||||||
|
|
||||||
## SHARED
|
## SHARED
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|
|
@ -7,7 +7,11 @@ class EppDomain < Domain
|
||||||
period: 'period'
|
period: 'period'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validate :validate_nameservers_count
|
||||||
|
validate :validate_admin_contacts_count
|
||||||
|
|
||||||
def parse_and_attach_domain_dependencies(parsed_frame)
|
def parse_and_attach_domain_dependencies(parsed_frame)
|
||||||
|
attach_owner_contact(self.class.parse_owner_contact_from_frame(parsed_frame))
|
||||||
attach_contacts(self.class.parse_contacts_from_frame(parsed_frame))
|
attach_contacts(self.class.parse_contacts_from_frame(parsed_frame))
|
||||||
attach_nameservers(self.class.parse_nameservers_from_frame(parsed_frame))
|
attach_nameservers(self.class.parse_nameservers_from_frame(parsed_frame))
|
||||||
attach_statuses(self.class.parse_statuses_from_frame(parsed_frame))
|
attach_statuses(self.class.parse_statuses_from_frame(parsed_frame))
|
||||||
|
@ -39,6 +43,7 @@ class EppDomain < Domain
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach_owner_contact(code)
|
def attach_owner_contact(code)
|
||||||
|
return unless code
|
||||||
self.owner_contact = Contact.find_by(code: code)
|
self.owner_contact = Contact.find_by(code: code)
|
||||||
|
|
||||||
return if owner_contact
|
return if owner_contact
|
||||||
|
@ -278,6 +283,10 @@ class EppDomain < Domain
|
||||||
res
|
res
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def parse_owner_contact_from_frame(parsed_frame)
|
||||||
|
parsed_frame.css('registrant').first.try(:text)
|
||||||
|
end
|
||||||
|
|
||||||
def parse_period_unit_from_frame(parsed_frame)
|
def parse_period_unit_from_frame(parsed_frame)
|
||||||
p = parsed_frame.css('period').first
|
p = parsed_frame.css('period').first
|
||||||
return nil unless p
|
return nil unless p
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue