mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Clear contact address fields if address processing turned off
This commit is contained in:
parent
8688de3248
commit
3b53e12284
1 changed files with 16 additions and 0 deletions
|
@ -62,6 +62,7 @@ class Contact < ApplicationRecord
|
||||||
mapping: [%w[ident code], %w[ident_type type], %w[ident_country_code country_code]]
|
mapping: [%w[ident code], %w[ident_type type], %w[ident_country_code country_code]]
|
||||||
|
|
||||||
after_save :update_related_whois_records
|
after_save :update_related_whois_records
|
||||||
|
before_save :clear_address_modifications, if: -> { !self.class.address_processing? }
|
||||||
|
|
||||||
self.ignored_columns = %w[legacy_id legacy_history_id]
|
self.ignored_columns = %w[legacy_id legacy_history_id]
|
||||||
|
|
||||||
|
@ -507,6 +508,21 @@ class Contact < ApplicationRecord
|
||||||
]).present?
|
]).present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear_address_modifications
|
||||||
|
return unless modifies_address?
|
||||||
|
|
||||||
|
addr_fields = %i[city street zip state country_code]
|
||||||
|
addr_fields.each { |field| self[field] = nil }
|
||||||
|
end
|
||||||
|
|
||||||
|
def modifies_address?
|
||||||
|
addr_fields = %i[city street zip state country_code]
|
||||||
|
modified = false
|
||||||
|
addr_fields.each { |field| modified = true if changes.key?(field) }
|
||||||
|
|
||||||
|
modified
|
||||||
|
end
|
||||||
|
|
||||||
def update_related_whois_records
|
def update_related_whois_records
|
||||||
# not doing anything if no real changes
|
# not doing anything if no real changes
|
||||||
ignored_columns = %w[updated_at created_at statuses status_notes]
|
ignored_columns = %w[updated_at created_at statuses status_notes]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue