mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 18:29:40 +02:00
Added legal document to contact, removed old comments
This commit is contained in:
parent
2e47bcf5cb
commit
ba55f3f9bc
8 changed files with 78 additions and 110 deletions
|
@ -94,6 +94,8 @@ class Epp::ContactsController < EppController
|
||||||
'postalInfo > name', 'postalInfo > addr > city',
|
'postalInfo > name', 'postalInfo > addr > city',
|
||||||
'postalInfo > addr > cc', 'ident', 'voice', 'email'
|
'postalInfo > addr > cc', 'ident', 'voice', 'email'
|
||||||
)
|
)
|
||||||
|
@prefix = nil
|
||||||
|
requires 'extension > extdata > legalDocument'
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_update
|
def validate_update
|
||||||
|
@ -105,10 +107,14 @@ class Epp::ContactsController < EppController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
requires 'id', 'authInfo > pw'
|
requires 'id', 'authInfo > pw'
|
||||||
|
@prefix = nil
|
||||||
|
requires 'extension > extdata > legalDocument'
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_delete
|
def validate_delete
|
||||||
@prefix = 'delete > delete >'
|
@prefix = 'delete > delete >'
|
||||||
requires 'id', 'authInfo > pw'
|
requires 'id', 'authInfo > pw'
|
||||||
|
@prefix = nil
|
||||||
|
requires 'extension > extdata > legalDocument'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,10 +7,11 @@ class Contact < ActiveRecord::Base
|
||||||
has_many :domain_contacts
|
has_many :domain_contacts
|
||||||
has_many :domains, through: :domain_contacts
|
has_many :domains, through: :domain_contacts
|
||||||
has_many :statuses, class_name: 'ContactStatus'
|
has_many :statuses, class_name: 'ContactStatus'
|
||||||
|
has_many :legal_documents, as: :documentable
|
||||||
|
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
|
|
||||||
accepts_nested_attributes_for :address, :disclosure
|
accepts_nested_attributes_for :address, :disclosure, :legal_documents
|
||||||
|
|
||||||
validates :name, :phone, :email, :ident, :address, :registrar, :ident_type, presence: true
|
validates :name, :phone, :email, :ident, :address, :registrar, :ident_type, presence: true
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@ class Domain < ActiveRecord::Base
|
||||||
-> { where(domain_contacts: { contact_type: DomainContact::ADMIN }) },
|
-> { where(domain_contacts: { contact_type: DomainContact::ADMIN }) },
|
||||||
through: :domain_contacts, source: :contact
|
through: :domain_contacts, source: :contact
|
||||||
|
|
||||||
# TODO: remove old
|
|
||||||
# has_many :nameservers, dependent: :delete_all, after_add: :track_nameserver_add
|
|
||||||
has_many :nameservers, dependent: :delete_all
|
has_many :nameservers, dependent: :delete_all
|
||||||
|
|
||||||
accepts_nested_attributes_for :nameservers, allow_destroy: true,
|
accepts_nested_attributes_for :nameservers, allow_destroy: true,
|
||||||
|
@ -117,11 +115,6 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
attr_accessor :owner_contact_typeahead, :update_me
|
attr_accessor :owner_contact_typeahead, :update_me
|
||||||
|
|
||||||
# TODO: remove old
|
|
||||||
# archiving
|
|
||||||
# if proc works only on changes on domain sadly
|
|
||||||
# has_paper_trail class_name: 'DomainVersion', meta: { snapshot: :create_snapshot }, if: proc(&:new_version)
|
|
||||||
|
|
||||||
def tech_domain_contacts
|
def tech_domain_contacts
|
||||||
domain_contacts.select { |x| x.contact_type == DomainContact::TECH }
|
domain_contacts.select { |x| x.contact_type == DomainContact::TECH }
|
||||||
end
|
end
|
||||||
|
@ -130,52 +123,6 @@ class Domain < ActiveRecord::Base
|
||||||
domain_contacts.select { |x| x.contact_type == DomainContact::ADMIN }
|
domain_contacts.select { |x| x.contact_type == DomainContact::ADMIN }
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: remove old
|
|
||||||
# def new_version
|
|
||||||
# return false if versions.try(:last).try(:snapshot) == create_snapshot
|
|
||||||
# true
|
|
||||||
# end
|
|
||||||
|
|
||||||
# TODO: remove old
|
|
||||||
# def create_version
|
|
||||||
# return true unless PaperTrail.enabled?
|
|
||||||
# return true unless valid?
|
|
||||||
# touch_with_version if new_version
|
|
||||||
# end
|
|
||||||
|
|
||||||
# TODO: remove old
|
|
||||||
# def track_nameserver_add(_nameserver)
|
|
||||||
# return true if versions.count == 0
|
|
||||||
# return true unless valid? && new_version
|
|
||||||
|
|
||||||
# touch_with_version
|
|
||||||
# end
|
|
||||||
|
|
||||||
# TODO: remove old
|
|
||||||
# def create_snapshot
|
|
||||||
# oc = owner_contact.snapshot if owner_contact.is_a?(Contact)
|
|
||||||
# {
|
|
||||||
# owner_contact: oc,
|
|
||||||
# tech_contacts: tech_contacts.map(&:snapshot),
|
|
||||||
# admin_contacts: admin_contacts.map(&:snapshot),
|
|
||||||
# nameservers: nameservers.map(&:snapshot),
|
|
||||||
# domain: make_snapshot
|
|
||||||
# }.to_yaml
|
|
||||||
# end
|
|
||||||
|
|
||||||
# TODO: remove old
|
|
||||||
# def make_snapshot
|
|
||||||
# {
|
|
||||||
# name: name,
|
|
||||||
# status: status,
|
|
||||||
# period: period,
|
|
||||||
# period_unit: period_unit,
|
|
||||||
# registrar_id: registrar.try(:id),
|
|
||||||
# valid_to: valid_to,
|
|
||||||
# valid_from: valid_from
|
|
||||||
# }
|
|
||||||
# end
|
|
||||||
|
|
||||||
def name=(value)
|
def name=(value)
|
||||||
value.strip!
|
value.strip!
|
||||||
value.downcase!
|
value.downcase!
|
||||||
|
|
|
@ -8,6 +8,7 @@ class Epp::Contact < Contact
|
||||||
class << self
|
class << self
|
||||||
# rubocop: disable Metrics/PerceivedComplexity
|
# rubocop: disable Metrics/PerceivedComplexity
|
||||||
# rubocop: disable Metrics/CyclomaticComplexity
|
# rubocop: disable Metrics/CyclomaticComplexity
|
||||||
|
# rubocop: disable Metrics/MethodLength
|
||||||
def attrs_from(frame)
|
def attrs_from(frame)
|
||||||
f = frame
|
f = frame
|
||||||
at = {}.with_indifferent_access
|
at = {}.with_indifferent_access
|
||||||
|
@ -23,7 +24,7 @@ class Epp::Contact < Contact
|
||||||
at[:ident_type] = f.css('ident').attr('type').text
|
at[:ident_type] = f.css('ident').attr('type').text
|
||||||
end
|
end
|
||||||
|
|
||||||
at[:address_attributes] = {}
|
at[:address_attributes] = {}.with_indifferent_access
|
||||||
sat = at[:address_attributes]
|
sat = at[:address_attributes]
|
||||||
sat[:city] = f.css('postalInfo addr city').text if f.css('postalInfo addr city').present?
|
sat[:city] = f.css('postalInfo addr city').text if f.css('postalInfo addr city').present?
|
||||||
sat[:zip] = f.css('postalInfo addr pc').text if f.css('postalInfo addr pc').present?
|
sat[:zip] = f.css('postalInfo addr pc').text if f.css('postalInfo addr pc').present?
|
||||||
|
@ -31,8 +32,20 @@ class Epp::Contact < Contact
|
||||||
sat[:state] = f.css('postalInfo addr sp').text if f.css('postalInfo addr sp').present?
|
sat[:state] = f.css('postalInfo addr sp').text if f.css('postalInfo addr sp').present?
|
||||||
sat[:country_code] = f.css('postalInfo addr cc').text if f.css('postalInfo addr cc').present?
|
sat[:country_code] = f.css('postalInfo addr cc').text if f.css('postalInfo addr cc').present?
|
||||||
at.delete(:address_attributes) if at[:address_attributes].blank?
|
at.delete(:address_attributes) if at[:address_attributes].blank?
|
||||||
|
|
||||||
|
legald = f.css('legalDocument').first
|
||||||
|
if legald.present?
|
||||||
|
at[:legal_documents_attributes] = {}.with_indifferent_access
|
||||||
|
lat = at[:legal_documents_attributes]
|
||||||
|
lat[0] = {}.with_indifferent_access
|
||||||
|
lat[0][:document_type] = legald['type']
|
||||||
|
lat[0][:body] = legald.text
|
||||||
|
at.delete(:legal_documents_attributes) if at[:legal_documents_attributes].blank?
|
||||||
|
end
|
||||||
|
|
||||||
at
|
at
|
||||||
end
|
end
|
||||||
|
# rubocop: enable Metrics/MethodLength
|
||||||
# rubocop: enable Metrics/PerceivedComplexity
|
# rubocop: enable Metrics/PerceivedComplexity
|
||||||
# rubocop: enable Metrics/CyclomaticComplexity
|
# rubocop: enable Metrics/CyclomaticComplexity
|
||||||
|
|
||||||
|
@ -40,16 +53,6 @@ class Epp::Contact < Contact
|
||||||
return super if frame.blank?
|
return super if frame.blank?
|
||||||
super(attrs_from(frame))
|
super(attrs_from(frame))
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_legal_document_from_frame(parsed_frame)
|
|
||||||
ld = parsed_frame.css('legalDocument').first
|
|
||||||
return nil unless ld
|
|
||||||
|
|
||||||
{
|
|
||||||
body: ld.text,
|
|
||||||
type: ld['type']
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def epp_code_map # rubocop:disable Metrics/MethodLength
|
def epp_code_map # rubocop:disable Metrics/MethodLength
|
||||||
|
@ -74,14 +77,5 @@ class Epp::Contact < Contact
|
||||||
at.deep_merge!(self.class.attrs_from(frame.css('chg')))
|
at.deep_merge!(self.class.attrs_from(frame.css('chg')))
|
||||||
super(at)
|
super(at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach_legal_document(legal_document_data)
|
|
||||||
return unless legal_document_data
|
|
||||||
|
|
||||||
legal_documents.build(
|
|
||||||
document_type: legal_document_data[:type],
|
|
||||||
body: legal_document_data[:body]
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# rubocop: enable Metrics/ClassLength
|
# rubocop: enable Metrics/ClassLength
|
||||||
|
|
|
@ -8,3 +8,6 @@
|
||||||
.col-md-6= render 'admin/contacts/partials/address'
|
.col-md-6= render 'admin/contacts/partials/address'
|
||||||
.row
|
.row
|
||||||
.col-md-12= render 'admin/contacts/partials/domains'
|
.col-md-12= render 'admin/contacts/partials/domains'
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
= render 'admin/domains/partials/legal_documents', legal_documents: @contact.legal_documents
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
%th{class: 'col-xs-8'}= t('created_at')
|
%th{class: 'col-xs-8'}= t('created_at')
|
||||||
%th{class: 'col-xs-4'}= t('type')
|
%th{class: 'col-xs-4'}= t('type')
|
||||||
%tbody
|
%tbody
|
||||||
- @domain.legal_documents.each do |x|
|
- legal_documents.each do |x|
|
||||||
%tr
|
%tr
|
||||||
%td= link_to(x.created_at, [:admin, x])
|
%td= link_to(x.created_at, [:admin, x])
|
||||||
%td= x.document_type
|
%td= x.document_type
|
||||||
|
|
|
@ -24,4 +24,5 @@
|
||||||
.row
|
.row
|
||||||
.col-md-12= render 'admin/domains/partials/keyrelays'
|
.col-md-12= render 'admin/domains/partials/keyrelays'
|
||||||
.row
|
.row
|
||||||
.col-md-12= render 'admin/domains/partials/legal_documents'
|
.col-md-12
|
||||||
|
= render 'admin/domains/partials/legal_documents', legal_documents: @domain.legal_documents
|
||||||
|
|
|
@ -17,6 +17,12 @@ describe 'EPP Contact', epp: true do
|
||||||
Contact.skip_callback(:create, :before, :generate_auth_info)
|
Contact.skip_callback(:create, :before, :generate_auth_info)
|
||||||
|
|
||||||
@contact = Fabricate(:contact, registrar: @registrar1)
|
@contact = Fabricate(:contact, registrar: @registrar1)
|
||||||
|
@legal_document = {
|
||||||
|
legalDocument: {
|
||||||
|
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
|
||||||
|
attrs: { type: 'pdf' }
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
after :all do
|
after :all do
|
||||||
|
@ -40,7 +46,7 @@ describe 'EPP Contact', epp: true do
|
||||||
email: { value: 'test@example.example' },
|
email: { value: 'test@example.example' },
|
||||||
ident: { value: '37605030299', attrs: { type: 'priv' } }
|
ident: { value: '37605030299', attrs: { type: 'priv' } }
|
||||||
}
|
}
|
||||||
create_xml = @epp_xml.create(defaults.deep_merge(overwrites))
|
create_xml = @epp_xml.create(defaults.deep_merge(overwrites), @legal_document)
|
||||||
epp_plain_request(create_xml, :xml)
|
epp_plain_request(create_xml, :xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,6 +64,8 @@ describe 'EPP Contact', epp: true do
|
||||||
'Required parameter missing: create > create > voice'
|
'Required parameter missing: create > create > voice'
|
||||||
response[:results][5][:msg].should ==
|
response[:results][5][:msg].should ==
|
||||||
'Required parameter missing: create > create > email'
|
'Required parameter missing: create > create > email'
|
||||||
|
response[:results][6][:msg].should ==
|
||||||
|
'Required parameter missing: extension > extdata > legalDocument'
|
||||||
|
|
||||||
response[:results][0][:result_code].should == '2003'
|
response[:results][0][:result_code].should == '2003'
|
||||||
response[:results][1][:result_code].should == '2003'
|
response[:results][1][:result_code].should == '2003'
|
||||||
|
@ -65,8 +73,9 @@ describe 'EPP Contact', epp: true do
|
||||||
response[:results][3][:result_code].should == '2003'
|
response[:results][3][:result_code].should == '2003'
|
||||||
response[:results][4][:result_code].should == '2003'
|
response[:results][4][:result_code].should == '2003'
|
||||||
response[:results][5][:result_code].should == '2003'
|
response[:results][5][:result_code].should == '2003'
|
||||||
|
response[:results][6][:result_code].should == '2003'
|
||||||
|
|
||||||
response[:results].count.should == 6
|
response[:results].count.should == 7
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'successfully creates a contact' do
|
it 'successfully creates a contact' do
|
||||||
|
@ -81,6 +90,7 @@ describe 'EPP Contact', epp: true do
|
||||||
@registrar1.api_users.should include(@contact.creator)
|
@registrar1.api_users.should include(@contact.creator)
|
||||||
@contact.ident.should == '37605030299'
|
@contact.ident.should == '37605030299'
|
||||||
@contact.address.street.should == '123 Example'
|
@contact.address.street.should == '123 Example'
|
||||||
|
@contact.legal_documents.count.should == 1
|
||||||
|
|
||||||
log = ApiLog::EppLog.last
|
log = ApiLog::EppLog.last
|
||||||
log.request_command.should == 'create'
|
log.request_command.should == 'create'
|
||||||
|
@ -156,7 +166,7 @@ describe 'EPP Contact', epp: true do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_xml = @epp_xml.update(defaults.deep_merge(overwrites))
|
update_xml = @epp_xml.update(defaults.deep_merge(overwrites), @legal_document)
|
||||||
epp_plain_request(update_xml, :xml)
|
epp_plain_request(update_xml, :xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -172,7 +182,10 @@ describe 'EPP Contact', epp: true do
|
||||||
response[:results][2][:msg].should ==
|
response[:results][2][:msg].should ==
|
||||||
'Required parameter missing: update > update > authInfo > pw'
|
'Required parameter missing: update > update > authInfo > pw'
|
||||||
response[:results][2][:result_code].should == '2003'
|
response[:results][2][:result_code].should == '2003'
|
||||||
response[:results].count.should == 3
|
response[:results][3][:msg].should ==
|
||||||
|
'Required parameter missing: extension > extdata > legalDocument'
|
||||||
|
response[:results][3][:result_code].should == '2003'
|
||||||
|
response[:results].count.should == 4
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns error if obj doesnt exist' do
|
it 'returns error if obj doesnt exist' do
|
||||||
|
@ -225,7 +238,7 @@ describe 'EPP Contact', epp: true do
|
||||||
id: { value: @contact.code },
|
id: { value: @contact.code },
|
||||||
authInfo: { pw: { value: @contact.auth_info } }
|
authInfo: { pw: { value: @contact.auth_info } }
|
||||||
}
|
}
|
||||||
delete_xml = @epp_xml.delete(defaults.deep_merge(overwrites))
|
delete_xml = @epp_xml.delete(defaults.deep_merge(overwrites), @legal_document)
|
||||||
epp_plain_request(delete_xml, :xml)
|
epp_plain_request(delete_xml, :xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -238,7 +251,10 @@ describe 'EPP Contact', epp: true do
|
||||||
response[:results][1][:msg].should ==
|
response[:results][1][:msg].should ==
|
||||||
'Required parameter missing: delete > delete > authInfo > pw'
|
'Required parameter missing: delete > delete > authInfo > pw'
|
||||||
response[:results][1][:result_code].should == '2003'
|
response[:results][1][:result_code].should == '2003'
|
||||||
response[:results].count.should == 2
|
response[:results][2][:msg].should ==
|
||||||
|
'Required parameter missing: extension > extdata > legalDocument'
|
||||||
|
response[:results][2][:result_code].should == '2003'
|
||||||
|
response[:results].count.should == 3
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns error if obj doesnt exist' do
|
it 'returns error if obj doesnt exist' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue