mirror of
https://github.com/internetee/registry.git
synced 2025-07-19 17:25:57 +02:00
Create legal documents
This commit is contained in:
parent
4f10cccdfa
commit
e09ddd3138
10 changed files with 274 additions and 7 deletions
|
@ -35,6 +35,8 @@ class Domain < ActiveRecord::Base
|
|||
accepts_nested_attributes_for :dnskeys, allow_destroy: true,
|
||||
reject_if: proc { |attrs| attrs[:public_key].blank? }
|
||||
|
||||
has_many :legal_documents, as: :documentable
|
||||
|
||||
delegate :code, to: :owner_contact, prefix: true
|
||||
delegate :email, to: :owner_contact, prefix: true
|
||||
delegate :ident, to: :owner_contact, prefix: true
|
||||
|
|
|
@ -54,6 +54,7 @@ class Epp::EppDomain < Domain
|
|||
attach_contacts(self.class.parse_contacts_from_frame(parsed_frame))
|
||||
attach_nameservers(self.class.parse_nameservers_from_frame(parsed_frame))
|
||||
attach_statuses(self.class.parse_statuses_from_frame(parsed_frame))
|
||||
attach_legal_document(self.class.parse_legal_document_from_frame(parsed_frame))
|
||||
errors.empty?
|
||||
end
|
||||
|
||||
|
@ -92,6 +93,15 @@ class Epp::EppDomain < Domain
|
|||
errors.empty?
|
||||
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
|
||||
|
||||
def attach_owner_contact(code)
|
||||
return unless code
|
||||
self.owner_contact = Contact.find_by(code: code)
|
||||
|
@ -528,6 +538,16 @@ class Epp::EppDomain < Domain
|
|||
res
|
||||
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
|
||||
|
||||
def check_availability(domains)
|
||||
domains = [domains] if domains.is_a?(String)
|
||||
|
||||
|
|
3
app/models/legal_document.rb
Normal file
3
app/models/legal_document.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class LegalDocument < ActiveRecord::Base
|
||||
belongs_to :documentable, polymorphic: true
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue