Basic archiving overhaul

This commit is contained in:
Andres Keskküla 2014-10-15 10:35:56 +03:00
parent 19846a3abf
commit 3b1e21d6eb
12 changed files with 260 additions and 30 deletions

View file

@ -5,8 +5,6 @@ class Contact < ActiveRecord::Base
include EppErrors
#has_one :local_address, dependent: :destroy
#has_one :international_address, dependent: :destroy
has_one :address, dependent: :destroy
has_one :disclosure, class_name: 'ContactDisclosure'
@ -35,6 +33,11 @@ class Contact < ActiveRecord::Base
delegate :street, to: :address#, prefix: true
delegate :zip, to: :address#, prefix: true
# callbacks
#after_commit :domains_snapshot
after_update :domains_snapshot
after_destroy :domains_snapshot
#scopes
scope :current_registrars, ->(id) { where(registrar_id: id) }
# archiving
@ -60,6 +63,13 @@ class Contact < ActiveRecord::Base
errors.add(:ident, 'bad format') unless code.valid?
end
def domains_snapshot
(domains + domains_owned).uniq.each do |domain|
next unless domain.is_a?(Domain)
domain.touch_with_version # Method from paper_trail
end
end
def juridical?
ident_type == IDENT_TYPE_ICO
end
@ -124,6 +134,17 @@ class Contact < ActiveRecord::Base
name
end
# for archiving
def snapshot
{
name: name,
phone: phone,
code: code,
ident: ident,
email: email
}
end
class << self
# non-EPP