diff --git a/Gemfile.lock b/Gemfile.lock
index 6d9105baf..efa504d8e 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -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)
diff --git a/app/models/domain.rb b/app/models/domain.rb
index 05ae9757a..1b59a1607 100644
--- a/app/models/domain.rb
+++ b/app/models/domain.rb
@@ -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
diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb
index 249f90a98..4e0e7d44c 100644
--- a/app/models/epp/domain.rb
+++ b/app/models/epp/domain.rb
@@ -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
diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb
index bd16e0c99..3ff0e9023 100644
--- a/app/models/whois_record.rb
+++ b/app/models/whois_record.rb
@@ -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
diff --git a/app/views/admin/domains/partials/_general.html.erb b/app/views/admin/domains/partials/_general.html.erb
index eeeef6eb5..7e09a7756 100644
--- a/app/views/admin/domains/partials/_general.html.erb
+++ b/app/views/admin/domains/partials/_general.html.erb
@@ -22,9 +22,6 @@
class: 'form-control input-sm' %>
-
<%= t(:valid_from) %>
- <%= l(@domain.valid_from) %>
-
<%= t(:valid_to) %>
<%= l(@domain.valid_to) %>
diff --git a/app/views/admin/domains/partials/_version.haml b/app/views/admin/domains/partials/_version.haml
index b15bda0dd..da0a0ece1 100644
--- a/app/views/admin/domains/partials/_version.haml
+++ b/app/views/admin/domains/partials/_version.haml
@@ -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
diff --git a/app/views/epp/domains/create.xml.builder b/app/views/epp/domains/create.xml.builder
index 213a2aa8f..2293f5657 100644
--- a/app/views/epp/domains/create.xml.builder
+++ b/app/views/epp/domains/create.xml.builder
@@ -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
diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder
index 8bf169acd..2d10f8baf 100644
--- a/app/views/epp/domains/info.xml.builder
+++ b/app/views/epp/domains/info.xml.builder
@@ -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
diff --git a/app/views/epp/domains/partials/_transfer.xml.builder b/app/views/epp/domains/partials/_transfer.xml.builder
index 151af28b3..bfcc7db94 100644
--- a/app/views/epp/domains/partials/_transfer.xml.builder
+++ b/app/views/epp/domains/partials/_transfer.xml.builder
@@ -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
diff --git a/app/views/epp/domains/renew.xml.builder b/app/views/epp/domains/renew.xml.builder
index 5d03c7128..e407ff0e7 100644
--- a/app/views/epp/domains/renew.xml.builder
+++ b/app/views/epp/domains/renew.xml.builder
@@ -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
diff --git a/app/views/for_models/whois_discarded.erb b/app/views/for_models/whois_discarded.erb
new file mode 100644
index 000000000..ecaa6f9af
--- /dev/null
+++ b/app/views/for_models/whois_discarded.erb
@@ -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
diff --git a/app/views/registrant/domains/partials/_general.html.erb b/app/views/registrant/domains/partials/_general.html.erb
index 72ae8aad7..eed058437 100644
--- a/app/views/registrant/domains/partials/_general.html.erb
+++ b/app/views/registrant/domains/partials/_general.html.erb
@@ -22,9 +22,6 @@
class: 'form-control input-sm' %>
- <%= t(:valid_from) %>
- <%= l(@domain.valid_from) %>
-
<%= t(:valid_to) %>
<%= l(@domain.valid_to) %>
diff --git a/db/migrate/20180327151906_remove_domains_valid_from.rb b/db/migrate/20180327151906_remove_domains_valid_from.rb
new file mode 100644
index 000000000..3514fc9f2
--- /dev/null
+++ b/db/migrate/20180327151906_remove_domains_valid_from.rb
@@ -0,0 +1,5 @@
+class RemoveDomainsValidFrom < ActiveRecord::Migration
+ def change
+ remove_column :domains, :valid_from, :datetime
+ end
+end
diff --git a/db/migrate/20180331200125_change_domains_valid_to_to_not_null.rb b/db/migrate/20180331200125_change_domains_valid_to_to_not_null.rb
new file mode 100644
index 000000000..049b08806
--- /dev/null
+++ b/db/migrate/20180331200125_change_domains_valid_to_to_not_null.rb
@@ -0,0 +1,5 @@
+class ChangeDomainsValidToToNotNull < ActiveRecord::Migration
+ def change
+ change_column_null :domains, :valid_to, false
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 4c7dbd70d..744ea9e19 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -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');
+
diff --git a/doc/models_complete.svg b/doc/models_complete.svg
index 235aa433b..644822637 100644
--- a/doc/models_complete.svg
+++ b/doc/models_complete.svg
@@ -852,7 +852,6 @@
registrar_id :integer
registered_at :datetime
status :string
-valid_from :datetime
valid_to :datetime
registrant_id :integer
transfer_code :string
diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake
index f4b133ed1..e4c120a8d 100644
--- a/lib/tasks/dev.rake
+++ b/lib/tasks/dev.rake
@@ -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)
diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake
index c5f84160d..d953c72c9 100644
--- a/lib/tasks/import.rake
+++ b/lib/tasks/import.rake
@@ -336,7 +336,6 @@ namespace :import do
name
registrar_id
registered_at
- valid_from
valid_to
transfer_code
created_at
diff --git a/spec/factories/domain.rb b/spec/factories/domain.rb
index 4e15a8713..39ad2240d 100644
--- a/spec/factories/domain.rb
+++ b/spec/factories/domain.rb
@@ -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
diff --git a/spec/models/epp/domain_spec.rb b/spec/models/epp/domain_spec.rb
index de0b8f4e1..402305527 100644
--- a/spec/models/epp/domain_spec.rb
+++ b/spec/models/epp/domain_spec.rb
@@ -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