mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 13:15:40 +02:00
Merge branch 'master' into registry-790
This commit is contained in:
commit
453acf6616
20 changed files with 41 additions and 63 deletions
|
@ -275,7 +275,7 @@ GEM
|
||||||
multi_json (1.12.1)
|
multi_json (1.12.1)
|
||||||
multi_xml (0.6.0)
|
multi_xml (0.6.0)
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
nokogiri (1.8.1)
|
nokogiri (1.8.2)
|
||||||
mini_portile2 (~> 2.3.0)
|
mini_portile2 (~> 2.3.0)
|
||||||
nori (2.6.0)
|
nori (2.6.0)
|
||||||
open4 (1.3.4)
|
open4 (1.3.4)
|
||||||
|
|
|
@ -215,17 +215,6 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def included
|
|
||||||
includes(
|
|
||||||
:registrant,
|
|
||||||
:registrar,
|
|
||||||
:nameservers,
|
|
||||||
:whois_record,
|
|
||||||
{ tech_contacts: :registrar },
|
|
||||||
{ admin_contacts: :registrar }
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def nameserver_required?
|
def nameserver_required?
|
||||||
Setting.nameserver_required
|
Setting.nameserver_required
|
||||||
end
|
end
|
||||||
|
@ -642,6 +631,7 @@ class Domain < ActiveRecord::Base
|
||||||
def as_json(_options)
|
def as_json(_options)
|
||||||
hash = super
|
hash = super
|
||||||
hash['auth_info'] = hash.delete('transfer_code') # API v1 requirement
|
hash['auth_info'] = hash.delete('transfer_code') # API v1 requirement
|
||||||
|
hash['valid_from'] = hash['registered_at'] # API v1 requirement
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -38,23 +38,12 @@ class Epp::Domain < Domain
|
||||||
ok
|
ok
|
||||||
end
|
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
|
class << self
|
||||||
def new_from_epp(frame, current_user)
|
def new_from_epp(frame, current_user)
|
||||||
domain = Epp::Domain.new
|
domain = Epp::Domain.new
|
||||||
domain.attributes = domain.attrs_from(frame, current_user)
|
domain.attributes = domain.attrs_from(frame, current_user)
|
||||||
domain.attach_default_contacts
|
domain.attach_default_contacts
|
||||||
domain.registered_at = Time.zone.now
|
domain.registered_at = Time.zone.now
|
||||||
domain.valid_from = Time.zone.now
|
|
||||||
|
|
||||||
period = domain.period.to_i
|
period = domain.period.to_i
|
||||||
plural_period_unit_name = (domain.period_unit == 'm' ? 'months' : 'years').to_sym
|
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_save :update_whois_server
|
||||||
after_destroy :destroy_whois_record
|
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)
|
def self.find_by_name(name)
|
||||||
WhoisRecord.where("lower(name) = ?", name.downcase)
|
WhoisRecord.where("lower(name) = ?", name.downcase)
|
||||||
end
|
end
|
||||||
|
@ -37,6 +23,12 @@ class WhoisRecord < ActiveRecord::Base
|
||||||
h = HashWithIndifferentAccess.new
|
h = HashWithIndifferentAccess.new
|
||||||
return h if domain.blank?
|
return h if domain.blank?
|
||||||
|
|
||||||
|
if domain.discarded?
|
||||||
|
h[:name] = domain.name
|
||||||
|
h[:status] = ['deleteCandidate']
|
||||||
|
return h
|
||||||
|
end
|
||||||
|
|
||||||
status_map = {
|
status_map = {
|
||||||
'ok' => 'ok (paid and in zone)'
|
'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[:status] = domain.statuses.map { |x| status_map[x] || x }
|
||||||
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
||||||
h[:changed] = domain.updated_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[: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)
|
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
|
end
|
||||||
|
|
||||||
def generated_body
|
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)
|
ERB.new(template.read, nil, "-").result(binding)
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/MethodLength
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
|
@ -22,9 +22,6 @@
|
||||||
class: 'form-control input-sm' %>
|
class: 'form-control input-sm' %>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><%= t(:valid_from) %></dt>
|
|
||||||
<dd><%= l(@domain.valid_from) %></dd>
|
|
||||||
|
|
||||||
<dt><%= t(:valid_to) %></dt>
|
<dt><%= t(:valid_to) %></dt>
|
||||||
<dd><%= l(@domain.valid_to) %></dd>
|
<dd><%= l(@domain.valid_to) %></dd>
|
||||||
|
|
||||||
|
|
|
@ -66,12 +66,10 @@
|
||||||
%p
|
%p
|
||||||
= link_to t(:pending_epp), '#', class: 'js-pending'
|
= link_to t(:pending_epp), '#', class: 'js-pending'
|
||||||
|
|
||||||
%td{class: changing_css_class(version, "period", "period_unit", "valid_from", "valid_to")}
|
%td{class: changing_css_class(version, "period", "period_unit", "valid_to")}
|
||||||
%p
|
%p
|
||||||
= "#{domain.period}#{domain.period_unit}"
|
= "#{domain.period}#{domain.period_unit}"
|
||||||
%br
|
%br
|
||||||
= "#{l(domain.valid_from, format: :date)}"
|
|
||||||
%br
|
|
||||||
= "#{l(domain.valid_to, format: :date)}"
|
= "#{l(domain.valid_to, format: :date)}"
|
||||||
|
|
||||||
%td
|
%td
|
||||||
|
|
|
@ -8,7 +8,7 @@ xml.epp_head do
|
||||||
xml.tag!('domain:creData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
|
xml.tag!('domain:creData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
|
||||||
xml.tag!('domain:name', @domain.name)
|
xml.tag!('domain:name', @domain.name)
|
||||||
xml.tag!('domain:crDate', @domain.created_at.try(:iso8601))
|
xml.tag!('domain:crDate', @domain.created_at.try(:iso8601))
|
||||||
xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601))
|
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ xml.epp_head do
|
||||||
xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601))
|
xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601))
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601))
|
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
|
||||||
|
|
||||||
# TODO Make domain transferrable
|
# TODO Make domain transferrable
|
||||||
#xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at
|
#xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at
|
||||||
|
|
|
@ -5,5 +5,5 @@ builder.tag!('domain:trnData', 'xmlns:domain' => 'https://epp.tld.ee/schema/doma
|
||||||
builder.tag!('domain:reDate', dt.transfer_requested_at.try(:iso8601))
|
builder.tag!('domain:reDate', dt.transfer_requested_at.try(:iso8601))
|
||||||
builder.tag!('domain:acID', dt.old_registrar.code)
|
builder.tag!('domain:acID', dt.old_registrar.code)
|
||||||
builder.tag!('domain:acDate', dt.transferred_at.try(:iso8601) || dt.wait_until.try(:iso8601))
|
builder.tag!('domain:acDate', dt.transferred_at.try(:iso8601) || dt.wait_until.try(:iso8601))
|
||||||
builder.tag!('domain:exDate', dt.domain_valid_to.try(:iso8601))
|
builder.tag!('domain:exDate', dt.domain_valid_to.iso8601)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ xml.epp_head do
|
||||||
xml.resData do
|
xml.resData do
|
||||||
xml.tag!('domain:renData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
|
xml.tag!('domain:renData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
|
||||||
xml.tag!('domain:name', @domain[:name])
|
xml.tag!('domain:name', @domain[:name])
|
||||||
xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601))
|
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
8
app/views/for_models/whois_discarded.erb
Normal file
8
app/views/for_models/whois_discarded.erb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Estonia .ee Top Level Domain WHOIS server
|
||||||
|
|
||||||
|
Domain:
|
||||||
|
name: <%= json['name'] %>
|
||||||
|
status: <%= json['status'] %>
|
||||||
|
|
||||||
|
Estonia .ee Top Level Domain WHOIS server
|
||||||
|
More information at http://internet.ee
|
|
@ -22,9 +22,6 @@
|
||||||
class: 'form-control input-sm' %>
|
class: 'form-control input-sm' %>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><%= t(:valid_from) %></dt>
|
|
||||||
<dd><%= l(@domain.valid_from) %></dd>
|
|
||||||
|
|
||||||
<dt><%= t(:valid_to) %></dt>
|
<dt><%= t(:valid_to) %></dt>
|
||||||
<dd><%= l(@domain.valid_to) %></dd>
|
<dd><%= l(@domain.valid_to) %></dd>
|
||||||
|
|
||||||
|
|
5
db/migrate/20180327151906_remove_domains_valid_from.rb
Normal file
5
db/migrate/20180327151906_remove_domains_valid_from.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class RemoveDomainsValidFrom < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :domains, :valid_from, :datetime
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeDomainsValidToToNotNull < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_column_null :domains, :valid_to, false
|
||||||
|
end
|
||||||
|
end
|
|
@ -872,8 +872,7 @@ CREATE TABLE domains (
|
||||||
registrar_id integer NOT NULL,
|
registrar_id integer NOT NULL,
|
||||||
registered_at timestamp without time zone,
|
registered_at timestamp without time zone,
|
||||||
status character varying,
|
status character varying,
|
||||||
valid_from timestamp without time zone,
|
valid_to timestamp without time zone NOT NULL,
|
||||||
valid_to timestamp without time zone,
|
|
||||||
registrant_id integer NOT NULL,
|
registrant_id integer NOT NULL,
|
||||||
transfer_code character varying NOT NULL,
|
transfer_code character varying NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
|
@ -4713,3 +4712,7 @@ INSERT INTO schema_migrations (version) VALUES ('20180313124751');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20180314122722');
|
INSERT INTO schema_migrations (version) VALUES ('20180314122722');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20180327151906');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20180331200125');
|
||||||
|
|
||||||
|
|
|
@ -852,7 +852,6 @@
|
||||||
<text text-anchor="start" x="1958.5" y="-2181.3" font-family="Times,serif" font-size="14.00">registrar_id :integer</text>
|
<text text-anchor="start" x="1958.5" y="-2181.3" font-family="Times,serif" font-size="14.00">registrar_id :integer</text>
|
||||||
<text text-anchor="start" x="1958.5" y="-2166.3" font-family="Times,serif" font-size="14.00">registered_at :datetime</text>
|
<text text-anchor="start" x="1958.5" y="-2166.3" font-family="Times,serif" font-size="14.00">registered_at :datetime</text>
|
||||||
<text text-anchor="start" x="1958.5" y="-2151.3" font-family="Times,serif" font-size="14.00">status :string</text>
|
<text text-anchor="start" x="1958.5" y="-2151.3" font-family="Times,serif" font-size="14.00">status :string</text>
|
||||||
<text text-anchor="start" x="1958.5" y="-2136.3" font-family="Times,serif" font-size="14.00">valid_from :datetime</text>
|
|
||||||
<text text-anchor="start" x="1958.5" y="-2121.3" font-family="Times,serif" font-size="14.00">valid_to :datetime</text>
|
<text text-anchor="start" x="1958.5" y="-2121.3" font-family="Times,serif" font-size="14.00">valid_to :datetime</text>
|
||||||
<text text-anchor="start" x="1958.5" y="-2106.3" font-family="Times,serif" font-size="14.00">registrant_id :integer</text>
|
<text text-anchor="start" x="1958.5" y="-2106.3" font-family="Times,serif" font-size="14.00">registrant_id :integer</text>
|
||||||
<text text-anchor="start" x="1958.5" y="-2091.3" font-family="Times,serif" font-size="14.00">transfer_code :string</text>
|
<text text-anchor="start" x="1958.5" y="-2091.3" font-family="Times,serif" font-size="14.00">transfer_code :string</text>
|
||||||
|
|
Before Width: | Height: | Size: 220 KiB After Width: | Height: | Size: 220 KiB |
|
@ -23,7 +23,6 @@ namespace :dev do
|
||||||
period: period,
|
period: period,
|
||||||
period_unit: period_unit,
|
period_unit: period_unit,
|
||||||
registered_at: reg_time,
|
registered_at: reg_time,
|
||||||
valid_from: reg_time,
|
|
||||||
expire_time: reg_time + period.send(duration.second.to_sym),
|
expire_time: reg_time + period.send(duration.second.to_sym),
|
||||||
created_at: reg_time,
|
created_at: reg_time,
|
||||||
updated_at: reg_time,
|
updated_at: reg_time,
|
||||||
|
@ -151,7 +150,6 @@ namespace :dev do
|
||||||
period: period,
|
period: period,
|
||||||
period_unit: 'y',
|
period_unit: 'y',
|
||||||
registered_at: Time.zone.now,
|
registered_at: Time.zone.now,
|
||||||
valid_from: Time.zone.now,
|
|
||||||
expire_time: Time.zone.now + period.years,
|
expire_time: Time.zone.now + period.years,
|
||||||
registrar: registrar,
|
registrar: registrar,
|
||||||
registrant: registrants.sample)
|
registrant: registrants.sample)
|
||||||
|
|
|
@ -336,7 +336,6 @@ namespace :import do
|
||||||
name
|
name
|
||||||
registrar_id
|
registrar_id
|
||||||
registered_at
|
registered_at
|
||||||
valid_from
|
|
||||||
valid_to
|
valid_to
|
||||||
transfer_code
|
transfer_code
|
||||||
created_at
|
created_at
|
||||||
|
|
|
@ -3,6 +3,7 @@ FactoryBot.define do
|
||||||
sequence(:name) { |n| "test#{n}.com" }
|
sequence(:name) { |n| "test#{n}.com" }
|
||||||
period 1
|
period 1
|
||||||
period_unit 'y' # Year
|
period_unit 'y' # Year
|
||||||
|
valid_to Time.zone.parse('2010-07-05')
|
||||||
registrar
|
registrar
|
||||||
registrant
|
registrant
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,7 @@ RSpec.describe Epp::Domain, db: false do
|
||||||
expect(domain.registered_at).to eq(Time.zone.parse('05.07.2010'))
|
expect(domain.registered_at).to eq(Time.zone.parse('05.07.2010'))
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has :valid_from set to now' do
|
it 'has :valid_to set to the beginning of next day after :registered_at' do
|
||||||
expect(domain.valid_from).to eq(Time.zone.parse('05.07.2010'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has :valid_to set to the beginning of next day after :valid_from' do
|
|
||||||
expect(domain.valid_to).to eq(Time.zone.parse('06.07.2011 00:00'))
|
expect(domain.valid_to).to eq(Time.zone.parse('06.07.2011 00:00'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue