mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Merge remote-tracking branch 'origin/master' into 110687814-update_values
# Conflicts: # app/models/epp/domain.rb
This commit is contained in:
commit
ae3467a8b1
304 changed files with 3676 additions and 426401 deletions
|
@ -1,8 +1,8 @@
|
|||
class Admin::AccountActivitiesController < AdminController
|
||||
load_and_authorize_resource
|
||||
before_action :set_default_dates, only: [:index]
|
||||
|
||||
def index # rubocop: disable Metrics/AbcSize
|
||||
params[:q] ||= {}
|
||||
|
||||
ca_cache = params[:q][:created_at_lteq]
|
||||
begin
|
||||
|
@ -25,10 +25,11 @@ class Admin::AccountActivitiesController < AdminController
|
|||
@account_activities = @q.result.page(params[:page]).per(params[:results_per_page])
|
||||
sort = @account_activities.orders.map(&:to_sql).join(",")
|
||||
|
||||
# can do here inline SQL as it's our
|
||||
if params[:page] && params[:page].to_i > 1
|
||||
@sum = @q.result.reorder(sort).limit(@account_activities.offset_value) + @b.result.where.not(id: @q.result.map(&:id))
|
||||
@sum = @q.result.reorder(sort).limit(@account_activities.offset_value).sum(:sum) + @b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum)
|
||||
else
|
||||
@sum = @b.result.where.not(id: @q.result.map(&:id))
|
||||
@sum = @b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -40,4 +41,20 @@ class Admin::AccountActivitiesController < AdminController
|
|||
|
||||
params[:q][:created_at_lteq] = ca_cache
|
||||
end
|
||||
|
||||
def set_default_dates
|
||||
params[:q] ||= {}
|
||||
|
||||
if params[:q][:created_at_gteq].nil? && params[:q][:created_at_lteq].nil? && params[:created_after].present?
|
||||
|
||||
default_date = params[:created_after]
|
||||
|
||||
if !['today', 'tomorrow', 'yesterday'].include?(default_date)
|
||||
default_date = 'today'
|
||||
end
|
||||
|
||||
params[:q][:created_at_gteq] = Date.send(default_date).strftime("%Y-%m-%d")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,46 +2,54 @@ class Admin::BlockedDomainsController < AdminController
|
|||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
bd = BlockedDomain.pluck(:name)
|
||||
if bd
|
||||
@blocked_domains = bd.to_yaml.gsub("---\n", '').gsub("-", '').gsub(" ", '')
|
||||
end
|
||||
|
||||
params[:q] ||= {}
|
||||
domains = BlockedDomain.all.order(:name)
|
||||
@q = domains.search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
@domain = BlockedDomain.new
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@blocked_domains = params[:blocked_domains]
|
||||
|
||||
begin
|
||||
params[:blocked_domains] = "---\n" if params[:blocked_domains].blank?
|
||||
names = YAML.load(params[:blocked_domains])
|
||||
fail if names == false
|
||||
rescue
|
||||
flash.now[:alert] = I18n.t('invalid_yaml')
|
||||
logger.warn 'Invalid YAML'
|
||||
render :index and return
|
||||
end
|
||||
@domain = BlockedDomain.new(blocked_domain_params)
|
||||
|
||||
names = names.split(' ')
|
||||
result = true
|
||||
BlockedDomain.transaction do
|
||||
existing = BlockedDomain.any_of_domains(names).pluck(:id)
|
||||
BlockedDomain.where.not(id: existing).destroy_all
|
||||
|
||||
names.each do |name|
|
||||
rec = BlockedDomain.find_or_initialize_by(name: name)
|
||||
unless rec.save
|
||||
result = false
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if result
|
||||
flash[:notice] = I18n.t('record_updated')
|
||||
redirect_to :back
|
||||
if @domain.save
|
||||
flash[:notice] = I18n.t('domain_added')
|
||||
redirect_to admin_blocked_domains_path
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||
render :index
|
||||
flash.now[:alert] = I18n.t('failed_to_add_domain')
|
||||
render 'new'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def delete
|
||||
|
||||
if BlockedDomain.find(params[:id]).destroy
|
||||
flash[:notice] = I18n.t('domain_deleted')
|
||||
redirect_to admin_blocked_domains_path
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_delete_domain')
|
||||
redirect_to admin_blocked_domains_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def blocked_domain_params
|
||||
params.require(:blocked_domain).permit(:name)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
@domain = BlockedDomain.find(params[:id])
|
||||
end
|
||||
end
|
|
@ -20,6 +20,8 @@ class Admin::ContactsController < AdminController
|
|||
else
|
||||
contacts = Contact.includes(:registrar)
|
||||
end
|
||||
contacts = contacts.where("ident_country_code is null or ident_country_code=''") if params[:only_no_country_code].eql?('1')
|
||||
|
||||
|
||||
normalize_search_parameters do
|
||||
@q = contacts.search(search_params)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class Admin::EppLogsController < AdminController
|
||||
load_and_authorize_resource class: ApiLog::EppLog
|
||||
before_action :set_default_dates, only: [:index]
|
||||
|
||||
def index
|
||||
@q = ApiLog::EppLog.search(params[:q])
|
||||
|
@ -10,4 +11,19 @@ class Admin::EppLogsController < AdminController
|
|||
def show
|
||||
@epp_log = ApiLog::EppLog.find(params[:id])
|
||||
end
|
||||
|
||||
def set_default_dates
|
||||
params[:q] ||= {}
|
||||
|
||||
if params[:q][:created_at_gteq].nil? && params[:q][:created_at_lteq].nil? && params[:created_after].present?
|
||||
default_date = params[:created_after]
|
||||
|
||||
if !['today', 'tomorrow', 'yesterday'].include?(default_date)
|
||||
default_date = 'today'
|
||||
end
|
||||
|
||||
params[:q][:created_at_gteq] = Date.send(default_date).strftime("%Y-%m-%d")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ class Admin::InvoicesController < AdminController
|
|||
|
||||
def index
|
||||
@q = Invoice.includes(:account_activity).search(params[:q])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
@q.sorts = 'number desc' if @q.sorts.empty?
|
||||
@invoices = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class Admin::RegistrarsController < AdminController
|
|||
def registrar_params
|
||||
params.require(:registrar).permit(
|
||||
:name, :reg_no, :vat_no, :street, :city, :state, :zip, :billing_address,
|
||||
:country_code, :email, :phone, :billing_email, :code
|
||||
:country_code, :email, :phone, :billing_email, :code, :test_registrar
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class Admin::ReppLogsController < AdminController
|
||||
load_and_authorize_resource class: ApiLog::ReppLog
|
||||
before_action :set_default_dates, only: [:index]
|
||||
|
||||
def index
|
||||
@q = ApiLog::ReppLog.search(params[:q])
|
||||
|
@ -10,4 +11,20 @@ class Admin::ReppLogsController < AdminController
|
|||
def show
|
||||
@repp_log = ApiLog::ReppLog.find(params[:id])
|
||||
end
|
||||
|
||||
def set_default_dates
|
||||
params[:q] ||= {}
|
||||
|
||||
if params[:q][:created_at_gteq].nil? && params[:q][:created_at_lteq].nil? && params[:created_after].present?
|
||||
|
||||
default_date = params[:created_after]
|
||||
|
||||
if !['today', 'tomorrow', 'yesterday'].include?(default_date)
|
||||
default_date = 'today'
|
||||
end
|
||||
|
||||
params[:q][:created_at_gteq] = Date.send(default_date).strftime("%Y-%m-%d")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,49 +1,68 @@
|
|||
class Admin::ReservedDomainsController < AdminController
|
||||
load_and_authorize_resource
|
||||
before_action :set_domain, only: [:edit, :update]
|
||||
|
||||
def index
|
||||
names = ReservedDomain.pluck(:name, :password).each_with_object({}){|domain, hash| hash[domain[0]] = domain[1]}
|
||||
names.names = nil if names.blank?
|
||||
@reserved_domains = names.to_yaml.gsub(/---.?\n/, '').gsub(/\.\.\..?\n/, '')
|
||||
|
||||
params[:q] ||= {}
|
||||
domains = ReservedDomain.all.order(:name)
|
||||
@q = domains.search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@domain = ReservedDomain.new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@reserved_domains = params[:reserved_domains]
|
||||
|
||||
begin
|
||||
params[:reserved_domains] = "---\n" if params[:reserved_domains].blank?
|
||||
names = YAML.load(params[:reserved_domains])
|
||||
fail if names == false
|
||||
rescue
|
||||
flash.now[:alert] = I18n.t('invalid_yaml')
|
||||
logger.warn 'Invalid YAML'
|
||||
render :index and return
|
||||
end
|
||||
@domain = ReservedDomain.new(reserved_domain_params)
|
||||
|
||||
result = true
|
||||
ReservedDomain.transaction do
|
||||
# removing old ones
|
||||
existing = ReservedDomain.any_of_domains(names.keys).pluck(:id)
|
||||
ReservedDomain.where.not(id: existing).destroy_all
|
||||
|
||||
#updating and adding
|
||||
names.each do |name, psw|
|
||||
rec = ReservedDomain.find_or_initialize_by(name: name)
|
||||
rec.password = psw
|
||||
|
||||
unless rec.save
|
||||
result = false
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if result
|
||||
flash[:notice] = I18n.t('record_updated')
|
||||
redirect_to :back
|
||||
if @domain.save
|
||||
flash[:notice] = I18n.t('domain_added')
|
||||
redirect_to admin_reserved_domains_path
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||
render :index
|
||||
flash.now[:alert] = I18n.t('failed_to_add_domain')
|
||||
render 'new'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
if @domain.update(reserved_domain_params)
|
||||
flash[:notice] = I18n.t('domain_updated')
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_domain')
|
||||
end
|
||||
render 'edit'
|
||||
|
||||
end
|
||||
|
||||
def delete
|
||||
|
||||
if ReservedDomain.find(params[:id]).destroy
|
||||
flash[:notice] = I18n.t('domain_deleted')
|
||||
redirect_to admin_reserved_domains_path
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_delete_domain')
|
||||
redirect_to admin_reserved_domains_path
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def reserved_domain_params
|
||||
params.require(:reserved_domain).permit(:name, :password)
|
||||
end
|
||||
|
||||
def set_domain
|
||||
@domain = ReservedDomain.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -19,6 +19,8 @@ class Epp::ContactsController < EppController
|
|||
authorize! :create, Epp::Contact
|
||||
@contact = Epp::Contact.new(params[:parsed_frame], current_user.registrar)
|
||||
|
||||
@contact.add_legal_file_to_new(params[:parsed_frame])
|
||||
|
||||
if @contact.save
|
||||
render_epp_response '/epp/contacts/create'
|
||||
else
|
||||
|
@ -39,7 +41,7 @@ class Epp::ContactsController < EppController
|
|||
def delete
|
||||
authorize! :delete, @contact, @password
|
||||
|
||||
if @contact.destroy_and_clean
|
||||
if @contact.destroy_and_clean(params[:parsed_frame])
|
||||
render_epp_response '/epp/contacts/delete'
|
||||
else
|
||||
handle_errors(@contact)
|
||||
|
|
|
@ -30,6 +30,8 @@ class Epp::DomainsController < EppController
|
|||
handle_errors and return unless balance_ok?('create') # loads pricelist in this method
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
@domain.add_legal_file_to_new(params[:parsed_frame])
|
||||
|
||||
if @domain.save # TODO: Maybe use validate: false here because we have already validated the domain?
|
||||
current_user.registrar.debit!({
|
||||
sum: @domain_pricelist.price.amount,
|
||||
|
|
|
@ -361,9 +361,10 @@ class EppController < ApplicationController
|
|||
if request_command == 'login' && frame.present?
|
||||
frame.gsub!(/pw>.+<\//, 'pw>[FILTERED]</')
|
||||
end
|
||||
trimmed_request = frame.gsub(/<eis:legalDocument([^>]+)>([^<])+<\/eis:legalDocument>/, "<eis:legalDocument>[FILTERED]</eis:legalDocument>")
|
||||
|
||||
ApiLog::EppLog.create({
|
||||
request: frame,
|
||||
request: trimmed_request,
|
||||
request_command: request_command,
|
||||
request_successful: epp_errors.empty?,
|
||||
request_object: params[:epp_object_type],
|
||||
|
|
26
app/controllers/registrant/contacts_controller.rb
Normal file
26
app/controllers/registrant/contacts_controller.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
class Registrant::ContactsController < RegistrantController
|
||||
helper_method :domain_ids
|
||||
def show
|
||||
@contact = Contact.where(id: contacts).find_by(id: params[:id])
|
||||
@current_user = current_user
|
||||
|
||||
authorize! :read, @contact
|
||||
end
|
||||
|
||||
def contacts
|
||||
begin
|
||||
DomainContact.where(domain_id: domain_ids).pluck(:contact_id) | Domain.where(id: domain_ids).pluck(:registrant_id)
|
||||
rescue Soap::Arireg::NotAvailableError => error
|
||||
flash[:notice] = I18n.t(error.json[:message])
|
||||
Rails.logger.fatal("[EXCEPTION] #{error.to_s}")
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def domain_ids
|
||||
@domain_ids ||= begin
|
||||
ident_cc, ident = @current_user.registrant_ident.to_s.split '-'
|
||||
BusinessRegistryCache.fetch_by_ident_and_cc(ident, ident_cc).associated_domain_ids
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,86 @@
|
|||
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 = domains.find(params[:id])
|
||||
authorize! :read, @domain
|
||||
end
|
||||
|
||||
def set_domain
|
||||
@domain = domains.find(params[:id])
|
||||
end
|
||||
|
||||
def domain_verification_url
|
||||
authorize! :view, :registrant_domains
|
||||
dom = domains.find(params[:id])
|
||||
if (dom.statuses.include?(DomainStatus::PENDING_UPDATE) || dom.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)) &&
|
||||
dom.pending_json.present?
|
||||
|
||||
@domain = dom
|
||||
confirm_path = get_confirm_path(dom.statuses)
|
||||
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
|
||||
|
||||
else
|
||||
flash[:warning] = I18n.t('available_verification_url_not_found')
|
||||
redirect_to registrant_domain_path(dom.id)
|
||||
end
|
||||
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
|
||||
|
||||
def get_confirm_path(statuses)
|
||||
if statuses.include?(DomainStatus::PENDING_UPDATE)
|
||||
"#{ENV['registrant_url']}/registrant/domain_update_confirms"
|
||||
elsif statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)
|
||||
"#{ENV['registrant_url']}/registrant/domain_delete_confirms"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
7
app/controllers/registrant/registrars_controller.rb
Normal file
7
app/controllers/registrant/registrars_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class Registrant::RegistrarsController < RegistrantController
|
||||
|
||||
def show
|
||||
@registrar = Registrar.find(params[:id])
|
||||
authorize! :read, @registrar
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue