mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
Merge branch 'master' into registry-790
This commit is contained in:
commit
453acf6616
20 changed files with 41 additions and 63 deletions
|
@ -215,17 +215,6 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
class << self
|
||||
def included
|
||||
includes(
|
||||
:registrant,
|
||||
:registrar,
|
||||
:nameservers,
|
||||
:whois_record,
|
||||
{ tech_contacts: :registrar },
|
||||
{ admin_contacts: :registrar }
|
||||
)
|
||||
end
|
||||
|
||||
def nameserver_required?
|
||||
Setting.nameserver_required
|
||||
end
|
||||
|
@ -642,6 +631,7 @@ class Domain < ActiveRecord::Base
|
|||
def as_json(_options)
|
||||
hash = super
|
||||
hash['auth_info'] = hash.delete('transfer_code') # API v1 requirement
|
||||
hash['valid_from'] = hash['registered_at'] # API v1 requirement
|
||||
hash
|
||||
end
|
||||
|
||||
|
|
|
@ -38,23 +38,12 @@ class Epp::Domain < Domain
|
|||
ok
|
||||
end
|
||||
|
||||
before_save :link_contacts
|
||||
def link_contacts
|
||||
#TODO: cleanup cache if we think to cache dynamic statuses
|
||||
end
|
||||
|
||||
after_destroy :unlink_contacts
|
||||
def unlink_contacts
|
||||
#TODO: cleanup cache if we think to cache dynamic statuses
|
||||
end
|
||||
|
||||
class << self
|
||||
def new_from_epp(frame, current_user)
|
||||
domain = Epp::Domain.new
|
||||
domain.attributes = domain.attrs_from(frame, current_user)
|
||||
domain.attach_default_contacts
|
||||
domain.registered_at = Time.zone.now
|
||||
domain.valid_from = Time.zone.now
|
||||
|
||||
period = domain.period.to_i
|
||||
plural_period_unit_name = (domain.period_unit == 'm' ? 'months' : 'years').to_sym
|
||||
|
|
|
@ -9,20 +9,6 @@ class WhoisRecord < ActiveRecord::Base
|
|||
after_save :update_whois_server
|
||||
after_destroy :destroy_whois_record
|
||||
|
||||
class << self
|
||||
def included
|
||||
includes(
|
||||
domain: [
|
||||
:registrant,
|
||||
:registrar,
|
||||
:nameservers,
|
||||
{ tech_contacts: :registrar },
|
||||
{ admin_contacts: :registrar }
|
||||
]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_by_name(name)
|
||||
WhoisRecord.where("lower(name) = ?", name.downcase)
|
||||
end
|
||||
|
@ -37,6 +23,12 @@ class WhoisRecord < ActiveRecord::Base
|
|||
h = HashWithIndifferentAccess.new
|
||||
return h if domain.blank?
|
||||
|
||||
if domain.discarded?
|
||||
h[:name] = domain.name
|
||||
h[:status] = ['deleteCandidate']
|
||||
return h
|
||||
end
|
||||
|
||||
status_map = {
|
||||
'ok' => 'ok (paid and in zone)'
|
||||
}
|
||||
|
@ -48,7 +40,7 @@ class WhoisRecord < ActiveRecord::Base
|
|||
h[:status] = domain.statuses.map { |x| status_map[x] || x }
|
||||
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
||||
h[:changed] = domain.updated_at.try(:to_s, :iso8601)
|
||||
h[:expire] = domain.valid_to.try(:to_date).try(:to_s)
|
||||
h[:expire] = domain.valid_to.to_date.to_s
|
||||
h[:outzone] = domain.outzone_at.try(:to_date).try(:to_s)
|
||||
h[:delete] = [domain.delete_at, domain.force_delete_at].compact.min.try(:to_date).try(:to_s)
|
||||
|
||||
|
@ -102,7 +94,8 @@ class WhoisRecord < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def generated_body
|
||||
template = Rails.root.join("app/views/for_models/whois.erb".freeze)
|
||||
template_name = domain.discarded? ? 'whois_discarded.erb' : 'whois.erb'
|
||||
template = Rails.root.join("app/views/for_models/#{template_name}".freeze)
|
||||
ERB.new(template.read, nil, "-").result(binding)
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue