Merge pull request #85 from internetee/105846070-merge-with-105842700-arireg-for-registrant-port

105846070 merge with 105842700 arireg for registrant port
This commit is contained in:
Timo Võhmar 2016-02-29 17:48:17 +02:00
commit b60dc1d833
45 changed files with 2197 additions and 30 deletions

View file

@ -59,6 +59,7 @@ class Admin::SettingsController < AdminController
:transfer_wait_time,
:invoice_number_min,
:invoice_number_max,
:days_to_keep_business_registry_cache,
:days_to_keep_invoices_active,
:days_to_keep_overdue_invoices_active,
:days_to_renew_domain_before_expire,

View file

@ -32,7 +32,7 @@ class ApplicationController < ActionController::Base
if registrar_request?
registrar_root_url
elsif registrant_request?
registrant_root_url
registrant_login_url
elsif admin_request?
admin_root_url
end

View file

@ -0,0 +1,8 @@
class Registrant::ContactsController < RegistrantController
def show
@contact = Contact.find(params[:id])
authorize! :read, @contact
@contact.valid?
end
end

View file

@ -1,5 +1,64 @@
class Registrant::DomainsController < RegistrantController
def index
authorize! :view, :registrant_domains
authorize! :view, :registrant_domains
params[:q] ||= {}
normalize_search_parameters do
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
end
end
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
end
def show
@domain = Domain.find(params[:id])
if !(domains.include?(@domain) || @domain.valid?)
redirect_to registrant_domains_path
end
authorize! :read, @domain
end
def set_domain
@domain = Domain.find(params[:id])
end
def download_list
authorize! :view, :registrant_domains
params[:q] ||= {}
normalize_search_parameters do
@q = domains.search(params[:q])
@domains = @q
end
respond_to do |format|
format.csv { render text: @domains.result.to_csv }
format.pdf do
pdf = @domains.result.pdf(render_to_string('registrant/domains/download_list', layout: false))
send_data pdf, filename: 'domains.pdf'
end
end
end
def domains
ident_cc, ident = @current_user.registrant_ident.split '-'
begin
BusinessRegistryCache.fetch_associated_domains ident, ident_cc
rescue Soap::Arireg::NotAvailableError => error
flash[:notice] = I18n.t(error.json[:message])
Rails.logger.fatal("[EXCEPTION] #{error.to_s}")
current_user.domains
end
end
def normalize_search_parameters
ca_cache = params[:q][:valid_to_lteq]
begin
end_time = params[:q][:valid_to_lteq].try(:to_date)
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
end
yield
params[:q][:valid_to_lteq] = ca_cache
end
end

View file

@ -0,0 +1,8 @@
class Registrant::RegistrantsController < RegistrantController
def show
@contact = Registrant.find(params[:id])
authorize! :read, @contact
@contact.valid?
end
end

View file

@ -0,0 +1,7 @@
class Registrant::RegistrarsController < RegistrantController
def show
@registrar = Registrar.find(params[:id])
authorize! :read, @registrar
end
end

View file

@ -6,15 +6,10 @@ class Registrant::SessionsController < Devise::SessionsController
# rubocop: disable Metrics/AbcSize
def id
if Rails.env.development?
sign_in(RegistrantUser.find_or_create_by_idc_data('test'), event: :authentication)
return redirect_to registrant_root_url
end
id_code, id_issuer = request.env['SSL_CLIENT_S_DN'], request.env['SSL_CLIENT_I_DN_O']
id_code, id_issuer = 'test', RegistrantUser::ACCEPTED_ISSUER if Rails.env.development?
logger.error request.env['SSL_CLIENT_S_DN']
logger.error request.env['SSL_CLIENT_S_DN'].encoding
logger.error request.env['SSL_CLIENT_I_DN_O']
@user = RegistrantUser.find_or_create_by_idc_data(request.env['SSL_CLIENT_S_DN'], request.env['SSL_CLIENT_I_DN_O'])
@user = RegistrantUser.find_or_create_by_idc_data(id_code, id_issuer)
if @user
sign_in(@user, event: :authentication)
redirect_to registrant_root_url

View file

@ -1,5 +1,9 @@
class Registrant::WhoisController < RegistrantController
def index
authorize! :view, :registrant_whois
if params[:domain_name].present?
@domain = WhoisRecord.find_by(name: params[:domain_name]);
end
end
end