mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Fix namespaces for Zeitwerk class loader
This commit is contained in:
parent
32634c7a8b
commit
43b3033991
78 changed files with 666 additions and 704 deletions
|
@ -31,6 +31,9 @@ plugins:
|
|||
rubocop:
|
||||
enabled: true
|
||||
channel: rubocop-0-74
|
||||
checks:
|
||||
Rubocop/Style/ClassAndModuleChildren:
|
||||
enabled: false
|
||||
checks:
|
||||
method-lines:
|
||||
config:
|
||||
|
|
|
@ -2,12 +2,12 @@ module Admin
|
|||
class ContactVersionsController < BaseController
|
||||
include ObjectVersionsHelper
|
||||
|
||||
load_and_authorize_resource
|
||||
load_and_authorize_resource class: Version::ContactVersion
|
||||
|
||||
def index
|
||||
params[:q] ||= {}
|
||||
|
||||
@q = ContactVersion.search(params[:q])
|
||||
@q = Version::ContactVersion.search(params[:q])
|
||||
@versions = @q.result.page(params[:page])
|
||||
search_params = params[:q].deep_dup
|
||||
|
||||
|
@ -23,7 +23,7 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
versions = ContactVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
|
||||
versions = Version::ContactVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
|
||||
@q = versions.search(params[:q])
|
||||
@versions = @q.result.page(params[:page])
|
||||
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
@ -32,8 +32,8 @@ module Admin
|
|||
|
||||
def show
|
||||
per_page = 7
|
||||
@version = ContactVersion.find(params[:id])
|
||||
@versions = ContactVersion.where(item_id: @version.item_id).order(created_at: :desc, id: :desc)
|
||||
@version = Version::ContactVersion.find(params[:id])
|
||||
@versions = Version::ContactVersion.where(item_id: @version.item_id).order(created_at: :desc, id: :desc)
|
||||
@versions_map = @versions.all.map(&:id)
|
||||
|
||||
# what we do is calc amount of results until needed version
|
||||
|
@ -49,7 +49,7 @@ module Admin
|
|||
end
|
||||
|
||||
def search
|
||||
render json: ContactVersion.search_by_query(params[:q])
|
||||
render json: Version::ContactVersion.search_by_query(params[:q])
|
||||
end
|
||||
|
||||
def create_where_string(key, value)
|
||||
|
|
|
@ -2,12 +2,12 @@ module Admin
|
|||
class DomainVersionsController < BaseController
|
||||
include ObjectVersionsHelper
|
||||
|
||||
load_and_authorize_resource
|
||||
load_and_authorize_resource class: Version::DomainVersion
|
||||
|
||||
def index
|
||||
params[:q] ||= {}
|
||||
|
||||
@q = DomainVersion.includes(:item).search(params[:q])
|
||||
@q = Version::DomainVersion.includes(:item).search(params[:q])
|
||||
@versions = @q.result.page(params[:page])
|
||||
search_params = params[:q].deep_dup
|
||||
|
||||
|
@ -40,7 +40,7 @@ module Admin
|
|||
whereS += " AND object->>'registrar_id' IN (#{registrars.map { |r| "'#{r.id.to_s}'" }.join ','})" if registrars.present?
|
||||
whereS += " AND 1=0" if registrars == []
|
||||
|
||||
versions = DomainVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
|
||||
versions = Version::DomainVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
|
||||
@q = versions.search(params[:q])
|
||||
@versions = @q.result.page(params[:page])
|
||||
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
@ -50,8 +50,8 @@ module Admin
|
|||
|
||||
def show
|
||||
per_page = 7
|
||||
@version = DomainVersion.find(params[:id])
|
||||
@versions = DomainVersion.where(item_id: @version.item_id).order(created_at: :desc, id: :desc)
|
||||
@version = Version::DomainVersion.find(params[:id])
|
||||
@versions = Version::DomainVersion.where(item_id: @version.item_id).order(created_at: :desc, id: :desc)
|
||||
@versions_map = @versions.all.map(&:id)
|
||||
|
||||
# what we do is calc amount of results until needed version
|
||||
|
@ -67,7 +67,7 @@ module Admin
|
|||
end
|
||||
|
||||
def search
|
||||
render json: DomainVersion.search_by_query(params[:q])
|
||||
render json: Version::DomainVersion.search_by_query(params[:q])
|
||||
end
|
||||
|
||||
def create_where_string(key, value)
|
||||
|
|
|
@ -17,7 +17,7 @@ class Registrar
|
|||
private
|
||||
|
||||
def check_ip_restriction
|
||||
ip_restriction = Authorization::RestrictedIP.new(request.ip)
|
||||
ip_restriction = Authorization::RestrictedIp.new(request.ip)
|
||||
allowed = ip_restriction.can_access_registrar_area?(current_registrar_user.registrar)
|
||||
|
||||
return if allowed
|
||||
|
|
|
@ -49,7 +49,7 @@ class Registrar
|
|||
domain_presenters << ::DomainPresenter.new(domain: domain, view: view_context)
|
||||
end
|
||||
|
||||
raw_csv = Registrar::DomainListCSVPresenter.new(domains: domain_presenters,
|
||||
raw_csv = Registrar::DomainListCsvPresenter.new(domains: domain_presenters,
|
||||
view: view_context).to_s
|
||||
filename = "Domains_#{l(Time.zone.now, format: :filename)}.csv"
|
||||
send_data raw_csv, filename: filename, type: "#{Mime[:csv]}; charset=utf-8"
|
||||
|
|
|
@ -72,7 +72,7 @@ class Registrar
|
|||
end
|
||||
|
||||
def check_ip_restriction
|
||||
ip_restriction = Authorization::RestrictedIP.new(request.ip)
|
||||
ip_restriction = Authorization::RestrictedIp.new(request.ip)
|
||||
allowed = ip_restriction.can_access_registrar_area_sign_in_page?
|
||||
|
||||
return if allowed
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class PunycodeInterceptor
|
||||
class Interceptors::PunycodeInterceptor
|
||||
class << self
|
||||
def delivering_email(message)
|
||||
message.from = encode_addresses_as_punycode(message.from)
|
||||
|
|
|
@ -89,8 +89,8 @@ class Ability
|
|||
can :manage, BlockedDomain
|
||||
can :manage, ReservedDomain
|
||||
can :manage, DNS::Zone
|
||||
can :manage, DomainVersion
|
||||
can :manage, ContactVersion
|
||||
can :manage, Version::DomainVersion
|
||||
can :manage, Version::ContactVersion
|
||||
can :manage, Billing::Price
|
||||
can :manage, User
|
||||
can :manage, ApiUser
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class Action < ApplicationRecord
|
||||
has_paper_trail versions: { class_name: 'ActionVersion' }
|
||||
has_paper_trail versions: { class_name: 'Version::ActionVersion' }
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :contact
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module Authorization
|
||||
class RestrictedIP
|
||||
class RestrictedIp
|
||||
def initialize(ip)
|
||||
@ip = ip
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Billing
|
||||
class Price < ApplicationRecord
|
||||
include Concerns::Billing::Price::Expirable
|
||||
include Billing::Price::Expirable
|
||||
include Versions
|
||||
|
||||
belongs_to :zone, class_name: 'DNS::Zone', required: true
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module Concerns::Billing::Price::Expirable
|
||||
module Billing::Price::Expirable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
|
|
|
@ -1,68 +1,64 @@
|
|||
module Concerns
|
||||
module Contact
|
||||
module Archivable
|
||||
extend ActiveSupport::Concern
|
||||
module Contact::Archivable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def archivable
|
||||
unlinked.find_each.select(&:archivable?)
|
||||
end
|
||||
end
|
||||
|
||||
def archivable?(post: false)
|
||||
inactive = inactive?
|
||||
|
||||
log("Found archivable contact id(#{id}), code (#{code})") if inactive && !post
|
||||
|
||||
inactive
|
||||
end
|
||||
|
||||
def archive(verified: false, notify: true, extra_log: false)
|
||||
unless verified
|
||||
raise 'Contact cannot be archived' unless archivable?(post: true)
|
||||
end
|
||||
|
||||
notify_registrar_about_archivation if notify
|
||||
write_to_registrar_log if extra_log
|
||||
destroy!
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def notify_registrar_about_archivation
|
||||
registrar.notifications.create!(
|
||||
text: I18n.t('contact_has_been_archived',
|
||||
contact_code: code, orphan_months: Setting.orphans_contacts_in_months)
|
||||
)
|
||||
end
|
||||
|
||||
def inactive?
|
||||
if DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period)
|
||||
return true
|
||||
end
|
||||
|
||||
DomainVersion.was_contact_linked?(id) ? false : created_at <= inactivity_period.ago
|
||||
end
|
||||
|
||||
def inactivity_period
|
||||
Setting.orphans_contacts_in_months.months
|
||||
end
|
||||
|
||||
def log(msg)
|
||||
@log ||= Logger.new(STDOUT)
|
||||
@log.info(msg)
|
||||
end
|
||||
|
||||
def write_to_registrar_log
|
||||
registrar_name = registrar.accounting_customer_code
|
||||
archive_path = ENV['contact_archivation_log_file_dir']
|
||||
registrar_log_path = "#{archive_path}/#{registrar_name}.txt"
|
||||
FileUtils.mkdir_p(archive_path) unless Dir.exist?(archive_path)
|
||||
|
||||
f = File.new(registrar_log_path, 'a+')
|
||||
f.write("#{code}\n")
|
||||
f.close
|
||||
end
|
||||
class_methods do
|
||||
def archivable
|
||||
unlinked.find_each.select(&:archivable?)
|
||||
end
|
||||
end
|
||||
|
||||
def archivable?(post: false)
|
||||
inactive = inactive?
|
||||
|
||||
log("Found archivable contact id(#{id}), code (#{code})") if inactive && !post
|
||||
|
||||
inactive
|
||||
end
|
||||
|
||||
def archive(verified: false, notify: true, extra_log: false)
|
||||
unless verified
|
||||
raise 'Contact cannot be archived' unless archivable?(post: true)
|
||||
end
|
||||
|
||||
notify_registrar_about_archivation if notify
|
||||
write_to_registrar_log if extra_log
|
||||
destroy!
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def notify_registrar_about_archivation
|
||||
registrar.notifications.create!(
|
||||
text: I18n.t('contact_has_been_archived',
|
||||
contact_code: code, orphan_months: Setting.orphans_contacts_in_months)
|
||||
)
|
||||
end
|
||||
|
||||
def inactive?
|
||||
if Version::DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period)
|
||||
return true
|
||||
end
|
||||
|
||||
Version::DomainVersion.was_contact_linked?(id) ? false : created_at <= inactivity_period.ago
|
||||
end
|
||||
|
||||
def inactivity_period
|
||||
Setting.orphans_contacts_in_months.months
|
||||
end
|
||||
|
||||
def log(msg)
|
||||
@log ||= Logger.new(STDOUT)
|
||||
@log.info(msg)
|
||||
end
|
||||
|
||||
def write_to_registrar_log
|
||||
registrar_name = registrar.accounting_customer_code
|
||||
archive_path = ENV['contact_archivation_log_file_dir']
|
||||
registrar_log_path = "#{archive_path}/#{registrar_name}.txt"
|
||||
FileUtils.mkdir_p(archive_path) unless Dir.exist?(archive_path)
|
||||
|
||||
f = File.new(registrar_log_path, 'a+')
|
||||
f.write("#{code}\n")
|
||||
f.close
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,26 +1,22 @@
|
|||
module Concerns
|
||||
module Contact
|
||||
module Disclosable
|
||||
extend ActiveSupport::Concern
|
||||
module Contact::Disclosable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
attr_accessor :disclosable_attributes
|
||||
end
|
||||
class_methods do
|
||||
attr_accessor :disclosable_attributes
|
||||
end
|
||||
|
||||
included do
|
||||
self.disclosable_attributes = %w[name email]
|
||||
validate :validate_disclosed_attributes
|
||||
end
|
||||
included do
|
||||
self.disclosable_attributes = %w[name email]
|
||||
validate :validate_disclosed_attributes
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def validate_disclosed_attributes
|
||||
return if disclosed_attributes.empty?
|
||||
def validate_disclosed_attributes
|
||||
return if disclosed_attributes.empty?
|
||||
|
||||
has_undisclosable_attributes = (disclosed_attributes - self.class.disclosable_attributes)
|
||||
.any?
|
||||
errors.add(:disclosed_attributes, :invalid) if has_undisclosable_attributes
|
||||
end
|
||||
end
|
||||
has_undisclosable_attributes = (disclosed_attributes - self.class.disclosable_attributes)
|
||||
.any?
|
||||
errors.add(:disclosed_attributes, :invalid) if has_undisclosable_attributes
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module Concerns::Contact::Identical
|
||||
module Contact::Identical
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
IDENTIFIABLE_ATTRIBUTES = %w[
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module Concerns::Domain::Activatable
|
||||
module Domain::Activatable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def active?
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
module Concerns
|
||||
module Domain
|
||||
module BulkUpdatable
|
||||
extend ActiveSupport::Concern
|
||||
module Domain::BulkUpdatable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def bulk_update_prohibited?
|
||||
discarded? || statuses_blocks_update?
|
||||
end
|
||||
def bulk_update_prohibited?
|
||||
discarded? || statuses_blocks_update?
|
||||
end
|
||||
|
||||
def statuses_blocks_update?
|
||||
prohibited_array = [DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||
DomainStatus::CLIENT_UPDATE_PROHIBITED]
|
||||
prohibited_array.any? { |block_status| statuses.include?(block_status) }
|
||||
end
|
||||
end
|
||||
def statuses_blocks_update?
|
||||
prohibited_array = [DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||
DomainStatus::CLIENT_UPDATE_PROHIBITED]
|
||||
prohibited_array.any? { |block_status| statuses.include?(block_status) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module Concerns::Domain::Deletable
|
||||
module Domain::Deletable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
DELETE_STATUSES = [
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module Concerns::Domain::Discardable
|
||||
module Domain::Discardable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def keep
|
||||
|
|
|
@ -1,44 +1,40 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Concerns
|
||||
module Domain
|
||||
module Disputable
|
||||
extend ActiveSupport::Concern
|
||||
module Domain::Disputable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
validate :validate_disputed
|
||||
end
|
||||
included do
|
||||
validate :validate_disputed
|
||||
end
|
||||
|
||||
def mark_as_disputed
|
||||
statuses.push(DomainStatus::DISPUTED) unless statuses.include?(DomainStatus::DISPUTED)
|
||||
save
|
||||
end
|
||||
def mark_as_disputed
|
||||
statuses.push(DomainStatus::DISPUTED) unless statuses.include?(DomainStatus::DISPUTED)
|
||||
save
|
||||
end
|
||||
|
||||
def unmark_as_disputed
|
||||
statuses.delete_if { |status| status == DomainStatus::DISPUTED }
|
||||
save
|
||||
end
|
||||
def unmark_as_disputed
|
||||
statuses.delete_if { |status| status == DomainStatus::DISPUTED }
|
||||
save
|
||||
end
|
||||
|
||||
def in_disputed_list?
|
||||
@in_disputed_list ||= Dispute.active.find_by(domain_name: name).present?
|
||||
end
|
||||
def in_disputed_list?
|
||||
@in_disputed_list ||= Dispute.active.find_by(domain_name: name).present?
|
||||
end
|
||||
|
||||
def disputed?
|
||||
Dispute.active.where(domain_name: name).any?
|
||||
end
|
||||
def disputed?
|
||||
Dispute.active.where(domain_name: name).any?
|
||||
end
|
||||
|
||||
def validate_disputed
|
||||
return if persisted? || !in_disputed_list?
|
||||
def validate_disputed
|
||||
return if persisted? || !in_disputed_list?
|
||||
|
||||
if reserved_pw.blank?
|
||||
errors.add(:base, :required_parameter_missing_disputed)
|
||||
return false
|
||||
end
|
||||
|
||||
return if Dispute.valid_auth?(name, reserved_pw)
|
||||
|
||||
errors.add(:base, :invalid_auth_information_reserved)
|
||||
end
|
||||
if reserved_pw.blank?
|
||||
errors.add(:base, :required_parameter_missing_disputed)
|
||||
return false
|
||||
end
|
||||
|
||||
return if Dispute.valid_auth?(name, reserved_pw)
|
||||
|
||||
errors.add(:base, :invalid_auth_information_reserved)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module Concerns::Domain::Expirable
|
||||
module Domain::Expirable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
|
||||
module Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
|
|
|
@ -1,63 +1,59 @@
|
|||
module Concerns
|
||||
module Domain
|
||||
module RegistryLockable
|
||||
extend ActiveSupport::Concern
|
||||
module Domain::RegistryLockable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def apply_registry_lock
|
||||
return unless registry_lockable?
|
||||
return if locked_by_registrant?
|
||||
def apply_registry_lock
|
||||
return unless registry_lockable?
|
||||
return if locked_by_registrant?
|
||||
|
||||
transaction do
|
||||
statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_DELETE_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
|
||||
self.locked_by_registrant_at = Time.zone.now
|
||||
alert_registrar_lock_changes!(lock: true)
|
||||
transaction do
|
||||
statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_DELETE_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
|
||||
self.locked_by_registrant_at = Time.zone.now
|
||||
alert_registrar_lock_changes!(lock: true)
|
||||
|
||||
save!
|
||||
end
|
||||
end
|
||||
|
||||
def registry_lockable?
|
||||
(statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION,
|
||||
DomainStatus::PENDING_CREATE, DomainStatus::PENDING_UPDATE,
|
||||
DomainStatus::PENDING_DELETE, DomainStatus::PENDING_RENEW,
|
||||
DomainStatus::PENDING_TRANSFER, DomainStatus::FORCE_DELETE]).empty?
|
||||
end
|
||||
|
||||
def locked_by_registrant?
|
||||
return false unless locked_by_registrant_at
|
||||
|
||||
lock_statuses = [DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::SERVER_TRANSFER_PROHIBITED]
|
||||
|
||||
(statuses & lock_statuses).count == 3
|
||||
end
|
||||
|
||||
def remove_registry_lock
|
||||
return unless locked_by_registrant?
|
||||
|
||||
transaction do
|
||||
statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
|
||||
self.locked_by_registrant_at = nil
|
||||
alert_registrar_lock_changes!(lock: false)
|
||||
|
||||
save!
|
||||
end
|
||||
end
|
||||
|
||||
def alert_registrar_lock_changes!(lock: true)
|
||||
translation = lock ? 'locked' : 'unlocked'
|
||||
registrar.notifications.create!(
|
||||
text: I18n.t("notifications.texts.registrar_#{translation}",
|
||||
domain_name: name),
|
||||
attached_obj_id: name,
|
||||
attached_obj_type: self.class.name
|
||||
)
|
||||
end
|
||||
save!
|
||||
end
|
||||
end
|
||||
|
||||
def registry_lockable?
|
||||
(statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION,
|
||||
DomainStatus::PENDING_CREATE, DomainStatus::PENDING_UPDATE,
|
||||
DomainStatus::PENDING_DELETE, DomainStatus::PENDING_RENEW,
|
||||
DomainStatus::PENDING_TRANSFER, DomainStatus::FORCE_DELETE]).empty?
|
||||
end
|
||||
|
||||
def locked_by_registrant?
|
||||
return false unless locked_by_registrant_at
|
||||
|
||||
lock_statuses = [DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::SERVER_TRANSFER_PROHIBITED]
|
||||
|
||||
(statuses & lock_statuses).count == 3
|
||||
end
|
||||
|
||||
def remove_registry_lock
|
||||
return unless locked_by_registrant?
|
||||
|
||||
transaction do
|
||||
statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
|
||||
self.locked_by_registrant_at = nil
|
||||
alert_registrar_lock_changes!(lock: false)
|
||||
|
||||
save!
|
||||
end
|
||||
end
|
||||
|
||||
def alert_registrar_lock_changes!(lock: true)
|
||||
translation = lock ? 'locked' : 'unlocked'
|
||||
registrar.notifications.create!(
|
||||
text: I18n.t("notifications.texts.registrar_#{translation}",
|
||||
domain_name: name),
|
||||
attached_obj_id: name,
|
||||
attached_obj_type: self.class.name
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,57 +1,53 @@
|
|||
module Concerns
|
||||
module Domain
|
||||
module Releasable
|
||||
extend ActiveSupport::Concern
|
||||
module Domain::Releasable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def release_domains
|
||||
releasable_domains.each do |domain|
|
||||
domain.release
|
||||
yield domain if block_given?
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def releasable_domains
|
||||
if release_to_auction
|
||||
where('(delete_date <= ? OR force_delete_date <= ?)' \
|
||||
' AND ? != ALL(coalesce(statuses, array[]::varchar[]))',
|
||||
Time.zone.today,
|
||||
Time.zone.today,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||
else
|
||||
where('(delete_date <= ? OR force_delete_date <= ?)' \
|
||||
' AND ? != ALL(coalesce(statuses, array[]::varchar[])) AND' \
|
||||
' ? != ALL(COALESCE(statuses, array[]::varchar[]))',
|
||||
Time.zone.today,
|
||||
Time.zone.today,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::DELETE_CANDIDATE)
|
||||
end
|
||||
end
|
||||
class_methods do
|
||||
def release_domains
|
||||
releasable_domains.each do |domain|
|
||||
domain.release
|
||||
yield domain if block_given?
|
||||
end
|
||||
end
|
||||
|
||||
included do
|
||||
class_attribute :release_to_auction
|
||||
self.release_to_auction = ENV['release_domains_to_auction'] == 'true'
|
||||
end
|
||||
private
|
||||
|
||||
def release
|
||||
if release_to_auction
|
||||
ToStdout.msg 'Destroying domain'
|
||||
destroy!
|
||||
ToStdout.msg "Checking if domain_name is auctionable: #{domain_name.auctionable?}"
|
||||
domain_name.sell_at_auction if domain_name.auctionable?
|
||||
|
||||
ToStdout.msg 'Sending registrar notification'
|
||||
registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}",
|
||||
attached_obj_id: id,
|
||||
attached_obj_type: self.class)
|
||||
else
|
||||
discard
|
||||
end
|
||||
def releasable_domains
|
||||
if release_to_auction
|
||||
where('(delete_date <= ? OR force_delete_date <= ?)' \
|
||||
' AND ? != ALL(coalesce(statuses, array[]::varchar[]))',
|
||||
Time.zone.today,
|
||||
Time.zone.today,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||
else
|
||||
where('(delete_date <= ? OR force_delete_date <= ?)' \
|
||||
' AND ? != ALL(coalesce(statuses, array[]::varchar[])) AND' \
|
||||
' ? != ALL(COALESCE(statuses, array[]::varchar[]))',
|
||||
Time.zone.today,
|
||||
Time.zone.today,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::DELETE_CANDIDATE)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
included do
|
||||
class_attribute :release_to_auction
|
||||
self.release_to_auction = ENV['release_domains_to_auction'] == 'true'
|
||||
end
|
||||
|
||||
def release
|
||||
if release_to_auction
|
||||
ToStdout.msg 'Destroying domain'
|
||||
destroy!
|
||||
ToStdout.msg "Checking if domain_name is auctionable: #{domain_name.auctionable?}"
|
||||
domain_name.sell_at_auction if domain_name.auctionable?
|
||||
|
||||
ToStdout.msg 'Sending registrar notification'
|
||||
registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}",
|
||||
attached_obj_id: id,
|
||||
attached_obj_type: self.class)
|
||||
else
|
||||
discard
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module Concerns::Domain::Transferable
|
||||
module Domain::Transferable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
|
|
|
@ -1,95 +1,93 @@
|
|||
module Concerns
|
||||
module EmailVerifable
|
||||
extend ActiveSupport::Concern
|
||||
module EmailVerifable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def email_verification
|
||||
@email_verification ||= EmailAddressVerification.find_or_create_by(email: unicode_email,
|
||||
domain: domain(email))
|
||||
end
|
||||
def email_verification
|
||||
@email_verification ||= EmailAddressVerification.find_or_create_by(email: unicode_email,
|
||||
domain: domain(email))
|
||||
end
|
||||
|
||||
def billing_email_verification
|
||||
return unless attribute_names.include?('billing_email')
|
||||
def billing_email_verification
|
||||
return unless attribute_names.include?('billing_email')
|
||||
|
||||
@billing_email_verification ||= EmailAddressVerification
|
||||
.find_or_create_by(email: unicode_billing_email,
|
||||
domain: domain(billing_email))
|
||||
end
|
||||
@billing_email_verification ||= EmailAddressVerification
|
||||
.find_or_create_by(email: unicode_billing_email,
|
||||
domain: domain(billing_email))
|
||||
end
|
||||
|
||||
def email_verification_failed?
|
||||
email_verification&.failed?
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def domain(email)
|
||||
Mail::Address.new(email).domain&.downcase || 'not_found'
|
||||
rescue Mail::Field::IncompleteParseError
|
||||
'not_found'
|
||||
end
|
||||
|
||||
def local(email)
|
||||
Mail::Address.new(email).local&.downcase || email
|
||||
rescue Mail::Field::IncompleteParseError
|
||||
email
|
||||
end
|
||||
|
||||
def punycode_to_unicode(email)
|
||||
return email if domain(email) == 'not_found'
|
||||
|
||||
local = local(email)
|
||||
domain = SimpleIDN.to_unicode(domain(email))
|
||||
"#{local}@#{domain}"&.downcase
|
||||
end
|
||||
|
||||
def unicode_to_punycode(email)
|
||||
return email if domain(email) == 'not_found'
|
||||
|
||||
local = local(email)
|
||||
domain = SimpleIDN.to_ascii(domain(email))
|
||||
"#{local}@#{domain}"&.downcase
|
||||
end
|
||||
end
|
||||
|
||||
def unicode_billing_email
|
||||
self.class.punycode_to_unicode(billing_email)
|
||||
end
|
||||
|
||||
def unicode_email
|
||||
self.class.punycode_to_unicode(email)
|
||||
end
|
||||
def email_verification_failed?
|
||||
email_verification&.failed?
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def domain(email)
|
||||
SimpleIDN.to_unicode(self.class.domain(email))
|
||||
Mail::Address.new(email).domain&.downcase || 'not_found'
|
||||
rescue Mail::Field::IncompleteParseError
|
||||
'not_found'
|
||||
end
|
||||
|
||||
def local(email)
|
||||
Mail::Address.new(email).local&.downcase || email
|
||||
rescue Mail::Field::IncompleteParseError
|
||||
email
|
||||
end
|
||||
|
||||
def punycode_to_unicode(email)
|
||||
self.class.punycode_to_unicode(email)
|
||||
return email if domain(email) == 'not_found'
|
||||
|
||||
local = local(email)
|
||||
domain = SimpleIDN.to_unicode(domain(email))
|
||||
"#{local}@#{domain}"&.downcase
|
||||
end
|
||||
|
||||
def correct_email_format
|
||||
return if email.blank?
|
||||
def unicode_to_punycode(email)
|
||||
return email if domain(email) == 'not_found'
|
||||
|
||||
result = email_verification.verify
|
||||
process_result(result: result, field: :email)
|
||||
local = local(email)
|
||||
domain = SimpleIDN.to_ascii(domain(email))
|
||||
"#{local}@#{domain}"&.downcase
|
||||
end
|
||||
|
||||
def correct_billing_email_format
|
||||
return if email.blank?
|
||||
|
||||
result = billing_email_verification.verify
|
||||
process_result(result: result, field: :billing_email)
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/LineLength
|
||||
def process_result(result:, field:)
|
||||
case result[:errors].keys.first
|
||||
when :smtp
|
||||
errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_smtp_check_error'))
|
||||
when :mx
|
||||
errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_mx_check_error'))
|
||||
when :regex
|
||||
errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_regex_check_error'))
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/LineLength
|
||||
end
|
||||
|
||||
def unicode_billing_email
|
||||
self.class.punycode_to_unicode(billing_email)
|
||||
end
|
||||
|
||||
def unicode_email
|
||||
self.class.punycode_to_unicode(email)
|
||||
end
|
||||
|
||||
def domain(email)
|
||||
SimpleIDN.to_unicode(self.class.domain(email))
|
||||
end
|
||||
|
||||
def punycode_to_unicode(email)
|
||||
self.class.punycode_to_unicode(email)
|
||||
end
|
||||
|
||||
def correct_email_format
|
||||
return if email.blank?
|
||||
|
||||
result = email_verification.verify
|
||||
process_result(result: result, field: :email)
|
||||
end
|
||||
|
||||
def correct_billing_email_format
|
||||
return if email.blank?
|
||||
|
||||
result = billing_email_verification.verify
|
||||
process_result(result: result, field: :billing_email)
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/LineLength
|
||||
def process_result(result:, field:)
|
||||
case result[:errors].keys.first
|
||||
when :smtp
|
||||
errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_smtp_check_error'))
|
||||
when :mx
|
||||
errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_mx_check_error'))
|
||||
when :regex
|
||||
errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_regex_check_error'))
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/LineLength
|
||||
end
|
||||
|
|
|
@ -1,34 +1,30 @@
|
|||
module Concerns
|
||||
module Invoice
|
||||
module BookKeeping
|
||||
extend ActiveSupport::Concern
|
||||
module Invoice::BookKeeping
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def as_directo_json
|
||||
invoice = ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(self))
|
||||
invoice['customer'] = compose_directo_customer
|
||||
invoice['issue_date'] = issue_date.strftime('%Y-%m-%d')
|
||||
invoice['transaction_date'] = account_activity
|
||||
.bank_transaction&.paid_at&.strftime('%Y-%m-%d')
|
||||
invoice['language'] = buyer.language == 'en' ? 'ENG' : ''
|
||||
invoice['invoice_lines'] = compose_directo_product
|
||||
def as_directo_json
|
||||
invoice = ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(self))
|
||||
invoice['customer'] = compose_directo_customer
|
||||
invoice['issue_date'] = issue_date.strftime('%Y-%m-%d')
|
||||
invoice['transaction_date'] = account_activity
|
||||
.bank_transaction&.paid_at&.strftime('%Y-%m-%d')
|
||||
invoice['language'] = buyer.language == 'en' ? 'ENG' : ''
|
||||
invoice['invoice_lines'] = compose_directo_product
|
||||
|
||||
invoice
|
||||
end
|
||||
invoice
|
||||
end
|
||||
|
||||
def compose_directo_product
|
||||
[{ 'product_id': Setting.directo_receipt_product_name, 'description': order,
|
||||
'quantity': 1, 'price': ActionController::Base.helpers.number_with_precision(
|
||||
subtotal, precision: 2, separator: '.'
|
||||
) }].as_json
|
||||
end
|
||||
def compose_directo_product
|
||||
[{ 'product_id': Setting.directo_receipt_product_name, 'description': order,
|
||||
'quantity': 1, 'price': ActionController::Base.helpers.number_with_precision(
|
||||
subtotal, precision: 2, separator: '.'
|
||||
) }].as_json
|
||||
end
|
||||
|
||||
def compose_directo_customer
|
||||
{
|
||||
'code': buyer.accounting_customer_code,
|
||||
'destination': buyer_country_code,
|
||||
'vat_reg_no': buyer_vat_no,
|
||||
}.as_json
|
||||
end
|
||||
end
|
||||
def compose_directo_customer
|
||||
{
|
||||
'code': buyer.accounting_customer_code,
|
||||
'destination': buyer_country_code,
|
||||
'vat_reg_no': buyer_vat_no,
|
||||
}.as_json
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
module Concerns
|
||||
module Invoice
|
||||
module Cancellable
|
||||
extend ActiveSupport::Concern
|
||||
module Invoice::Cancellable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
scope :non_cancelled, -> { where(cancelled_at: nil) }
|
||||
end
|
||||
included do
|
||||
scope :non_cancelled, -> { where(cancelled_at: nil) }
|
||||
end
|
||||
|
||||
def cancellable?
|
||||
unpaid? && not_cancelled?
|
||||
end
|
||||
def cancellable?
|
||||
unpaid? && not_cancelled?
|
||||
end
|
||||
|
||||
def cancel
|
||||
raise 'Invoice cannot be cancelled' unless cancellable?
|
||||
update!(cancelled_at: Time.zone.now)
|
||||
end
|
||||
def cancel
|
||||
raise 'Invoice cannot be cancelled' unless cancellable?
|
||||
update!(cancelled_at: Time.zone.now)
|
||||
end
|
||||
|
||||
def cancelled?
|
||||
cancelled_at
|
||||
end
|
||||
def cancelled?
|
||||
cancelled_at
|
||||
end
|
||||
|
||||
def not_cancelled?
|
||||
!cancelled?
|
||||
end
|
||||
end
|
||||
def not_cancelled?
|
||||
!cancelled?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
module Concerns
|
||||
module Invoice
|
||||
module Payable
|
||||
extend ActiveSupport::Concern
|
||||
module Invoice::Payable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
scope :unpaid, -> { where('id NOT IN (SELECT invoice_id FROM account_activities WHERE' \
|
||||
' invoice_id IS NOT NULL)') }
|
||||
end
|
||||
included do
|
||||
scope :unpaid, -> { where('id NOT IN (SELECT invoice_id FROM account_activities WHERE' \
|
||||
' invoice_id IS NOT NULL)') }
|
||||
end
|
||||
|
||||
def payable?
|
||||
unpaid? && not_cancelled?
|
||||
end
|
||||
def payable?
|
||||
unpaid? && not_cancelled?
|
||||
end
|
||||
|
||||
def paid?
|
||||
account_activity
|
||||
end
|
||||
def paid?
|
||||
account_activity
|
||||
end
|
||||
|
||||
def receipt_date
|
||||
account_activity.created_at.to_date
|
||||
end
|
||||
def receipt_date
|
||||
account_activity.created_at.to_date
|
||||
end
|
||||
|
||||
def unpaid?
|
||||
!paid?
|
||||
end
|
||||
end
|
||||
def unpaid?
|
||||
!paid?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,128 +1,124 @@
|
|||
module Concerns
|
||||
module Registrar
|
||||
module BookKeeping
|
||||
extend ActiveSupport::Concern
|
||||
module Registrar::BookKeeping
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
DOMAIN_TO_PRODUCT = { 'ee': '01EE', 'com.ee': '02COM', 'pri.ee': '03PRI',
|
||||
'fie.ee': '04FIE', 'med.ee': '05MED' }.freeze
|
||||
DOMAIN_TO_PRODUCT = { 'ee': '01EE', 'com.ee': '02COM', 'pri.ee': '03PRI',
|
||||
'fie.ee': '04FIE', 'med.ee': '05MED' }.freeze
|
||||
|
||||
def monthly_summary(month:)
|
||||
activities = monthly_activites(month)
|
||||
return unless activities.any?
|
||||
def monthly_summary(month:)
|
||||
activities = monthly_activites(month)
|
||||
return unless activities.any?
|
||||
|
||||
invoice = {
|
||||
'number': 1,
|
||||
'customer': compose_directo_customer,
|
||||
'language': language == 'en' ? 'ENG' : '', 'currency': activities.first.currency,
|
||||
'date': month.end_of_month.strftime('%Y-%m-%d')
|
||||
}.as_json
|
||||
invoice = {
|
||||
'number': 1,
|
||||
'customer': compose_directo_customer,
|
||||
'language': language == 'en' ? 'ENG' : '', 'currency': activities.first.currency,
|
||||
'date': month.end_of_month.strftime('%Y-%m-%d')
|
||||
}.as_json
|
||||
|
||||
invoice['invoice_lines'] = prepare_invoice_lines(month: month, activities: activities)
|
||||
invoice['invoice_lines'] = prepare_invoice_lines(month: month, activities: activities)
|
||||
|
||||
invoice
|
||||
end
|
||||
invoice
|
||||
end
|
||||
|
||||
def prepare_invoice_lines(month:, activities:)
|
||||
lines = []
|
||||
def prepare_invoice_lines(month:, activities:)
|
||||
lines = []
|
||||
|
||||
lines << { 'description': title_for_summary(month) }
|
||||
activities.each do |activity|
|
||||
fetch_invoice_lines(activity, lines)
|
||||
end
|
||||
lines << prepayment_for_all(lines)
|
||||
lines << { 'description': title_for_summary(month) }
|
||||
activities.each do |activity|
|
||||
fetch_invoice_lines(activity, lines)
|
||||
end
|
||||
lines << prepayment_for_all(lines)
|
||||
|
||||
lines.as_json
|
||||
end
|
||||
lines.as_json
|
||||
end
|
||||
|
||||
def title_for_summary(date)
|
||||
I18n.with_locale(language == 'en' ? 'en' : 'et') do
|
||||
I18n.t('registrar.monthly_summary_title', date: I18n.l(date, format: '%B %Y'))
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_invoice_lines(activity, lines)
|
||||
price = load_price(activity)
|
||||
if price.duration.include? 'year'
|
||||
price.duration.to_i.times do |duration|
|
||||
lines << new_monthly_invoice_line(activity: activity, duration: duration + 1).as_json
|
||||
end
|
||||
else
|
||||
lines << new_monthly_invoice_line(activity: activity).as_json
|
||||
end
|
||||
end
|
||||
|
||||
def monthly_activites(month)
|
||||
AccountActivity.where(account_id: account_ids)
|
||||
.where(created_at: month.beginning_of_month..month.end_of_month)
|
||||
.where(activity_type: [AccountActivity::CREATE, AccountActivity::RENEW])
|
||||
end
|
||||
|
||||
def new_monthly_invoice_line(activity:, duration: nil)
|
||||
price = load_price(activity)
|
||||
line = {
|
||||
'product_id': DOMAIN_TO_PRODUCT[price.zone_name.to_sym],
|
||||
'quantity': 1,
|
||||
'unit': language == 'en' ? 'pc' : 'tk',
|
||||
}
|
||||
|
||||
finalize_invoice_line(line, price: price, duration: duration, activity: activity)
|
||||
end
|
||||
|
||||
def finalize_invoice_line(line, price:, activity:, duration:)
|
||||
yearly = price.duration.include?('year')
|
||||
|
||||
line['price'] = yearly ? (price.price.amount / price.duration.to_i) : price.price.amount
|
||||
line['description'] = description_in_language(price: price, yearly: yearly)
|
||||
|
||||
if duration.present?
|
||||
add_product_timeframe(line: line, activity: activity, duration: duration) if duration > 1
|
||||
end
|
||||
|
||||
line
|
||||
end
|
||||
|
||||
def add_product_timeframe(line:, activity:, duration:)
|
||||
create_time = activity.created_at
|
||||
line['start_date'] = (create_time + (duration - 1).year).end_of_month.strftime('%Y-%m-%d')
|
||||
line['end_date'] = (create_time + (duration - 1).year + 1).end_of_month.strftime('%Y-%m-%d')
|
||||
end
|
||||
|
||||
def description_in_language(price:, yearly:)
|
||||
timeframe_string = yearly ? 'yearly' : 'monthly'
|
||||
locale_string = "registrar.invoice_#{timeframe_string}_product_description"
|
||||
|
||||
I18n.with_locale(language == 'en' ? 'en' : 'et') do
|
||||
I18n.t(locale_string, tld: ".#{price.zone_name}", length: price.duration.to_i)
|
||||
end
|
||||
end
|
||||
|
||||
def prepayment_for_all(lines)
|
||||
total = 0
|
||||
en = language == 'en'
|
||||
lines.each { |l| total += l['quantity'].to_f * l['price'].to_f }
|
||||
{
|
||||
'product_id': Setting.directo_receipt_product_name,
|
||||
'description': en ? 'Domains prepayment' : 'Domeenide ettemaks',
|
||||
'quantity': -1,
|
||||
'price': total,
|
||||
'unit': en ? 'pc' : 'tk',
|
||||
}
|
||||
end
|
||||
|
||||
def compose_directo_customer
|
||||
{
|
||||
'code': accounting_customer_code,
|
||||
'destination': address_country_code,
|
||||
'vat_reg_no': vat_no,
|
||||
}.as_json
|
||||
end
|
||||
|
||||
def load_price(account_activity)
|
||||
@pricelists ||= {}
|
||||
return @pricelists[account_activity.price_id] if @pricelists.key? account_activity.price_id
|
||||
|
||||
@pricelists[account_activity.price_id] = account_activity.price
|
||||
end
|
||||
def title_for_summary(date)
|
||||
I18n.with_locale(language == 'en' ? 'en' : 'et') do
|
||||
I18n.t('registrar.monthly_summary_title', date: I18n.l(date, format: '%B %Y'))
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_invoice_lines(activity, lines)
|
||||
price = load_price(activity)
|
||||
if price.duration.include? 'year'
|
||||
price.duration.to_i.times do |duration|
|
||||
lines << new_monthly_invoice_line(activity: activity, duration: duration + 1).as_json
|
||||
end
|
||||
else
|
||||
lines << new_monthly_invoice_line(activity: activity).as_json
|
||||
end
|
||||
end
|
||||
|
||||
def monthly_activites(month)
|
||||
AccountActivity.where(account_id: account_ids)
|
||||
.where(created_at: month.beginning_of_month..month.end_of_month)
|
||||
.where(activity_type: [AccountActivity::CREATE, AccountActivity::RENEW])
|
||||
end
|
||||
|
||||
def new_monthly_invoice_line(activity:, duration: nil)
|
||||
price = load_price(activity)
|
||||
line = {
|
||||
'product_id': DOMAIN_TO_PRODUCT[price.zone_name.to_sym],
|
||||
'quantity': 1,
|
||||
'unit': language == 'en' ? 'pc' : 'tk',
|
||||
}
|
||||
|
||||
finalize_invoice_line(line, price: price, duration: duration, activity: activity)
|
||||
end
|
||||
|
||||
def finalize_invoice_line(line, price:, activity:, duration:)
|
||||
yearly = price.duration.include?('year')
|
||||
|
||||
line['price'] = yearly ? (price.price.amount / price.duration.to_i) : price.price.amount
|
||||
line['description'] = description_in_language(price: price, yearly: yearly)
|
||||
|
||||
if duration.present?
|
||||
add_product_timeframe(line: line, activity: activity, duration: duration) if duration > 1
|
||||
end
|
||||
|
||||
line
|
||||
end
|
||||
|
||||
def add_product_timeframe(line:, activity:, duration:)
|
||||
create_time = activity.created_at
|
||||
line['start_date'] = (create_time + (duration - 1).year).end_of_month.strftime('%Y-%m-%d')
|
||||
line['end_date'] = (create_time + (duration - 1).year + 1).end_of_month.strftime('%Y-%m-%d')
|
||||
end
|
||||
|
||||
def description_in_language(price:, yearly:)
|
||||
timeframe_string = yearly ? 'yearly' : 'monthly'
|
||||
locale_string = "registrar.invoice_#{timeframe_string}_product_description"
|
||||
|
||||
I18n.with_locale(language == 'en' ? 'en' : 'et') do
|
||||
I18n.t(locale_string, tld: ".#{price.zone_name}", length: price.duration.to_i)
|
||||
end
|
||||
end
|
||||
|
||||
def prepayment_for_all(lines)
|
||||
total = 0
|
||||
en = language == 'en'
|
||||
lines.each { |l| total += l['quantity'].to_f * l['price'].to_f }
|
||||
{
|
||||
'product_id': Setting.directo_receipt_product_name,
|
||||
'description': en ? 'Domains prepayment' : 'Domeenide ettemaks',
|
||||
'quantity': -1,
|
||||
'price': total,
|
||||
'unit': en ? 'pc' : 'tk',
|
||||
}
|
||||
end
|
||||
|
||||
def compose_directo_customer
|
||||
{
|
||||
'code': accounting_customer_code,
|
||||
'destination': address_country_code,
|
||||
'vat_reg_no': vat_no,
|
||||
}.as_json
|
||||
end
|
||||
|
||||
def load_price(account_activity)
|
||||
@pricelists ||= {}
|
||||
return @pricelists[account_activity.price_id] if @pricelists.key? account_activity.price_id
|
||||
|
||||
@pricelists[account_activity.price_id] = account_activity.price
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
module Concerns
|
||||
module Registrar
|
||||
module LegalDoc
|
||||
extend ActiveSupport::Concern
|
||||
module Registrar::LegalDoc
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def legaldoc_mandatory?
|
||||
!legaldoc_not_mandatory?
|
||||
end
|
||||
def legaldoc_mandatory?
|
||||
!legaldoc_not_mandatory?
|
||||
end
|
||||
|
||||
def legaldoc_not_mandatory?
|
||||
setting = Setting.legal_document_is_mandatory
|
||||
legaldoc_optout || !setting
|
||||
end
|
||||
end
|
||||
def legaldoc_not_mandatory?
|
||||
setting = Setting.legal_document_is_mandatory
|
||||
legaldoc_optout || !setting
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,10 +7,10 @@ module Versions
|
|||
attr_accessor :version_loader
|
||||
|
||||
if WITH_CHILDREN.include?(model_name.name)
|
||||
has_paper_trail versions: { class_name: "#{model_name}Version" },
|
||||
has_paper_trail versions: { class_name: "Version::#{model_name}Version" },
|
||||
meta: { children: :children_log }
|
||||
else
|
||||
has_paper_trail versions: { class_name: "#{model_name}Version" }
|
||||
has_paper_trail versions: { class_name: "Version::#{model_name}Version" }
|
||||
end
|
||||
|
||||
# add creator and updator
|
||||
|
|
|
@ -1,74 +1,70 @@
|
|||
module Concerns
|
||||
module Zone
|
||||
module WhoisQueryable
|
||||
extend ActiveSupport::Concern
|
||||
module Zone::WhoisQueryable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
after_save :update_whois_record, if: :subzone?
|
||||
after_destroy :update_whois_record
|
||||
end
|
||||
included do
|
||||
after_save :update_whois_record, if: :subzone?
|
||||
after_destroy :update_whois_record
|
||||
end
|
||||
|
||||
def subzone?
|
||||
origin.include? '.'
|
||||
end
|
||||
def subzone?
|
||||
origin.include? '.'
|
||||
end
|
||||
|
||||
def update_whois_record
|
||||
UpdateWhoisRecordJob.enqueue origin, 'zone'
|
||||
end
|
||||
def update_whois_record
|
||||
UpdateWhoisRecordJob.enqueue origin, 'zone'
|
||||
end
|
||||
|
||||
def generate_data
|
||||
wr = Whois::Record.find_or_initialize_by(name: origin)
|
||||
wr.json = generate_json
|
||||
wr.save
|
||||
end
|
||||
def generate_data
|
||||
wr = Whois::Record.find_or_initialize_by(name: origin)
|
||||
wr.json = generate_json
|
||||
wr.save
|
||||
end
|
||||
|
||||
def generate_json
|
||||
data = {}.with_indifferent_access
|
||||
[domain_vars, registrar_vars, registrant_vars].each do |h|
|
||||
data.merge!(h)
|
||||
end
|
||||
|
||||
data
|
||||
end
|
||||
|
||||
# Take note - since this concern only used to zone whois queries, dnssec keys are set to
|
||||
# empty array
|
||||
def domain_vars
|
||||
{ disclaimer: Setting.registry_whois_disclaimer, name: origin,
|
||||
registered: created_at.try(:to_s, :iso8601), status: ['ok (paid and in zone)'],
|
||||
changed: updated_at.try(:to_s, :iso8601), email: Setting.registry_email,
|
||||
admin_contacts: [contact_vars], tech_contacts: [contact_vars],
|
||||
nameservers: nameserver_vars, dnssec_keys: [], dnssec_changed: nil }
|
||||
end
|
||||
|
||||
def registrar_vars
|
||||
{ registrar: Setting.registry_juridical_name, registrar_website: Setting.registry_url,
|
||||
registrar_phone: Setting.registry_phone }
|
||||
end
|
||||
|
||||
def registrant_vars
|
||||
{ registrant: Setting.registry_juridical_name, registrant_reg_no: Setting.registry_reg_no,
|
||||
registrant_ident_country_code: Setting.registry_country_code, registrant_kind: 'org',
|
||||
registrant_disclosed_attributes: %w[name email] }
|
||||
end
|
||||
|
||||
def contact_vars
|
||||
{ name: Setting.registry_invoice_contact, email: Setting.registry_email,
|
||||
disclosed_attributes: %w[name email] }
|
||||
end
|
||||
|
||||
def nameserver_vars
|
||||
vars = []
|
||||
return vars unless ns_records
|
||||
|
||||
parsed_ns = ns_records.gsub("\r", '').gsub("\n", '')
|
||||
parsed_ns.split("#{origin}. IN NS ").each do |ns|
|
||||
ns.delete_suffix! '.'
|
||||
vars << ns if ns.match? Nameserver::HOSTNAME_REGEXP
|
||||
end
|
||||
|
||||
vars
|
||||
end
|
||||
def generate_json
|
||||
data = {}.with_indifferent_access
|
||||
[domain_vars, registrar_vars, registrant_vars].each do |h|
|
||||
data.merge!(h)
|
||||
end
|
||||
|
||||
data
|
||||
end
|
||||
|
||||
# Take note - since this concern only used to zone whois queries, dnssec keys are set to
|
||||
# empty array
|
||||
def domain_vars
|
||||
{ disclaimer: Setting.registry_whois_disclaimer, name: origin,
|
||||
registered: created_at.try(:to_s, :iso8601), status: ['ok (paid and in zone)'],
|
||||
changed: updated_at.try(:to_s, :iso8601), email: Setting.registry_email,
|
||||
admin_contacts: [contact_vars], tech_contacts: [contact_vars],
|
||||
nameservers: nameserver_vars, dnssec_keys: [], dnssec_changed: nil }
|
||||
end
|
||||
|
||||
def registrar_vars
|
||||
{ registrar: Setting.registry_juridical_name, registrar_website: Setting.registry_url,
|
||||
registrar_phone: Setting.registry_phone }
|
||||
end
|
||||
|
||||
def registrant_vars
|
||||
{ registrant: Setting.registry_juridical_name, registrant_reg_no: Setting.registry_reg_no,
|
||||
registrant_ident_country_code: Setting.registry_country_code, registrant_kind: 'org',
|
||||
registrant_disclosed_attributes: %w[name email] }
|
||||
end
|
||||
|
||||
def contact_vars
|
||||
{ name: Setting.registry_invoice_contact, email: Setting.registry_email,
|
||||
disclosed_attributes: %w[name email] }
|
||||
end
|
||||
|
||||
def nameserver_vars
|
||||
vars = []
|
||||
return vars unless ns_records
|
||||
|
||||
parsed_ns = ns_records.gsub("\r", '').gsub("\n", '')
|
||||
parsed_ns.split("#{origin}. IN NS ").each do |ns|
|
||||
ns.delete_suffix! '.'
|
||||
vars << ns if ns.match? Nameserver::HOSTNAME_REGEXP
|
||||
end
|
||||
|
||||
vars
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,11 +4,11 @@ class Contact < ApplicationRecord
|
|||
include Versions # version/contact_version.rb
|
||||
include EppErrors
|
||||
include UserEvents
|
||||
include Concerns::Contact::Transferable
|
||||
include Concerns::Contact::Identical
|
||||
include Concerns::Contact::Disclosable
|
||||
include Concerns::Contact::Archivable
|
||||
include Concerns::EmailVerifable
|
||||
include Contact::Transferable
|
||||
include Contact::Identical
|
||||
include Contact::Disclosable
|
||||
include Contact::Archivable
|
||||
include EmailVerifable
|
||||
|
||||
belongs_to :original, class_name: self.name
|
||||
belongs_to :registrar, required: true
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module Concerns::Contact::Transferable
|
||||
module Contact::Transferable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
|
@ -9,7 +9,7 @@ module Concerns::Contact::Transferable
|
|||
def transfer(new_registrar)
|
||||
return identical(new_registrar) if identical(new_registrar)
|
||||
|
||||
new_contact = self.dup
|
||||
new_contact = dup
|
||||
new_contact.registrar = new_registrar
|
||||
new_contact.original = self
|
||||
new_contact.code = nil
|
|
@ -5,7 +5,7 @@ module DNS
|
|||
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, :master_nameserver, presence: true
|
||||
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
|
||||
validates :origin, uniqueness: true
|
||||
include Concerns::Zone::WhoisQueryable
|
||||
include ::Zone::WhoisQueryable
|
||||
|
||||
before_destroy do
|
||||
throw(:abort) if used?
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
class Domain < ApplicationRecord
|
||||
include UserEvents
|
||||
include Versions # version/domain_version.rb
|
||||
include Concerns::Domain::Expirable
|
||||
include Concerns::Domain::Activatable
|
||||
include Concerns::Domain::ForceDelete
|
||||
include Concerns::Domain::Discardable
|
||||
include Concerns::Domain::Deletable
|
||||
include Concerns::Domain::Transferable
|
||||
include Concerns::Domain::RegistryLockable
|
||||
include Concerns::Domain::Releasable
|
||||
include Concerns::Domain::Disputable
|
||||
include Concerns::Domain::BulkUpdatable
|
||||
include Domain::Expirable
|
||||
include Domain::Activatable
|
||||
include Domain::ForceDelete
|
||||
include Domain::Discardable
|
||||
include Domain::Deletable
|
||||
include Domain::Transferable
|
||||
include Domain::RegistryLockable
|
||||
include Domain::Releasable
|
||||
include Domain::Disputable
|
||||
include Domain::BulkUpdatable
|
||||
|
||||
attr_accessor :roles
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class Invoice < ApplicationRecord
|
||||
include Versions
|
||||
include Concerns::Invoice::Cancellable
|
||||
include Concerns::Invoice::Payable
|
||||
include Concerns::Invoice::BookKeeping
|
||||
include Invoice::Cancellable
|
||||
include Invoice::Payable
|
||||
include Invoice::BookKeeping
|
||||
|
||||
belongs_to :buyer, class_name: 'Registrar'
|
||||
has_one :account_activity
|
||||
|
@ -34,7 +34,7 @@ class Invoice < ApplicationRecord
|
|||
before_create :calculate_total, unless: :total?
|
||||
before_create :apply_default_buyer_vat_no, unless: :buyer_vat_no?
|
||||
|
||||
attribute :vat_rate, ::Type::VATRate.new
|
||||
attribute :vat_rate, ::Type::VatRate.new
|
||||
|
||||
def set_invoice_number
|
||||
last_no = Invoice.order(number: :desc).limit(1).pluck(:number).first
|
||||
|
|
|
@ -82,7 +82,7 @@ class LegalDocument < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
contact_ids = DomainVersion.where(item_id: orig_legal.documentable_id).distinct.
|
||||
contact_ids = Version::DomainVersion.where(item_id: orig_legal.documentable_id).distinct.
|
||||
pluck("object->>'registrant_id'", "object_changes->>'registrant_id'",
|
||||
"children->>'tech_contacts'", "children->>'admin_contacts'").flatten.uniq
|
||||
contact_ids = contact_ids.map{|id|
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class Registrar < ApplicationRecord
|
||||
include Versions # version/registrar_version.rb
|
||||
include Concerns::Registrar::BookKeeping
|
||||
include Concerns::EmailVerifable
|
||||
include Concerns::Registrar::LegalDoc
|
||||
include Registrar::BookKeeping
|
||||
include EmailVerifable
|
||||
include Registrar::LegalDoc
|
||||
|
||||
has_many :domains, dependent: :restrict_with_error
|
||||
has_many :contacts, dependent: :restrict_with_error
|
||||
|
@ -30,7 +30,7 @@ class Registrar < ApplicationRecord
|
|||
validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than: 100 },
|
||||
allow_nil: true
|
||||
|
||||
attribute :vat_rate, ::Type::VATRate.new
|
||||
attribute :vat_rate, ::Type::VatRate.new
|
||||
after_initialize :set_defaults
|
||||
|
||||
validate :correct_email_format, if: proc { |c| c.will_save_change_to_email? }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module Type
|
||||
class VATRate < ActiveRecord::Type::Decimal
|
||||
class VatRate < ActiveRecord::Type::Decimal
|
||||
def deserialize(value)
|
||||
super * 100 if value
|
||||
end
|
||||
|
|
1
app/models/version.rb
Normal file
1
app/models/version.rb
Normal file
|
@ -0,0 +1 @@
|
|||
class Version; end
|
|
@ -1,4 +1,4 @@
|
|||
class AccountActivityVersion < PaperTrail::Version
|
||||
class Version::AccountActivityVersion < PaperTrail::Version
|
||||
self.table_name = :log_account_activities
|
||||
self.sequence_name = :log_account_activities_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class AccountVersion < PaperTrail::Version
|
||||
class Version::AccountVersion < PaperTrail::Version
|
||||
self.table_name = :log_accounts
|
||||
self.sequence_name = :log_accounts_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class ActionVersion < PaperTrail::Version
|
||||
class Version::ActionVersion < PaperTrail::Version
|
||||
self.table_name = :log_actions
|
||||
self.sequence_name = :log_actions_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class BankStatementVersion < PaperTrail::Version
|
||||
class Version::BankStatementVersion < PaperTrail::Version
|
||||
self.table_name = :log_bank_statements
|
||||
self.sequence_name = :log_bank_statements_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class BankTransactionVersion < PaperTrail::Version
|
||||
class Version::BankTransactionVersion < PaperTrail::Version
|
||||
self.table_name = :log_bank_transactions
|
||||
self.sequence_name = :log_bank_transactions_id_seq
|
||||
end
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
module Billing
|
||||
class PriceVersion < PaperTrail::Version
|
||||
self.table_name = :log_prices
|
||||
self.sequence_name = :log_prices_id_seq
|
||||
end
|
||||
class Version::Billing::PriceVersion < PaperTrail::Version
|
||||
self.table_name = :log_prices
|
||||
self.sequence_name = :log_prices_id_seq
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class BlockedDomainVersion < PaperTrail::Version
|
||||
class Version::BlockedDomainVersion < PaperTrail::Version
|
||||
self.table_name = :log_blocked_domains
|
||||
self.sequence_name = :log_blocked_domains_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class CertificateVersion < PaperTrail::Version
|
||||
class Version::CertificateVersion < PaperTrail::Version
|
||||
self.table_name = :log_certificates
|
||||
self.sequence_name = :log_certificates_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class ContactVersion < PaperTrail::Version
|
||||
class Version::ContactVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_contacts
|
||||
self.sequence_name = :log_contacts_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class DnskeyVersion < PaperTrail::Version
|
||||
class Version::DnskeyVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_dnskeys
|
||||
self.sequence_name = :log_dnskeys_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class DomainContactVersion < PaperTrail::Version
|
||||
class Version::DomainContactVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_domain_contacts
|
||||
self.sequence_name = :log_domain_contacts_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class DomainVersion < PaperTrail::Version
|
||||
class Version::DomainVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
|
||||
self.table_name = :log_domains
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class InvoiceItemVersion < PaperTrail::Version
|
||||
class Version::InvoiceItemVersion < PaperTrail::Version
|
||||
self.table_name = :log_invoice_items
|
||||
self.sequence_name = :log_invoice_items_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class InvoiceVersion < PaperTrail::Version
|
||||
class Version::InvoiceVersion < PaperTrail::Version
|
||||
self.table_name = :log_invoices
|
||||
self.sequence_name = :log_invoices_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class NameserverVersion < PaperTrail::Version
|
||||
class Version::NameserverVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_nameservers
|
||||
self.sequence_name = :log_nameservers_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class NotificationVersion < PaperTrail::Version
|
||||
class Version::NotificationVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_notifications
|
||||
self.sequence_name = :log_notifications_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class PaymentOrderVersion < PaperTrail::Version
|
||||
class Version::PaymentOrderVersion < PaperTrail::Version
|
||||
self.table_name = :log_payment_orders
|
||||
self.sequence_name = :log_payment_orders_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class RegistrantVerificationVersion < PaperTrail::Version
|
||||
class Version::RegistrantVerificationVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_registrant_verifications
|
||||
self.sequence_name = :log_registrant_verifications_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class RegistrarVersion < PaperTrail::Version
|
||||
class Version::RegistrarVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_registrars
|
||||
self.sequence_name = :log_registrars_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class ReservedDomainVersion < PaperTrail::Version
|
||||
class Version::ReservedDomainVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_reserved_domains
|
||||
self.sequence_name = :log_reserved_domains_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class SettingEntryVersion < PaperTrail::Version
|
||||
class Version::SettingEntryVersion < PaperTrail::Version
|
||||
self.table_name = :log_setting_entries
|
||||
self.sequence_name = :log_setting_entries
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class SettingVersion < PaperTrail::Version
|
||||
class Version::SettingVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_settings
|
||||
self.sequence_name = :log_settings_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class UserVersion < PaperTrail::Version
|
||||
class Version::UserVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_users
|
||||
self.sequence_name = :log_users_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class WhiteIpVersion < PaperTrail::Version
|
||||
class Version::WhiteIpVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_white_ips
|
||||
self.sequence_name = :log_white_ips_id_seq
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Registrar::DomainListCSVPresenter
|
||||
class Registrar::DomainListCsvPresenter
|
||||
def initialize(domains:, view:)
|
||||
@domains = domains
|
||||
@view = view
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
= domain.registrant.name
|
||||
- else
|
||||
- contact = Contact.all_versions_for([domain.registrant_id], version.created_at).first
|
||||
- if contact.nil? && ver = ContactVersion.where(item_id: domain.registrant_id).last
|
||||
- if contact.nil? && ver = Version::ContactVersion.where(item_id: domain.registrant_id).last
|
||||
- contact = Contact.new(ver.object.to_h.merge(ver.object_changes.to_h.each_with_object({}) {|(k,v), o| o[k] = v.last }))
|
||||
= contact.try(:name)
|
||||
= " ".html_safe
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
- admin_contacts = domain.admin_contacts
|
||||
- registrant = domain.registrant
|
||||
- unless registrant
|
||||
- ver = ContactVersion.where(item_id: domain.registrant_id).where(event: :destroy).last
|
||||
- ver = Version::ContactVersion.where(item_id: domain.registrant_id).where(event: :destroy).last
|
||||
- registrant = ver.reify
|
||||
- registrant.version_loader = ver
|
||||
- registrant = [registrant]
|
||||
|
|
|
@ -17,7 +17,7 @@ end
|
|||
module DomainNameRegistry
|
||||
class Application < Rails::Application
|
||||
config.load_defaults 6.0
|
||||
config.autoloader = :classic # Do not use zeitwerk for now
|
||||
config.autoloader = :zeitwerk # Do not use zeitwerk for now
|
||||
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
|
@ -35,9 +35,9 @@ module DomainNameRegistry
|
|||
# config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
|
||||
|
||||
# Autoload all model subdirs
|
||||
config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
|
||||
config.autoload_paths += Dir[Rails.root.join('app', 'lib', '**/')]
|
||||
config.autoload_paths += Dir[Rails.root.join('app', 'interactions', '**/')]
|
||||
# config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
|
||||
# config.autoload_paths += Dir[Rails.root.join('app', 'lib', '**/')]
|
||||
# config.autoload_paths += Dir[Rails.root.join('app', 'interactions', '**/')]
|
||||
config.eager_load_paths << config.root.join('lib', 'validators')
|
||||
config.eager_load_paths << config.root.join('app', 'lib')
|
||||
config.watchable_dirs['lib'] = %i[rb]
|
||||
|
@ -72,8 +72,7 @@ module DomainNameRegistry
|
|||
}
|
||||
config.action_mailer.default_options = { from: ENV['action_mailer_default_from'] }
|
||||
|
||||
require "#{Rails.root}/app/mailers/interceptors/punycode_interceptor"
|
||||
ActionMailer::Base.register_interceptor(PunycodeInterceptor)
|
||||
config.action_mailer.interceptors = ["Interceptors::PunycodeInterceptor"]
|
||||
|
||||
config.action_view.default_form_builder = 'DefaultFormBuilder'
|
||||
config.secret_key_base = Figaro.env.secret_key_base
|
||||
|
|
|
@ -247,12 +247,24 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :version_domain_versions do
|
||||
collection do
|
||||
get 'search' => 'domain_versions#search', via: [:get, :post], as: :search
|
||||
end
|
||||
end
|
||||
|
||||
resources :contact_versions do
|
||||
collection do
|
||||
get 'search'
|
||||
end
|
||||
end
|
||||
|
||||
resources :version_contact_versions do
|
||||
collection do
|
||||
get 'search' => 'contact_versions#search', via: [:get, :post], as: :search
|
||||
end
|
||||
end
|
||||
|
||||
resources :settings, only: %i[index create]
|
||||
|
||||
resources :blocked_domains do
|
||||
|
|
|
@ -16,8 +16,8 @@ namespace :documents do
|
|||
next if x.documentable_id.blank?
|
||||
|
||||
document_type = case x.documentable_type
|
||||
when 'Domain' then DomainVersion
|
||||
when 'Contact'then ContactVersion
|
||||
when 'Domain' then Version::DomainVersion
|
||||
when 'Contact'then Version::ContactVersion
|
||||
end
|
||||
|
||||
dc = document_type.where(item_id: x.documentable_id)
|
||||
|
|
|
@ -7,7 +7,7 @@ class VersionsTest < ActiveSupport::TestCase
|
|||
@nameserver.update(hostname: 'ns99.bestnames.test')
|
||||
@ignored_column_title = Nameserver.ignored_columns.first
|
||||
|
||||
version = NameserverVersion.last
|
||||
version = Version::NameserverVersion.last
|
||||
hash = version.object
|
||||
hash[@ignored_column_title] = 123456
|
||||
version.update(object: hash)
|
||||
|
|
|
@ -6,8 +6,8 @@ class ArchivableContactTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_contact_is_archivable_when_it_was_linked_and_inactivity_period_has_passed
|
||||
DomainVersion.stub(:was_contact_linked?, true) do
|
||||
DomainVersion.stub(:contact_unlinked_more_than?, true) do
|
||||
Version::DomainVersion.stub(:was_contact_linked?, true) do
|
||||
Version::DomainVersion.stub(:contact_unlinked_more_than?, true) do
|
||||
assert @contact.archivable?
|
||||
end
|
||||
end
|
||||
|
@ -18,7 +18,7 @@ class ArchivableContactTest < ActiveSupport::TestCase
|
|||
@contact.created_at = Time.zone.parse('2010-07-05 00:00:00')
|
||||
travel_to Time.zone.parse('2010-07-05 00:00:01')
|
||||
|
||||
DomainVersion.stub(:was_contact_linked?, false) do
|
||||
Version::DomainVersion.stub(:was_contact_linked?, false) do
|
||||
assert @contact.archivable?
|
||||
end
|
||||
end
|
||||
|
@ -28,14 +28,14 @@ class ArchivableContactTest < ActiveSupport::TestCase
|
|||
@contact.created_at = Time.zone.parse('2010-07-05')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
DomainVersion.stub(:contact_unlinked_more_than?, false) do
|
||||
Version::DomainVersion.stub(:contact_unlinked_more_than?, false) do
|
||||
assert_not @contact.archivable?
|
||||
end
|
||||
end
|
||||
|
||||
def test_contact_is_not_archivable_when_it_was_ever_linked_but_linked_within_inactivity_period
|
||||
DomainVersion.stub(:was_contact_linked?, true) do
|
||||
DomainVersion.stub(:contact_unlinked_more_than?, false) do
|
||||
Version::DomainVersion.stub(:was_contact_linked?, true) do
|
||||
Version::DomainVersion.stub(:contact_unlinked_more_than?, false) do
|
||||
assert_not @contact.archivable?
|
||||
end
|
||||
end
|
||||
|
@ -73,7 +73,7 @@ class ArchivableContactTest < ActiveSupport::TestCase
|
|||
def archivable_contact
|
||||
contact = contacts(:john)
|
||||
Setting.orphans_contacts_in_months = 0
|
||||
DomainVersion.delete_all
|
||||
Version::DomainVersion.delete_all
|
||||
|
||||
other_contact = contacts(:william)
|
||||
assert_not_equal other_contact, contact
|
||||
|
|
|
@ -15,7 +15,7 @@ class RegistrantVerificationTest < ActiveSupport::TestCase
|
|||
registrant_verification = registrant_verifications(:one)
|
||||
random_action = "random#{rand(100)}"
|
||||
|
||||
assert_difference -> { RegistrantVerificationVersion.count } do
|
||||
assert_difference -> { Version::RegistrantVerificationVersion.count } do
|
||||
registrant_verification.update_attributes!(action: random_action)
|
||||
end
|
||||
end
|
||||
|
@ -23,11 +23,11 @@ class RegistrantVerificationTest < ActiveSupport::TestCase
|
|||
def test_reject_changes
|
||||
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
|
||||
verification_token: @token)
|
||||
start_versions_count = RegistrantVerificationVersion.count
|
||||
start_versions_count = Version::RegistrantVerificationVersion.count
|
||||
|
||||
assert_nothing_raised do
|
||||
@registrant_verification.domain_registrant_change_reject!("email link, #{@initiator}")
|
||||
end
|
||||
assert_equal RegistrantVerificationVersion.count, start_versions_count + 1
|
||||
assert_equal Version::RegistrantVerificationVersion.count, start_versions_count + 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
tech_contacts: [],
|
||||
registrant: [@contact.id] })
|
||||
|
||||
assert DomainVersion.was_contact_linked?(@contact.id)
|
||||
assert Version::DomainVersion.was_contact_linked?(@contact.id)
|
||||
end
|
||||
|
||||
def test_was_contact_linked_returns_true_when_contact_was_used_as_admin_contact
|
||||
|
@ -19,7 +19,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
tech_contacts: [],
|
||||
registrant: [] })
|
||||
|
||||
assert DomainVersion.was_contact_linked?(@contact.id)
|
||||
assert Version::DomainVersion.was_contact_linked?(@contact.id)
|
||||
end
|
||||
|
||||
def test_was_contact_linked_returns_true_when_contact_was_used_as_tech_contact
|
||||
|
@ -27,7 +27,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
tech_contacts: [@contact.id],
|
||||
registrant: [] })
|
||||
|
||||
assert DomainVersion.was_contact_linked?(@contact.id)
|
||||
assert Version::DomainVersion.was_contact_linked?(@contact.id)
|
||||
end
|
||||
|
||||
def test_was_contact_linked_returns_false_when_contact_was_not_used
|
||||
|
@ -35,7 +35,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
tech_contacts: [],
|
||||
registrant: [] })
|
||||
|
||||
assert_not DomainVersion.was_contact_linked?(@contact.id)
|
||||
assert_not Version::DomainVersion.was_contact_linked?(@contact.id)
|
||||
end
|
||||
|
||||
def test_contact_unlinked_more_than_returns_true_when_contact_was_linked_as_registrant_more_than_given_period
|
||||
|
@ -45,7 +45,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [@contact.id] })
|
||||
travel_to Time.zone.parse('2010-07-05 00:00:01')
|
||||
|
||||
assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_unlinked_more_than_given_period_as_admin_contact
|
||||
|
@ -55,7 +55,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [] })
|
||||
travel_to Time.zone.parse('2010-07-05 00:00:01')
|
||||
|
||||
assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_unlinked_more_than_given_period_as_tech_contact
|
||||
|
@ -65,7 +65,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [] })
|
||||
travel_to Time.zone.parse('2010-07-05 00:00:01')
|
||||
|
||||
assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_linked_within_given_period_as_registrant
|
||||
|
@ -75,7 +75,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [@contact.id] })
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_linked_within_given_period_as_admin_contact
|
||||
|
@ -85,7 +85,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [] })
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_linked_within_given_period_as_tech_contact
|
||||
|
@ -95,11 +95,11 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [] })
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_was_never_linked
|
||||
DomainVersion.delete_all
|
||||
assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
Version::DomainVersion.delete_all
|
||||
assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class ArchiveContactsTaskTest < ActiveSupport::TestCase
|
|||
def archivable_contact
|
||||
contact = contacts(:john)
|
||||
Setting.orphans_contacts_in_months = 0
|
||||
DomainVersion.delete_all
|
||||
Version::DomainVersion.delete_all
|
||||
|
||||
other_contact = contacts(:william)
|
||||
assert_not_equal other_contact, contact
|
||||
|
|
|
@ -42,7 +42,7 @@ EInvoice.provider = EInvoice::Providers::TestProvider.new
|
|||
class ActiveSupport::TestCase
|
||||
ActiveRecord::Migration.check_pending!
|
||||
fixtures :all
|
||||
set_fixture_class log_domains: DomainVersion
|
||||
set_fixture_class log_domains: Version::DomainVersion
|
||||
|
||||
teardown do
|
||||
travel_back
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue