mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
Merge remote-tracking branch 'origin/master' into 509-directo-to-gem
This commit is contained in:
commit
cd871ca829
45 changed files with 329 additions and 294 deletions
|
@ -4,7 +4,7 @@ class AdminUser < User
|
|||
validates :identity_code, presence: true, if: -> { country_code == 'EE' }
|
||||
validates :email, presence: true
|
||||
validates :password, :password_confirmation, presence: true, if: :new_record?
|
||||
validates :password_confirmation, presence: true, if: :encrypted_password_changed?
|
||||
validates :password_confirmation, presence: true, if: :will_save_change_to_encrypted_password?
|
||||
validate :validate_identity_code, if: -> { country_code == 'EE' }
|
||||
|
||||
ROLES = %w(user customer_service admin) # should not match to api_users roles
|
||||
|
|
|
@ -43,7 +43,7 @@ class ApiUser < User
|
|||
after_initialize :set_defaults
|
||||
def set_defaults
|
||||
return unless new_record?
|
||||
self.active = true unless active_changed?
|
||||
self.active = true unless saved_change_to_active?
|
||||
end
|
||||
|
||||
class << self
|
||||
|
|
|
@ -45,7 +45,7 @@ class BankStatement < ApplicationRecord
|
|||
buyer_name: row[83, 35].strip,
|
||||
document_no: row[118, 8].strip,
|
||||
description: row[126, 140].strip,
|
||||
sum: BigDecimal.new(row[268, 12].strip) / BigDecimal.new('100.0'),
|
||||
sum: BigDecimal(row[268, 12].strip) / BigDecimal('100.0'),
|
||||
reference_no: row[280, 35].strip
|
||||
}
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ module Concerns::Contact::Transferable
|
|||
|
||||
included do
|
||||
validates :auth_info, presence: true
|
||||
after_initialize :generate_auth_info, if: 'new_record? && auth_info.blank?'
|
||||
after_initialize :generate_auth_info, if: -> { new_record? && auth_info.blank? }
|
||||
end
|
||||
|
||||
def transfer(new_registrar)
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
# Papertrail concerns is mainly tested at country spec
|
||||
module Versions
|
||||
extend ActiveSupport::Concern
|
||||
WITH_CHILDREN = %w[Domain Contact].freeze
|
||||
|
||||
included do
|
||||
attr_accessor :version_loader
|
||||
has_paper_trail class_name: "#{model_name}Version"
|
||||
|
||||
if WITH_CHILDREN.include?(model_name.name)
|
||||
has_paper_trail class_name: "#{model_name}Version", meta: { children: :children_log }
|
||||
else
|
||||
has_paper_trail class_name: "#{model_name}Version"
|
||||
end
|
||||
|
||||
# add creator and updator
|
||||
before_create :add_creator
|
||||
|
@ -45,17 +51,17 @@ module Versions
|
|||
|
||||
# callbacks
|
||||
def touch_domain_version
|
||||
domain.try(:touch_with_version)
|
||||
domain.paper_trail.try(:touch_with_version)
|
||||
end
|
||||
|
||||
def touch_domains_version
|
||||
domains.each(&:touch_with_version)
|
||||
domains.each { |domain| domain.paper_trail.touch_with_version }
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def all_versions_for(ids, time)
|
||||
ver_klass = paper_trail_version_class
|
||||
ver_klass = paper_trail.version_class
|
||||
from_history = ver_klass.where(item_id: ids.to_a).
|
||||
order(:item_id).
|
||||
preceding(time + 1, true).
|
||||
|
|
|
@ -14,8 +14,6 @@ class Contact < ApplicationRecord
|
|||
has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id'
|
||||
has_many :actions, dependent: :destroy
|
||||
|
||||
has_paper_trail class_name: "ContactVersion", meta: { children: :children_log }
|
||||
|
||||
attr_accessor :legal_document_id
|
||||
alias_attribute :kind, :ident_type
|
||||
alias_attribute :copy_from_id, :original_id # Old attribute name; for PaperTrail
|
||||
|
@ -23,12 +21,14 @@ class Contact < ApplicationRecord
|
|||
accepts_nested_attributes_for :legal_documents
|
||||
|
||||
validates :name, :email, presence: true
|
||||
validates :street, :city, :zip, :country_code, presence: true, if: 'self.class.address_processing?'
|
||||
validates :street, :city, :zip, :country_code, presence: true, if: lambda {
|
||||
self.class.address_processing?
|
||||
}
|
||||
|
||||
validates :phone, presence: true, e164: true, phone: true
|
||||
|
||||
validates :email, format: /@/
|
||||
validates :email, email_format: { message: :invalid }, if: proc { |c| c.email_changed? }
|
||||
validates :email, email_format: { message: :invalid }, if: proc { |c| c.will_save_change_to_email? }
|
||||
|
||||
validates :code,
|
||||
uniqueness: { message: :epp_id_taken },
|
||||
|
@ -37,7 +37,7 @@ class Contact < ApplicationRecord
|
|||
validates_associated :identifier
|
||||
|
||||
validate :validate_html
|
||||
validate :validate_country_code, if: 'self.class.address_processing?'
|
||||
validate :validate_country_code, if: -> { self.class.address_processing? }
|
||||
|
||||
after_initialize do
|
||||
self.status_notes = {} if status_notes.nil?
|
||||
|
|
|
@ -9,10 +9,16 @@ class Dnskey < ApplicationRecord
|
|||
validate :validate_protocol
|
||||
validate :validate_flags
|
||||
|
||||
before_save -> { generate_digest if public_key_changed? && !ds_digest_changed? }
|
||||
before_save lambda {
|
||||
generate_digest if will_save_change_to_public_key? && !will_save_change_to_ds_digest?
|
||||
}
|
||||
|
||||
before_save lambda {
|
||||
if (public_key_changed? || flags_changed? || alg_changed? || protocol_changed?) && !ds_key_tag_changed?
|
||||
if (will_save_change_to_public_key? ||
|
||||
will_save_change_to_flags? ||
|
||||
will_save_change_to_alg? ||
|
||||
will_save_change_to_protocol?) &&
|
||||
!will_save_change_to_ds_key_tag?
|
||||
generate_ds_key_tag
|
||||
end
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@ class Domain < ApplicationRecord
|
|||
include Concerns::Domain::RegistryLockable
|
||||
include Concerns::Domain::Releasable
|
||||
|
||||
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
|
||||
|
||||
attr_accessor :roles
|
||||
|
||||
attr_accessor :legal_document_id
|
||||
|
@ -73,12 +71,13 @@ class Domain < ApplicationRecord
|
|||
|
||||
before_update :manage_statuses
|
||||
def manage_statuses
|
||||
return unless registrant_id_changed? # rollback has not yet happened
|
||||
return unless will_save_change_to_registrant_id? # rollback has not yet happened
|
||||
|
||||
pending_update! if registrant_verification_asked?
|
||||
true
|
||||
end
|
||||
|
||||
after_commit :update_whois_record, unless: 'domain_name.at_auction?'
|
||||
after_commit :update_whois_record, unless: -> { domain_name.at_auction? }
|
||||
|
||||
after_create :update_reserved_domains
|
||||
def update_reserved_domains
|
||||
|
@ -547,7 +546,7 @@ class Domain < ApplicationRecord
|
|||
activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count
|
||||
end
|
||||
|
||||
cancel_force_delete if force_delete_scheduled? && registrant_id_changed?
|
||||
cancel_force_delete if force_delete_scheduled? && will_save_change_to_registrant_id?
|
||||
|
||||
if statuses.empty? && valid?
|
||||
statuses << DomainStatus::OK
|
||||
|
|
|
@ -182,7 +182,7 @@ class Epp::Contact < Contact
|
|||
|
||||
self.attributes = at
|
||||
|
||||
email_changed = email_changed?
|
||||
email_changed = will_save_change_to_email?
|
||||
old_email = email_was
|
||||
updated = save
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ module PaymentOrders
|
|||
|
||||
def valid_amount?
|
||||
source = number_with_precision(
|
||||
BigDecimal.new(response["VK_AMOUNT"]), precision: 2, separator: "."
|
||||
BigDecimal(response["VK_AMOUNT"]), precision: 2, separator: "."
|
||||
)
|
||||
target = number_with_precision(
|
||||
invoice.total, precision: 2, separator: "."
|
||||
|
|
|
@ -76,7 +76,7 @@ module PaymentOrders
|
|||
end
|
||||
|
||||
def valid_amount?
|
||||
invoice.total == BigDecimal.new(response[:amount])
|
||||
invoice.total == BigDecimal(response[:amount])
|
||||
end
|
||||
|
||||
def valid_account?
|
||||
|
|
|
@ -22,9 +22,9 @@ class Registrar < ApplicationRecord
|
|||
validates :reference_no, format: Billing::ReferenceNo::REGEXP
|
||||
validate :forbid_special_code
|
||||
|
||||
validates :vat_rate, presence: true, if: 'vat_liable_in_foreign_country? && vat_no.blank?'
|
||||
validates :vat_rate, presence: true, if: -> { vat_liable_in_foreign_country? && vat_no.blank? }
|
||||
validates :vat_rate, absence: true, if: :vat_liable_locally?
|
||||
validates :vat_rate, absence: true, if: 'vat_liable_in_foreign_country? && vat_no?'
|
||||
validates :vat_rate, absence: true, if: -> { vat_liable_in_foreign_country? && vat_no? }
|
||||
validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than: 100 },
|
||||
allow_nil: true
|
||||
|
||||
|
@ -34,7 +34,7 @@ class Registrar < ApplicationRecord
|
|||
after_initialize :set_defaults
|
||||
|
||||
validates :email, email_format: { message: :invalid },
|
||||
allow_blank: true, if: proc { |c| c.email_changed? }
|
||||
allow_blank: true, if: proc { |c| c.will_save_change_to_email? }
|
||||
validates :billing_email, email_format: { message: :invalid }, allow_blank: true
|
||||
|
||||
alias_attribute :contact_email, :email
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue