Merge branch 'master' into registry-790

This commit is contained in:
Artur Beljajev 2018-04-18 19:08:32 +03:00
commit 453acf6616
20 changed files with 41 additions and 63 deletions

View file

@ -275,7 +275,7 @@ GEM
multi_json (1.12.1)
multi_xml (0.6.0)
netrc (0.11.0)
nokogiri (1.8.1)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
nori (2.6.0)
open4 (1.3.4)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -22,9 +22,6 @@
class: 'form-control input-sm' %>
</dd>
<dt><%= t(:valid_from) %></dt>
<dd><%= l(@domain.valid_from) %></dd>
<dt><%= t(:valid_to) %></dt>
<dd><%= l(@domain.valid_to) %></dd>

View file

@ -66,12 +66,10 @@
%p
= 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
= "#{domain.period}#{domain.period_unit}"
%br
= "#{l(domain.valid_from, format: :date)}"
%br
= "#{l(domain.valid_to, format: :date)}"
%td

View file

@ -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:name', @domain.name)
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

View file

@ -48,7 +48,7 @@ xml.epp_head do
xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601))
end
xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601))
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
# TODO Make domain transferrable
#xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at

View file

@ -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:acID', dt.old_registrar.code)
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

View file

@ -7,7 +7,7 @@ xml.epp_head do
xml.resData 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:exDate', @domain.valid_to.try(:iso8601))
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
end
end

View 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

View file

@ -22,9 +22,6 @@
class: 'form-control input-sm' %>
</dd>
<dt><%= t(:valid_from) %></dt>
<dd><%= l(@domain.valid_from) %></dd>
<dt><%= t(:valid_to) %></dt>
<dd><%= l(@domain.valid_to) %></dd>

View file

@ -0,0 +1,5 @@
class RemoveDomainsValidFrom < ActiveRecord::Migration
def change
remove_column :domains, :valid_from, :datetime
end
end

View file

@ -0,0 +1,5 @@
class ChangeDomainsValidToToNotNull < ActiveRecord::Migration
def change
change_column_null :domains, :valid_to, false
end
end

View file

@ -872,8 +872,7 @@ CREATE TABLE domains (
registrar_id integer NOT NULL,
registered_at timestamp without time zone,
status character varying,
valid_from timestamp without time zone,
valid_to timestamp without time zone,
valid_to timestamp without time zone NOT NULL,
registrant_id integer NOT NULL,
transfer_code character varying NOT NULL,
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 ('20180327151906');
INSERT INTO schema_migrations (version) VALUES ('20180331200125');

View file

@ -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="-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="-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="-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>

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

Before After
Before After

View file

@ -23,7 +23,6 @@ namespace :dev do
period: period,
period_unit: period_unit,
registered_at: reg_time,
valid_from: reg_time,
expire_time: reg_time + period.send(duration.second.to_sym),
created_at: reg_time,
updated_at: reg_time,
@ -151,7 +150,6 @@ namespace :dev do
period: period,
period_unit: 'y',
registered_at: Time.zone.now,
valid_from: Time.zone.now,
expire_time: Time.zone.now + period.years,
registrar: registrar,
registrant: registrants.sample)

View file

@ -336,7 +336,6 @@ namespace :import do
name
registrar_id
registered_at
valid_from
valid_to
transfer_code
created_at

View file

@ -3,6 +3,7 @@ FactoryBot.define do
sequence(:name) { |n| "test#{n}.com" }
period 1
period_unit 'y' # Year
valid_to Time.zone.parse('2010-07-05')
registrar
registrant

View file

@ -21,11 +21,7 @@ RSpec.describe Epp::Domain, db: false do
expect(domain.registered_at).to eq(Time.zone.parse('05.07.2010'))
end
it 'has :valid_from set to now' 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
it 'has :valid_to set to the beginning of next day after :registered_at' do
expect(domain.valid_to).to eq(Time.zone.parse('06.07.2011 00:00'))
end
end