mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Merge pull request #2576 from internetee/2567-add-csv-export-to-registrar-users
Added csv export to registrar api_users and white_ips
This commit is contained in:
commit
30ab0f5750
11 changed files with 116 additions and 11 deletions
|
@ -91,6 +91,24 @@ class ApiUser < User
|
|||
another_api_user.identity_code == identity_code
|
||||
end
|
||||
|
||||
def as_csv_row
|
||||
[
|
||||
username,
|
||||
plain_text_password,
|
||||
identity_code,
|
||||
roles.join(', '),
|
||||
active,
|
||||
accredited?,
|
||||
accreditation_expire_date,
|
||||
created_at, updated_at
|
||||
]
|
||||
end
|
||||
|
||||
def self.csv_header
|
||||
['Username', 'Password', 'Identity Code', 'Role', 'Active', 'Accredited',
|
||||
'Accreditation Expire Date', 'Created', 'Updated']
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def machine_readable_certificate(cert)
|
||||
|
|
|
@ -13,6 +13,7 @@ class WhiteIp < ApplicationRecord
|
|||
|
||||
def validate_ipv4_and_ipv6
|
||||
return if ipv4.present? || ipv6.present?
|
||||
|
||||
errors.add(:base, I18n.t(:ipv4_or_ipv6_must_be_present))
|
||||
end
|
||||
|
||||
|
@ -32,12 +33,12 @@ class WhiteIp < ApplicationRecord
|
|||
errors.add(:ipv6, :invalid)
|
||||
end
|
||||
|
||||
API = 'api'
|
||||
REGISTRAR = 'registrar'
|
||||
INTERFACES = [API, REGISTRAR]
|
||||
API = 'api'.freeze
|
||||
REGISTRAR = 'registrar'.freeze
|
||||
INTERFACES = [API, REGISTRAR].freeze
|
||||
|
||||
scope :api, -> { where("interfaces @> ?::varchar[]", "{#{API}}") }
|
||||
scope :registrar_area, -> { where("interfaces @> ?::varchar[]", "{#{REGISTRAR}}") }
|
||||
scope :api, -> { where('interfaces @> ?::varchar[]', "{#{API}}") }
|
||||
scope :registrar_area, -> { where('interfaces @> ?::varchar[]', "{#{REGISTRAR}}") }
|
||||
|
||||
def interfaces=(interfaces)
|
||||
super(interfaces.reject(&:blank?))
|
||||
|
@ -72,5 +73,19 @@ class WhiteIp < ApplicationRecord
|
|||
rescue StandardError => _e
|
||||
nil
|
||||
end
|
||||
|
||||
def csv_header
|
||||
%w[IPv4 IPv6 Interfaces Created Updated]
|
||||
end
|
||||
end
|
||||
|
||||
def as_csv_row
|
||||
[
|
||||
ipv4,
|
||||
ipv6,
|
||||
interfaces.join(', ').upcase,
|
||||
created_at,
|
||||
updated_at,
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue