Do not require name servers in registrar area

#267
This commit is contained in:
Artur Beljajev 2016-12-29 16:27:07 +02:00
parent ffd29f6a67
commit b9df5aa92d
11 changed files with 411 additions and 281 deletions

View file

@ -0,0 +1,20 @@
module Concerns::Domain::Activatable
extend ActiveSupport::Concern
def active?
!inactive?
end
def inactive?
statuses.include?(DomainStatus::INACTIVE)
end
def activate
statuses.delete(DomainStatus::INACTIVE)
end
def deactivate
return if inactive?
statuses << DomainStatus::INACTIVE
end
end

View file

@ -40,13 +40,22 @@ module Depp
keys = Domain.create_dnskeys_hash(domain_params)
dns_hash[:_anonymus] = keys if keys.any?
xml = epp_xml.create({
name: { value: domain_params[:name] },
period: { value: domain_params[:period].to_s[0], attrs: { unit: domain_params[:period].to_s[1] } },
ns: Domain.create_nameservers_hash(domain_params),
registrant: { value: domain_params[:registrant] },
_anonymus: Domain.create_contacts_hash(domain_params)
}, dns_hash, Domain.construct_custom_params_hash(domain_params))
if domain_params[:nameservers_attributes].select { |key, value| value['hostname'].present? }.any?
xml = epp_xml.create({
name: { value: domain_params[:name] },
period: { value: domain_params[:period].to_s[0], attrs: { unit: domain_params[:period].to_s[1] } },
ns: Domain.create_nameservers_hash(domain_params),
registrant: { value: domain_params[:registrant] },
_anonymus: Domain.create_contacts_hash(domain_params)
}, dns_hash, Domain.construct_custom_params_hash(domain_params))
else
xml = epp_xml.create({
name: { value: domain_params[:name] },
period: { value: domain_params[:period].to_s[0], attrs: { unit: domain_params[:period].to_s[1] } },
registrant: { value: domain_params[:registrant] },
_anonymus: Domain.create_contacts_hash(domain_params)
}, dns_hash, Domain.construct_custom_params_hash(domain_params))
end
current_user.request(xml)
end

View file

@ -4,6 +4,7 @@ class Domain < ActiveRecord::Base
include Versions # version/domain_version.rb
include Statuses
include Concerns::Domain::Expirable
include Concerns::Domain::Activatable
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
@ -694,8 +695,8 @@ class Domain < ActiveRecord::Base
statuses << DomainStatus::SERVER_HOLD if p_d && s_h
if !self.class.nameserver_required?
statuses << DomainStatus::INACTIVE if nameservers.empty?
statuses.delete(DomainStatus::INACTIVE) if nameservers.size >= Setting.ns_min_count
deactivate if nameservers.reject(&:marked_for_destruction?).empty?
activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count
end
end
# rubocop: enable Metrics/CyclomaticComplexity