diff --git a/app/controllers/admin/registrars_controller.rb b/app/controllers/admin/registrars_controller.rb index b552a8cb3..94ca74dad 100644 --- a/app/controllers/admin/registrars_controller.rb +++ b/app/controllers/admin/registrars_controller.rb @@ -3,7 +3,7 @@ require 'net/http' module Admin class RegistrarsController < BaseController # rubocop:disable Metrics/ClassLength load_and_authorize_resource - before_action :set_registrar, only: [:show, :edit, :update, :destroy] + before_action :set_registrar, only: %i[show edit update destroy] before_action :set_registrar_status_filter, only: [:index] helper_method :registry_vat_rate helper_method :iban_max_length @@ -39,6 +39,11 @@ module Admin def edit; end + def show + @result = @registrar.send(params[:records]) unless params[:records].blank? + render_by_format('admin/registrars/show', "#{@registrar.name.parameterize}_#{params[:records]}") + end + def update if @registrar.update(registrar_params) redirect_to [:admin, @registrar], notice: t('.updated') diff --git a/app/models/api_user.rb b/app/models/api_user.rb index a15b12a85..289e0e8d9 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -91,6 +91,25 @@ 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) diff --git a/app/models/white_ip.rb b/app/models/white_ip.rb index 7bbd8c18f..358fa82c7 100644 --- a/app/models/white_ip.rb +++ b/app/models/white_ip.rb @@ -72,5 +72,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 diff --git a/app/services/csv_generator.rb b/app/services/csv_generator.rb index d92beeddc..7a8055680 100644 --- a/app/services/csv_generator.rb +++ b/app/services/csv_generator.rb @@ -22,7 +22,7 @@ class CsvGenerator def custom_csv?(class_name) [ Version::DomainVersion, Version::ContactVersion, Domain, - Contact, Invoice, Account, AccountActivity + Contact, Invoice, Account, AccountActivity, ApiUser, WhiteIp ].include?(class_name) end end diff --git a/app/views/admin/registrars/show/_api_users.html.erb b/app/views/admin/registrars/show/_api_users.html.erb index fddccd9b7..7e3cb287d 100644 --- a/app/views/admin/registrars/show/_api_users.html.erb +++ b/app/views/admin/registrars/show/_api_users.html.erb @@ -1,4 +1,4 @@ -