Merge remote-tracking branch 'origin/master' into generate-whois-records-for-subzone

This commit is contained in:
Karl Erik Õunapuu 2020-08-13 17:01:21 +03:00
commit ea43d18c3d
20 changed files with 265 additions and 38 deletions

View file

@ -23,7 +23,7 @@ module Actions
end
def maybe_remove_address
return if Setting.address_processing?
return if Contact.address_processing?
new_attributes.delete(:city)
new_attributes.delete(:zip)

View file

@ -62,6 +62,7 @@ class Contact < ApplicationRecord
mapping: [%w[ident code], %w[ident_type type], %w[ident_country_code country_code]]
after_save :update_related_whois_records
before_validation :clear_address_modifications, if: -> { !self.class.address_processing? }
self.ignored_columns = %w[legacy_id legacy_history_id]
@ -507,6 +508,19 @@ class Contact < ApplicationRecord
]).present?
end
def clear_address_modifications
return unless modifies_address?
remove_address
end
def modifies_address?
modified = false
self.class.address_attribute_names.each { |field| modified = true if changes.key?(field) }
modified
end
def update_related_whois_records
# not doing anything if no real changes
ignored_columns = %w[updated_at created_at statuses status_notes]

View file

@ -7,6 +7,7 @@ module Epp
KEY_TO_VALUE = {
completed_successfully: 1000,
completed_successfully_action_pending: 1001,
completed_without_address: 1100,
completed_successfully_no_messages: 1300,
completed_successfully_ack_to_dequeue: 1301,
completed_successfully_ending_session: 1500,
@ -35,6 +36,7 @@ module Epp
DEFAULT_DESCRIPTIONS = {
1000 => 'Command completed successfully',
1001 => 'Command completed successfully; action pending',
1100 => 'Command completed successfully; Postal address data discarded',
1300 => 'Command completed successfully; no messages',
1301 => 'Command completed successfully; ack to dequeue',
1500 => 'Command completed successfully; ending session',