Renamed owner_contact to registrant

This commit is contained in:
Priit Tark 2015-04-16 12:23:06 +03:00
parent 92f41ebe0b
commit 8cd3dcf551
21 changed files with 126 additions and 812 deletions

View file

@ -3,7 +3,7 @@ class Admin::DomainsController < AdminController
before_action :set_domain, only: [:show, :edit, :update, :zonefile]
def index
@q = Domain.includes(:registrar, :owner_contact).search(params[:q])
@q = Domain.includes(:registrar, :registrant).search(params[:q])
@domains = @q.result.page(params[:page])
end

View file

@ -156,7 +156,7 @@ class Epp::DomainsController < EppController
def find_domain
domain_name = params[:parsed_frame].css('name').text.strip.downcase
@domain = Epp::Domain.where(name: domain_name).includes(owner_contact: :registrar).first
@domain = Epp::Domain.where(name: domain_name).includes(registrant: :registrar).first
unless @domain
epp_errors << {

View file

@ -34,7 +34,7 @@ class Epp::KeyrelaysController < EppController
def find_domain
domain_name = params[:parsed_frame].css('name').text.strip.downcase
domain = Epp::Domain.includes(:owner_contact).find_by(name: domain_name)
domain = Epp::Domain.includes(:registrant).find_by(name: domain_name)
unless domain
epp_errors << {

View file

@ -74,7 +74,7 @@ class Contact < ActiveRecord::Base
def find_orphans
Contact.where('
NOT EXISTS(
select 1 from domains d where d.owner_contact_id = contacts.id
select 1 from domains d where d.registrant_id = contacts.id
) AND NOT EXISTS(
select 1 from domain_contacts dc where dc.contact_id = contacts.id
)
@ -138,7 +138,7 @@ class Contact < ActiveRecord::Base
# Find a way to use self.domains with contact
def domains_owned
Domain.where(owner_contact_id: id)
Domain.where(registrant_id: id)
end
def relations_with_domain?

View file

@ -7,7 +7,7 @@ class Domain < ActiveRecord::Base
paginates_per 10 # just for showoff
belongs_to :registrar
belongs_to :owner_contact, class_name: 'Contact'
belongs_to :registrant, class_name: 'Contact'
has_many :domain_contacts, dependent: :destroy
has_many :admin_domain_contacts
@ -39,10 +39,10 @@ class Domain < ActiveRecord::Base
has_many :legal_documents, as: :documentable
accepts_nested_attributes_for :legal_documents, reject_if: proc { |attrs| attrs[:body].blank? }
delegate :code, to: :owner_contact, prefix: true
delegate :email, to: :owner_contact, prefix: true
delegate :ident, to: :owner_contact, prefix: true
delegate :phone, to: :owner_contact, prefix: true
delegate :code, to: :registrant, prefix: true
delegate :email, to: :registrant, prefix: true
delegate :ident, to: :registrant, prefix: true
delegate :phone, to: :registrant, prefix: true
delegate :name, to: :registrar, prefix: true
before_create :generate_auth_info
@ -57,7 +57,7 @@ class Domain < ActiveRecord::Base
validates :name_dirty, domain_name: true, uniqueness: true
validates :period, numericality: { only_integer: true }
validates :owner_contact, :registrar, presence: true
validates :registrant, :registrar, presence: true
validate :validate_period
@ -103,7 +103,7 @@ class Domain < ActiveRecord::Base
validate :validate_nameserver_ips
attr_accessor :owner_contact_typeahead, :update_me
attr_accessor :registrant_typeahead, :update_me
def subordinate_nameservers
nameservers.select { |x| x.hostname.end_with?(name) }
@ -138,8 +138,8 @@ class Domain < ActiveRecord::Base
self[:name_dirty] = value
end
def owner_contact_typeahead
@owner_contact_typeahead || owner_contact.try(:name) || nil
def registrant_typeahead
@registrant_typeahead || registrant.try(:name) || nil
end
def pending_transfer
@ -234,7 +234,7 @@ class Domain < ActiveRecord::Base
log[:admin_contacts] = admin_contacts.map(&:attributes)
log[:tech_contacts] = tech_contacts.map(&:attributes)
log[:nameservers] = nameservers.map(&:attributes)
log[:owner_contact] = [owner_contact.try(:attributes)]
log[:registrant] = [registrant.try(:attributes)]
log
end
@ -244,7 +244,7 @@ class Domain < ActiveRecord::Base
Estonia .ee Top Level Domain WHOIS server
domain: #{name}
registrant: #{owner_contact.name}
registrant: #{registrant.name}
status: #{domain_statuses.map(&:value).join(', ')}
registered: #{registered_at and registered_at.to_s(:db)}
changed: #{updated_at and updated_at.to_s(:db)}

View file

@ -24,7 +24,7 @@ class Epp::Domain < Domain
[:base, :domain_status_prohibits_operation]
],
'2306' => [ # Parameter policy error
[:owner_contact, :blank],
[:registrant, :blank],
[:base, :ds_data_with_key_not_allowed],
[:base, :ds_data_not_allowed],
[:base, :key_data_not_allowed],
@ -68,9 +68,9 @@ class Epp::Domain < Domain
end
def attach_default_contacts
return if owner_contact.blank?
tech_contacts << owner_contact if tech_contacts.blank?
admin_contacts << owner_contact if admin_contacts.blank? && owner_contact.priv?
return if registrant.blank?
tech_contacts << registrant if tech_contacts.blank?
admin_contacts << registrant if admin_contacts.blank? && registrant.priv?
end
# rubocop: disable Metrics/PerceivedComplexity
@ -84,9 +84,9 @@ class Epp::Domain < Domain
oc = Contact.find_by(code: code).try(:id)
if oc
at[:owner_contact_id] = oc
at[:registrant_id] = oc
else
add_epp_error('2303', 'registrant', code, [:owner_contact, :not_found])
add_epp_error('2303', 'registrant', code, [:registrant, :not_found])
end
end
@ -430,7 +430,7 @@ class Epp::Domain < Domain
# TODO: Eager load problems here. Investigate how it's possible not to query contact again
# Check if versioning works with update_column
def transfer_contacts(registrar_id)
transfer_owner_contact(registrar_id)
transfer_registrant(registrar_id)
transfer_domain_contacts(registrar_id)
end
@ -452,15 +452,15 @@ class Epp::Domain < Domain
oc
end
def transfer_owner_contact(registrar_id)
return if owner_contact.registrar_id == registrar_id
def transfer_registrant(registrar_id)
return if registrant.registrar_id == registrar_id
is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', owner_contact_id, id).count > 0
if owner_contact.domains_owned.count > 1 || is_other_domains_contact
oc = copy_and_transfer_contact(owner_contact_id, registrar_id)
self.owner_contact_id = oc.id
is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', registrant_id, id).count > 0
if registrant.domains_owned.count > 1 || is_other_domains_contact
oc = copy_and_transfer_contact(registrant_id, registrar_id)
self.registrant_id = oc.id
else
transfer_contact(owner_contact_id, registrar_id)
transfer_contact(registrant_id, registrar_id)
end
end
@ -471,11 +471,11 @@ class Epp::Domain < Domain
is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', c.id, id).count > 0
# if contact used to be owner contact but was copied, then contact must be transferred
# (owner_contact_id_was != c.id)
# (registrant_id_was != c.id)
if c.domains.count > 1 || is_other_domains_contact
# copy contact
if owner_contact_id_was == c.id # owner contact was copied previously, do not copy it again
oc = OpenStruct.new(id: owner_contact_id)
if registrant_id_was == c.id # owner contact was copied previously, do not copy it again
oc = OpenStruct.new(id: registrant_id)
else
oc = copy_and_transfer_contact(c.id, registrar_id)
end

View file

@ -2,7 +2,7 @@
- nameservers = children[:nameservers] || []
- tech_contacts = children[:tech_contacts] || []
- admin_contacts = children[:admin_contacts] || []
- owner_contact = children[:owner_contact] || []
- registrant = children[:registrant] || []
%td
%p.nowrap
@ -19,7 +19,7 @@
= domain.status
%td
- owner_contact.each do |oc|
- registrant.each do |oc|
%p
= oc[:name]
= oc[:phone]
@ -75,16 +75,16 @@
-# = ',' + children[:domain][:status]
-# %td{ class: changes.include?(:owner_contact) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:owner_contact]
-# %td{ class: changes.include?(:registrant) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:registrant]
-# %p{:style => "font-size:x-small;"}
-# = children[:owner_contact][:name]
-# = children[:registrant][:name]
-# = ","
-# = children[:owner_contact][:phone]
-# = children[:registrant][:phone]
-# = ","
-# = children[:owner_contact][:email]
-# = children[:registrant][:email]
-# = ","
-# = children[:owner_contact][:code]
-# = children[:registrant][:code]
-# %td{ class: changes.include?(:admin_contacts) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:admin_contacts]

View file

@ -1,6 +1,6 @@
.row
.col-sm-12
%h2.text-center-xs= t('domains')
%h2.text-center-xs= t(:domains)
%hr
.row
.col-md-12
@ -24,16 +24,16 @@
%th{class: 'col-xs-2'}
= sort_link(@q, 'name')
%th{class: 'col-xs-2'}
= sort_link(@q, 'owner_contact_name', t('owner'))
= sort_link(@q, 'registrant_name', t(:registrant))
%th{class: 'col-xs-2'}
= sort_link(@q, 'valid_to', t('valid_to'))
= sort_link(@q, 'valid_to', t(:valid_to))
%th{class: 'col-xs-2'}
= sort_link(@q, 'registrar_name', t('registrar'))
= sort_link(@q, 'registrar_name', t(:registrar))
%tbody
- @domains.each do |x|
%tr
%td= link_to(x, admin_domain_path(x))
%td= link_to(x.owner_contact, [:admin, x.owner_contact])
%td= link_to(x.registrant, [:admin, x.registrant])
%td= l(x.valid_to, format: :short)
%td= link_to(x.registrar, admin_registrar_path(x.registrar)) if x.registrar
.row

View file

@ -1,19 +1,19 @@
.panel.panel-default
.panel-heading
%h3.panel-title= t('owner')
%h3.panel-title= t(:registrant)
.panel-body
%dl.dl-horizontal
%dt= t('name')
%dd= link_to(@domain.owner_contact, [:admin, @domain.owner_contact])
%dt= t(:name)
%dd= link_to(@domain.registrant, [:admin, @domain.registrant])
%dt= t('code')
%dd= @domain.owner_contact_code
%dt= t(:code)
%dd= @domain.registrant_code
%dt= t('identity_code')
%dd= @domain.owner_contact_ident
%dt= t(:identity_code)
%dd= @domain.registrant_ident
%dt= t('email')
%dd= @domain.owner_contact_email
%dt= t(:email)
%dd= @domain.registrant_email
%dt= t('phone')
%dd= @domain.owner_contact_phone
%dt= t(:phone)
%dd= @domain.registrant_phone

View file

@ -12,7 +12,7 @@ xml.epp_head do
xml.tag!('domain:status', 's' => ds.value) if ds.description.blank?
end
xml.tag!('domain:registrant', @domain.owner_contact_code)
xml.tag!('domain:registrant', @domain.registrant_code)
@domain.tech_contacts.each do |tc|
xml.tag!('domain:contact', tc.code, 'type' => 'tech')