mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
Strory#108869472 - merge master
This commit is contained in:
commit
f49ee67e83
393 changed files with 5729 additions and 426963 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
|
||||
|
@ -12,11 +12,28 @@ class Admin::AccountActivitiesController < AdminController
|
|||
logger.warn('Invalid date')
|
||||
end
|
||||
|
||||
balance_params = params[:q].deep_dup
|
||||
|
||||
if balance_params[:created_at_gteq]
|
||||
balance_params.delete('created_at_gteq')
|
||||
end
|
||||
|
||||
@q = AccountActivity.includes(:invoice, account: :registrar).search(params[:q])
|
||||
@b = AccountActivity.search(balance_params)
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
|
||||
@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).sum(:sum) + @b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum)
|
||||
else
|
||||
@sum = @b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { @account_activities = @q.result.page(params[:page]) }
|
||||
format.html
|
||||
format.csv do
|
||||
send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
|
||||
end
|
||||
|
@ -24,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,22 +2,54 @@ class Admin::BlockedDomainsController < AdminController
|
|||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
bd = BlockedDomain.first_or_initialize
|
||||
@blocked_domains = bd.names.join("\n")
|
||||
|
||||
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
|
||||
names = params[:blocked_domains].split("\r\n").map(&:strip)
|
||||
|
||||
bd = BlockedDomain.first_or_create
|
||||
@domain = BlockedDomain.new(blocked_domain_params)
|
||||
|
||||
if bd.update(names: names)
|
||||
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
|
||||
@blocked_domains = params[:blocked_domains]
|
||||
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
|
|
@ -4,20 +4,28 @@ class Admin::ContactsController < AdminController
|
|||
|
||||
def index
|
||||
params[:q] ||= {}
|
||||
@q = Contact.includes(:registrar).search(params[:q])
|
||||
@contacts = @q.result.page(params[:page])
|
||||
search_params = params[:q].deep_dup
|
||||
|
||||
if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant')
|
||||
search_params[:registrant_domains_id_not_null] = 1
|
||||
end
|
||||
|
||||
@q = Contact.includes(:registrar).joins(:registrar).select('contacts.*, registrars.name').search(search_params)
|
||||
@contacts = @q.result(distinct: :true).page(params[:page])
|
||||
|
||||
if params[:statuses_contains]
|
||||
contacts = Contact.includes(:registrar).where(
|
||||
contacts = Contact.includes(:registrar).joins(:registrar).select('contacts.*, registrars.name').where(
|
||||
"contacts.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
|
||||
)
|
||||
else
|
||||
contacts = Contact.includes(:registrar)
|
||||
contacts = Contact.includes(:registrar).joins(:registrar).select('contacts.*, registrars.name')
|
||||
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(params[:q])
|
||||
@contacts = @q.result.page(params[:page])
|
||||
@q = contacts.includes(:registrar).joins(:registrar).select('contacts.*, registrars.name').search(search_params)
|
||||
@contacts = @q.result.uniq.page(params[:page])
|
||||
end
|
||||
|
||||
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
|
||||
|
|
|
@ -9,7 +9,7 @@ class Admin::DomainsController < AdminController
|
|||
params[:q] ||= {}
|
||||
if params[:statuses_contains]
|
||||
domains = Domain.includes(:registrar, :registrant).where(
|
||||
"statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
|
||||
"domains.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
|
||||
)
|
||||
else
|
||||
domains = Domain.includes(:registrar, :registrant)
|
||||
|
|
|
@ -1,13 +1,33 @@
|
|||
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])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
@epp_logs = @q.result.page(params[:page])
|
||||
|
||||
@epp_logs = @q.result
|
||||
@epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present?
|
||||
@epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present?
|
||||
@epp_logs = @epp_logs.page(params[:page])
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -5,9 +5,7 @@ class Admin::PendingDeletesController < AdminController
|
|||
def update
|
||||
authorize! :update, :pending
|
||||
|
||||
@epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending
|
||||
@epp_domain.is_admin= true
|
||||
if @epp_domain.apply_pending_delete!
|
||||
if registrant_verification.domain_registrant_delete_confirm!
|
||||
redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied)
|
||||
else
|
||||
redirect_to admin_edit_domain_path(@domain.id), alert: t(:failure)
|
||||
|
@ -17,7 +15,7 @@ class Admin::PendingDeletesController < AdminController
|
|||
def destroy
|
||||
authorize! :destroy, :pending
|
||||
|
||||
if @domain.clean_pendings!
|
||||
if registrant_verification.domain_registrant_delete_reject!
|
||||
redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed)
|
||||
else
|
||||
redirect_to admin_domain_path(@domain.id), alert: t(:failure)
|
||||
|
@ -26,6 +24,14 @@ class Admin::PendingDeletesController < AdminController
|
|||
|
||||
private
|
||||
|
||||
def registrant_verification
|
||||
# steal token
|
||||
token = @domain.registrant_verification_token
|
||||
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
|
||||
domain_name: @domain.name,
|
||||
verification_token: token)
|
||||
end
|
||||
|
||||
def find_domain
|
||||
@domain = Domain.find(params[:domain_id])
|
||||
end
|
||||
|
|
|
@ -5,8 +5,7 @@ class Admin::PendingUpdatesController < AdminController
|
|||
def update
|
||||
authorize! :update, :pending
|
||||
|
||||
@epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending
|
||||
if @epp_domain.apply_pending_update!
|
||||
if registrant_verification.domain_registrant_change_confirm!
|
||||
redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied)
|
||||
else
|
||||
redirect_to edit_admin_domain_path(@domain.id), alert: t(:failure)
|
||||
|
@ -15,14 +14,21 @@ class Admin::PendingUpdatesController < AdminController
|
|||
|
||||
def destroy
|
||||
authorize! :destroy, :pending
|
||||
|
||||
if @domain.clean_pendings!
|
||||
if registrant_verification.domain_registrant_change_reject!
|
||||
redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed)
|
||||
else
|
||||
redirect_to admin_domain_path(@domain.id), alert: t(:failure)
|
||||
end
|
||||
end
|
||||
|
||||
def registrant_verification
|
||||
# steal token
|
||||
token = @domain.registrant_verification_token
|
||||
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
|
||||
domain_name: @domain.name,
|
||||
verification_token: token)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_domain
|
||||
|
|
|
@ -6,7 +6,7 @@ class Admin::RegistrarsController < AdminController
|
|||
end
|
||||
|
||||
def index
|
||||
@q = Registrar.ordered.search(params[:q])
|
||||
@q = Registrar.joins(:accounts).ordered.search(params[:q])
|
||||
@registrars = @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,13 +1,34 @@
|
|||
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])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
@repp_logs = @q.result.page(params[:page])
|
||||
|
||||
@repp_logs = @q.result
|
||||
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present?
|
||||
@repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present?
|
||||
@repp_logs = @repp_logs.page(params[:page])
|
||||
end
|
||||
|
||||
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,51 +1,68 @@
|
|||
class Admin::ReservedDomainsController < AdminController
|
||||
load_and_authorize_resource
|
||||
before_action :set_domain, only: [:edit, :update]
|
||||
|
||||
def index
|
||||
names = ReservedDomain.pluck(:names).each_with_object({}){|e_h,h| h.merge!(e_h)}
|
||||
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).delete_all
|
||||
|
||||
#updating and adding
|
||||
names.each do |name, psw|
|
||||
rec = ReservedDomain.by_domain(name).first
|
||||
rec ||= ReservedDomain.new
|
||||
rec.names = {name => 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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue