mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Fix some CC issues
This commit is contained in:
parent
0d2cb6b7f2
commit
7c35083a8b
8 changed files with 48 additions and 30 deletions
|
@ -13,7 +13,8 @@ plugins:
|
||||||
enabled: true
|
enabled: true
|
||||||
config:
|
config:
|
||||||
languages:
|
languages:
|
||||||
- ruby
|
ruby:
|
||||||
|
mass_threshold: 26
|
||||||
- javascript
|
- javascript
|
||||||
eslint:
|
eslint:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Repp
|
module Repp
|
||||||
module V1
|
module V1
|
||||||
class BaseController < ActionController::API
|
class BaseController < ActionController::API # rubocop:disable Metrics/ClassLength
|
||||||
rescue_from ActiveRecord::RecordNotFound, with: :not_found_error
|
rescue_from ActiveRecord::RecordNotFound, with: :not_found_error
|
||||||
before_action :authenticate_user
|
before_action :authenticate_user
|
||||||
before_action :validate_webclient_ca
|
before_action :validate_webclient_ca
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'serializers/repp/contact'
|
require 'serializers/repp/contact'
|
||||||
module Repp
|
module Repp
|
||||||
module V1
|
module V1
|
||||||
class ContactsController < BaseController
|
class ContactsController < BaseController # rubocop:disable Metrics/ClassLength
|
||||||
before_action :find_contact, only: %i[show update destroy]
|
before_action :find_contact, only: %i[show update destroy]
|
||||||
|
|
||||||
api :get, '/repp/v1/contacts'
|
api :get, '/repp/v1/contacts'
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Repp
|
||||||
param :domain_name, String, required: true, desc: 'Domain name'
|
param :domain_name, String, required: true, desc: 'Domain name'
|
||||||
param :status, String, required: true, desc: 'Status to be removed'
|
param :status, String, required: true, desc: 'Status to be removed'
|
||||||
def destroy
|
def destroy
|
||||||
return editing_failed unless @domain.statuses.include?(params[:id])
|
return editing_failed unless domain_with_status?(params[:id])
|
||||||
|
|
||||||
@domain.statuses = @domain.statuses.delete(params[:id])
|
@domain.statuses = @domain.statuses.delete(params[:id])
|
||||||
if @domain.save
|
if @domain.save
|
||||||
|
@ -25,18 +25,22 @@ module Repp
|
||||||
param :domain_name, String, required: true, desc: 'Domain name'
|
param :domain_name, String, required: true, desc: 'Domain name'
|
||||||
param :status, String, required: true, desc: 'Status to be added'
|
param :status, String, required: true, desc: 'Status to be added'
|
||||||
def update
|
def update
|
||||||
return editing_failed if @domain.statuses.include?(params[:id])
|
return editing_failed if domain_with_status?(params[:id])
|
||||||
|
|
||||||
@domain.statuses = @domain.statuses << params[:id]
|
|
||||||
# rubocop:disable Style/AndOr
|
|
||||||
handle_errors(@domain) and return unless @domain.save
|
|
||||||
# rubocop:enable Style/AndOr
|
|
||||||
|
|
||||||
|
@domain.statuses << params[:id]
|
||||||
|
if @domain.save
|
||||||
render_success(data: { domain: @domain.name, status: params[:id] })
|
render_success(data: { domain: @domain.name, status: params[:id] })
|
||||||
|
else
|
||||||
|
handle_errors(@domain)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def domain_with_status?
|
||||||
|
@domain.statuses.include?(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
def verify_status
|
def verify_status
|
||||||
allowed_statuses = [DomainStatus::CLIENT_HOLD].freeze
|
allowed_statuses = [DomainStatus::CLIENT_HOLD].freeze
|
||||||
stat = params[:id]
|
stat = params[:id]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'serializers/repp/domain'
|
require 'serializers/repp/domain'
|
||||||
module Repp
|
module Repp
|
||||||
module V1
|
module V1
|
||||||
class DomainsController < BaseController
|
class DomainsController < BaseController # rubocop:disable Metrics/ClassLength
|
||||||
before_action :set_authorized_domain, only: %i[transfer_info destroy]
|
before_action :set_authorized_domain, only: %i[transfer_info destroy]
|
||||||
before_action :forward_registrar_id, only: %i[create destroy]
|
before_action :forward_registrar_id, only: %i[create destroy]
|
||||||
before_action :set_domain, only: %i[show update]
|
before_action :set_domain, only: %i[show update]
|
||||||
|
@ -11,13 +11,9 @@ module Repp
|
||||||
def index
|
def index
|
||||||
records = current_user.registrar.domains
|
records = current_user.registrar.domains
|
||||||
domains = records.limit(limit).offset(offset)
|
domains = records.limit(limit).offset(offset)
|
||||||
domains = domains.pluck(:name) unless index_params[:details] == 'true'
|
|
||||||
|
|
||||||
if index_params[:details] == 'true'
|
render_success(data: { domains: serialized_domains(domains),
|
||||||
domains = domains.map { |d| Serializers::Repp::Domain.new(d).to_json }
|
total_number_of_records: records.count })
|
||||||
end
|
|
||||||
|
|
||||||
render_success(data: { domains: domains, total_number_of_records: records.count })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
api :GET, '/repp/v1/domains/:domain_name'
|
api :GET, '/repp/v1/domains/:domain_name'
|
||||||
|
@ -136,6 +132,12 @@ module Repp
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def serialized_domains(domains)
|
||||||
|
return domains.pluck(:name) unless index_params[:details] == 'true'
|
||||||
|
|
||||||
|
domains.map { |d| Serializers::Repp::Domain.new(d).to_json }
|
||||||
|
end
|
||||||
|
|
||||||
def initiate_transfer(transfer)
|
def initiate_transfer(transfer)
|
||||||
domain = Epp::Domain.find_or_initialize_by(name: transfer[:domain_name])
|
domain = Epp::Domain.find_or_initialize_by(name: transfer[:domain_name])
|
||||||
action = Actions::DomainTransfer.new(domain, transfer[:transfer_code],
|
action = Actions::DomainTransfer.new(domain, transfer[:transfer_code],
|
||||||
|
|
|
@ -65,7 +65,7 @@ module Actions
|
||||||
|
|
||||||
def assign_domain_attributes
|
def assign_domain_attributes
|
||||||
domain.name = params[:name].strip.downcase
|
domain.name = params[:name].strip.downcase
|
||||||
domain.registrar = Registrar.find(params[:registrar_id])
|
domain.registrar = current_registrar
|
||||||
assign_domain_period
|
assign_domain_period
|
||||||
assign_domain_auth_codes
|
assign_domain_auth_codes
|
||||||
domain.dnskeys_attributes = params[:dnskeys_attributes] if params[:dnskeys_attributes]
|
domain.dnskeys_attributes = params[:dnskeys_attributes] if params[:dnskeys_attributes]
|
||||||
|
@ -111,9 +111,12 @@ module Actions
|
||||||
return unless domain.period
|
return unless domain.period
|
||||||
|
|
||||||
period = Integer(domain.period)
|
period = Integer(domain.period)
|
||||||
|
domain.expire_time = calculate_expiry(period)
|
||||||
|
end
|
||||||
|
|
||||||
|
def calculate_expiry(period)
|
||||||
plural_period_unit_name = (domain.period_unit == 'm' ? 'months' : 'years').to_sym
|
plural_period_unit_name = (domain.period_unit == 'm' ? 'months' : 'years').to_sym
|
||||||
exp = (Time.zone.now.advance(plural_period_unit_name => period) + 1.day).beginning_of_day
|
(Time.zone.now.advance(plural_period_unit_name => period) + 1.day).beginning_of_day
|
||||||
domain.expire_time = exp
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def action_billable?
|
def action_billable?
|
||||||
|
@ -173,5 +176,9 @@ module Actions
|
||||||
domain.errors.delete(:name_dirty) if domain.errors[:puny_label].any?
|
domain.errors.delete(:name_dirty) if domain.errors[:puny_label].any?
|
||||||
domain.errors.any?
|
domain.errors.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_registrar
|
||||||
|
Registrar.find(params[:registrar_id])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,11 +39,15 @@ module Actions
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def ask_delete_verification
|
||||||
if verify?
|
|
||||||
domain.registrant_verification_asked!(params, user.id)
|
domain.registrant_verification_asked!(params, user.id)
|
||||||
domain.pending_delete!
|
domain.pending_delete!
|
||||||
domain.manage_automatic_statuses
|
domain.manage_automatic_statuses
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
if verify?
|
||||||
|
ask_delete_verification
|
||||||
else
|
else
|
||||||
domain.set_pending_delete!
|
domain.set_pending_delete!
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,15 +11,15 @@ module Actions
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
|
if !domain.renewable? || domain.invalid?
|
||||||
|
domain.add_renew_epp_errors
|
||||||
|
false
|
||||||
|
else
|
||||||
renew
|
renew
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def renew
|
def renew
|
||||||
if !domain.renewable? || domain.invalid?
|
|
||||||
domain.add_renew_epp_errors
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
task = Domains::BulkRenew::SingleDomainRenew.run(domain: domain,
|
task = Domains::BulkRenew::SingleDomainRenew.run(domain: domain,
|
||||||
period: params[:period],
|
period: params[:period],
|
||||||
unit: params[:period_unit],
|
unit: params[:period_unit],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue