added dedicated registrant model

This commit is contained in:
Priit Tark 2015-05-11 16:22:43 +03:00
parent 2ed9672eb5
commit 321e28b8c7
10 changed files with 40 additions and 14 deletions

View file

@ -7,7 +7,7 @@ class Domain < ActiveRecord::Base
paginates_per 10 # just for showoff
belongs_to :registrar
belongs_to :registrant, class_name: 'Contact'
belongs_to :registrant
has_many :domain_contacts, dependent: :destroy
has_many :admin_domain_contacts

View file

@ -72,8 +72,9 @@ class Epp::Domain < Domain
def attach_default_contacts
return if registrant.blank?
tech_contacts << registrant if tech_domain_contacts.blank?
admin_contacts << registrant if admin_domain_contacts.blank? && registrant.priv?
regt = Registrant.find(registrant.id) # temp for bullet
tech_contacts << regt if tech_domain_contacts.blank?
admin_contacts << regt if admin_domain_contacts.blank? && regt.priv?
end
# rubocop: disable Metrics/PerceivedComplexity
@ -84,10 +85,9 @@ class Epp::Domain < Domain
code = frame.css('registrant').first.try(:text)
if code.present?
oc = Epp::Contact.find_by_epp_code(code).try(:id)
if oc
at[:registrant_id] = oc
regt = Registrant.find_by(code: code)
if regt
at[:registrant_id] = regt.id
else
add_epp_error('2303', 'registrant', code, [:registrant, :not_found])
end

6
app/models/registrant.rb Normal file
View file

@ -0,0 +1,6 @@
class Registrant < Contact
# epp_code_map is used during epp domain create
def epp_code_map
{}
end
end