mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
Change deprecated changed? methods to new in callbacks
This commit is contained in:
parent
95ad3086b0
commit
01114386b3
7 changed files with 14 additions and 9 deletions
|
@ -4,7 +4,7 @@ class AdminUser < User
|
||||||
validates :identity_code, presence: true, if: -> { country_code == 'EE' }
|
validates :identity_code, presence: true, if: -> { country_code == 'EE' }
|
||||||
validates :email, presence: true
|
validates :email, presence: true
|
||||||
validates :password, :password_confirmation, presence: true, if: :new_record?
|
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' }
|
validate :validate_identity_code, if: -> { country_code == 'EE' }
|
||||||
|
|
||||||
ROLES = %w(user customer_service admin) # should not match to api_users roles
|
ROLES = %w(user customer_service admin) # should not match to api_users roles
|
||||||
|
|
|
@ -43,7 +43,7 @@ class ApiUser < User
|
||||||
after_initialize :set_defaults
|
after_initialize :set_defaults
|
||||||
def set_defaults
|
def set_defaults
|
||||||
return unless new_record?
|
return unless new_record?
|
||||||
self.active = true unless active_changed?
|
self.active = true unless saved_change_to_active?
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Contact < ApplicationRecord
|
||||||
validates :phone, presence: true, e164: true, phone: true
|
validates :phone, presence: true, e164: true, phone: true
|
||||||
|
|
||||||
validates :email, format: /@/
|
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,
|
validates :code,
|
||||||
uniqueness: { message: :epp_id_taken },
|
uniqueness: { message: :epp_id_taken },
|
||||||
|
|
|
@ -9,10 +9,15 @@ class Dnskey < ApplicationRecord
|
||||||
validate :validate_protocol
|
validate :validate_protocol
|
||||||
validate :validate_flags
|
validate :validate_flags
|
||||||
|
|
||||||
before_save -> { generate_digest if public_key_changed? && !ds_digest_changed? }
|
before_save -> { generate_digest if will_save_change_to_public_key? &&
|
||||||
|
!will_save_change_to_ds_digest? }
|
||||||
|
|
||||||
before_save lambda {
|
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
|
generate_ds_key_tag
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ class Domain < ApplicationRecord
|
||||||
|
|
||||||
before_update :manage_statuses
|
before_update :manage_statuses
|
||||||
def 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?
|
pending_update! if registrant_verification_asked?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -547,7 +547,7 @@ class Domain < ApplicationRecord
|
||||||
activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count
|
activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count
|
||||||
end
|
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?
|
if statuses.empty? && valid?
|
||||||
statuses << DomainStatus::OK
|
statuses << DomainStatus::OK
|
||||||
|
|
|
@ -182,7 +182,7 @@ class Epp::Contact < Contact
|
||||||
|
|
||||||
self.attributes = at
|
self.attributes = at
|
||||||
|
|
||||||
email_changed = email_changed?
|
email_changed = will_save_change_to_email?
|
||||||
old_email = email_was
|
old_email = email_was
|
||||||
updated = save
|
updated = save
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Registrar < ApplicationRecord
|
||||||
after_initialize :set_defaults
|
after_initialize :set_defaults
|
||||||
|
|
||||||
validates :email, email_format: { message: :invalid },
|
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
|
validates :billing_email, email_format: { message: :invalid }, allow_blank: true
|
||||||
|
|
||||||
alias_attribute :contact_email, :email
|
alias_attribute :contact_email, :email
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue