Make domain unavailable when zone with the same origin exists

This commit is contained in:
Artur Beljajev 2019-01-07 03:20:55 +02:00
parent ee864c807f
commit d40dc28484
5 changed files with 41 additions and 3 deletions

View file

@ -7,7 +7,7 @@ module DNS
end
def unavailable?
registered? || blocked?
registered? || blocked? || zone_with_same_origin?
end
def unavailability_reason
@ -15,6 +15,8 @@ module DNS
:registered
elsif blocked?
:blocked
elsif zone_with_same_origin?
:zone_with_same_origin
end
end
@ -29,5 +31,9 @@ module DNS
def blocked?
BlockedDomain.where(name: name).any?
end
def zone_with_same_origin?
DNS::Zone.where(origin: name).any?
end
end
end

View file

@ -805,8 +805,8 @@ class Epp::Domain < Domain
domain_name = DNS::DomainName.new(domain_name_as_string)
if domain_name.unavailable?
reason = domain_name.unavailability_reason
result << { name: domain_name_as_string, avail: 0, reason: I18n.t("errors.messages.epp_domain_#{reason}") }
reason = I18n.t("errors.messages.epp_domain_#{domain_name.unavailability_reason}")
result << { name: domain_name_as_string, avail: 0, reason: reason }
next
end