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