Modified csv export file for admin domains

This commit is contained in:
Sergei Tsoganov 2023-04-14 10:56:12 +03:00
parent 7f0787b27f
commit b71a8ccf9f
3 changed files with 18 additions and 9 deletions

View file

@ -755,7 +755,10 @@ class Domain < ApplicationRecord
def as_csv_row
[
name,
"#{registrant_name}, #{registrant_ident_info}",
registrant_info[0],
registrant_info[1],
registrant_info[2],
registrant_info[3],
valid_to.to_formatted_s(:db),
registrar,
created_at.to_formatted_s(:db),
@ -774,15 +777,19 @@ class Domain < ApplicationRecord
generator.to_pdf
end
def registrant_name
return registrant.name if registrant
def registrant_info
if registrant
return [registrant.name, registrant.ident, registrant.ident_country_code,
registrant.ident_type]
end
ver = Version::ContactVersion.where(item_id: registrant_id).last
contact = Contact.all_versions_for([registrant_id], created_at).first
contact = ObjectVersionsParser.new(ver).parse if contact.nil? && ver
contact.try(:name) || 'Deleted'
[contact.try(:name), contact.try(:ident), contact.try(:ident_country_code),
contact.try(:ident_type)] || ['Deleted']
end
def registrant_ident_info
@ -791,8 +798,10 @@ class Domain < ApplicationRecord
def self.csv_header
[
'Domain', 'Registrant', 'Valid to', 'Registrar', 'Created at',
'Statuses', 'Admin. contacts', 'Tech. contacts', 'Nameservers', 'Force delete date', 'Force delete data'
'Domain', 'Registrant name', 'Registrant ident', 'Registrant ident country code',
'Registrant ident type', 'Valid to', 'Registrar', 'Created at',
'Statuses', 'Admin. contacts', 'Tech. contacts', 'Nameservers', 'Force delete date',
'Force delete data'
]
end

View file

@ -11,7 +11,7 @@ class Version::DomainVersion < PaperTrail::Version
[
domain.name,
domain.registrant_name,
domain.registrant_info[0],
domain.registrar,
event,
created_at.to_formatted_s(:db),

View file

@ -1,2 +1,2 @@
Domain,Registrant,Valid to,Registrar,Created at,Statuses,Admin. contacts,Tech. contacts,Nameservers,Force delete date,Force delete data
metro.test,"Jack, 12345678 [US org]",2010-07-05 00:00:00,Good Names,2010-07-05 07:30:00,[],"[""Jack, jack-001, 12345678 [US org]""]","[""Jack, jack-001, 12345678 [US org]""]","[""ns1.bestnames.test""]",,
Domain,Registrant name,Registrant ident,Registrant ident country code,Registrant ident type,Valid to,Registrar,Created at,Statuses,Admin. contacts,Tech. contacts,Nameservers,Force delete date,Force delete data
metro.test,Jack,12345678,US,org,2010-07-05 00:00:00,Good Names,2010-07-05 07:30:00,[],"[""Jack, jack-001, 12345678 [US org]""]","[""Jack, jack-001, 12345678 [US org]""]","[""ns1.bestnames.test""]",,

1 Domain Registrant Registrant name Registrant ident Registrant ident country code Registrant ident type Valid to Registrar Created at Statuses Admin. contacts Tech. contacts Nameservers Force delete date Force delete data
2 metro.test Jack, 12345678 [US org] Jack 12345678 US org 2010-07-05 00:00:00 Good Names 2010-07-05 07:30:00 [] ["Jack, jack-001, 12345678 [US org]"] ["Jack, jack-001, 12345678 [US org]"] ["ns1.bestnames.test"]