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:
Timo Võhmar 2023-05-18 12:08:12 +03:00 committed by GitHub
commit 30ab0f5750
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 116 additions and 11 deletions

View file

@ -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,13 @@ module Admin
def edit; end
def show
method = allowed_method(params[:records]) || 'api_users'
@result = @registrar.send(method.to_sym)
partial_name = "#{@registrar.name.parameterize}_#{method}"
render_by_format('admin/registrars/show', partial_name)
end
def update
if @registrar.update(registrar_params)
redirect_to [:admin, @registrar], notice: t('.updated')
@ -168,5 +175,10 @@ module Admin
def iban_max_length
Iban.max_length
end
def allowed_method(records_param)
allowed_methods = %w[api_users white_ips]
records_param if allowed_methods.include?(records_param)
end
end
end