Merge branch 'master' of github.com:domify/registry into country-refactor

Conflicts:
	app/models/address.rb
	app/models/country_deprecated.rb
	app/models/registrar.rb
	db/schema.rb
This commit is contained in:
Martin Lensment 2015-02-02 11:42:21 +02:00
commit 7537bb3712
91 changed files with 1614 additions and 698 deletions

View file

@ -1,4 +1,6 @@
class Address < ActiveRecord::Base
include Versions # version/address_version.rb
LOCAL_TYPE_SHORT = 'loc'
INTERNATIONAL_TYPE_SHORT = 'int'
LOCAL_TYPE = 'LocalAddress'
@ -9,8 +11,6 @@ class Address < ActiveRecord::Base
belongs_to :contact
has_paper_trail class_name: 'AddressVersion'
def country
Country.new(country_code)
end

View file

@ -1,4 +0,0 @@
class AddressVersion < PaperTrail::Version
self.table_name = :address_versions
self.sequence_name = :address_version_id_seq
end

View file

@ -1,5 +1,6 @@
# rubocop: disable Metrics/ClassLength
class ApiUser < ActiveRecord::Base
include Versions # version/api_user_version.rb
# TODO: should have max request limit per day
belongs_to :registrar
has_many :contacts

View file

@ -1,35 +1,36 @@
module DomainVersionObserver
extend ActiveSupport::Concern
included do
after_save :delayed_whois_update
end
# TODO: remove old
# included do
# after_save :delayed_whois_update
# end
private
# private
def delayed_whois_update
name = domain_name
return unless name
body = snapshot
delay.update_private_whois(name, body)
delay.update_public_whois(name, body)
end
# def delayed_whois_update
# name = domain_name
# return unless name
# body = snapshot
# delay.update_private_whois(name, body)
# delay.update_public_whois(name, body)
# end
def update_private_whois(domain_name, body)
wd = Whois::PublicDomain.find_or_initialize_by(name: domain_name)
wd.body = body
wd.save!
end
# def update_private_whois(domain_name, body)
# wd = Whois::PublicDomain.find_or_initialize_by(name: domain_name)
# wd.body = body
# wd.save!
# end
def update_public_whois(domain_name, body)
wd = Whois::PrivateDomain.find_or_initialize_by(name: domain_name)
wd.body = body
wd.save!
end
# def update_public_whois(domain_name, body)
# wd = Whois::PrivateDomain.find_or_initialize_by(name: domain_name)
# wd.body = body
# wd.save!
# end
def domain_name
name = reify.try(:name)
name = load_snapshot[:domain][:name] if event == 'create'
return name if name
end
# def domain_name
# name = reify.try(:name)
# name = load_snapshot[:domain][:name] if event == 'create'
# return name if name
# end
end

View file

@ -1,22 +1,23 @@
module UserEvents
extend ActiveSupport::Concern
module ClassMethods
def registrar_events(id)
registrar = Registrar.find(id)
return [] unless registrar
@events = []
registrar.users.each { |user| @events << user_events(user.id) }
registrar.api_users.each { |user| @events << epp_user_events(user.id) }
@events
end
# TODO: remove old
# module ClassMethods
# def registrar_events(id)
# registrar = Registrar.find(id)
# return [] unless registrar
# @events = []
# registrar.users.each { |user| @events << user_events(user.id) }
# registrar.epp_users.each { |user| @events << epp_user_events(user.id) }
# @events
# end
def user_events(id)
where(whodunnit: id.to_s)
end
# def user_events(id)
# where(whodunnit: id.to_s)
# end
def epp_user_events(id)
where(whodunnit: "#{id}-ApiUser")
end
end
# def epp_user_events(id)
# where(whodunnit: "#{id}-EppUser")
# end
# end
end

View file

@ -0,0 +1,12 @@
module VersionSession
extend ActiveSupport::Concern
included do
before_save :add_session
def add_session
self.session = PaperSession.session
true
end
end
end

View file

@ -0,0 +1,32 @@
# Papertrail concerns is mainly tested at country spec
module Versions
extend ActiveSupport::Concern
included do
has_paper_trail class_name: "#{model_name}Version"
# add creator and updator
before_create :add_creator
before_create :add_updator
before_update :add_updator
def add_creator
self.creator_str = ::PaperTrail.whodunnit
true
end
def add_updator
self.updator_str = ::PaperTrail.whodunnit
true
end
# callbacks
def touch_domain_version
domain.try(:touch_with_version)
end
def touch_domains_version
domains.each(&:touch_with_version)
end
end
end

View file

@ -1,6 +1,5 @@
class Contact < ActiveRecord::Base
# TODO: Foreign contact will get email with activation link/username/temp password
include Versions # version/contact_version.rb
include EppErrors
has_one :address, dependent: :destroy
@ -10,9 +9,6 @@ class Contact < ActiveRecord::Base
has_many :domains, through: :domain_contacts
has_many :statuses, class_name: 'ContactStatus'
# TODO: remove the x_by
belongs_to :created_by, class_name: 'ApiUser', foreign_key: :created_by_id
belongs_to :updated_by, class_name: 'ApiUser', foreign_key: :updated_by_id
belongs_to :registrar
accepts_nested_attributes_for :address, :disclosure
@ -34,17 +30,16 @@ class Contact < ActiveRecord::Base
delegate :zip, to: :address # , prefix: true
# callbacks
# TODO: remove old
# after_commit :domains_snapshot
after_update :domains_snapshot
after_destroy :domains_snapshot
# after_update :domains_snapshot
# after_destroy :domains_snapshot
before_create :generate_code
before_create :generate_auth_info
after_create :ensure_disclosure
# scopes
scope :current_registrars, ->(id) { where(registrar_id: id) }
# archiving
has_paper_trail class_name: 'ContactVersion'
IDENT_TYPE_ICO = 'ico'
IDENT_TYPES = [
@ -72,13 +67,14 @@ class Contact < ActiveRecord::Base
create_disclosure! unless disclosure
end
def domains_snapshot
(domains + domains_owned).uniq.each do |domain|
next unless domain.is_a?(Domain)
# next if domain.versions.last == domain.create_snapshot
domain.create_version # Method from paper_trail
end
end
# TODO: remove old
# def domains_snapshot
# (domains + domains_owned).uniq.each do |domain|
# next unless domain.is_a?(Domain)
# # next if domain.versions.last == domain.create_snapshot
# domain.create_version # Method from paper_trail
# end
# end
def juridical?
ident_type == IDENT_TYPE_ICO
@ -89,11 +85,11 @@ class Contact < ActiveRecord::Base
end
def cr_id
created_by ? created_by.username : nil
# created_by ? created_by.username : nil
end
def up_id
updated_by ? updated_by.username : nil
# updated_by ? updated_by.username : nil
end
def auth_info_matches(pw)
@ -148,16 +144,17 @@ class Contact < ActiveRecord::Base
name
end
# TODO: remove old
# for archiving
def snapshot
{
name: name,
phone: phone,
code: code,
ident: ident,
email: email
}
end
# def snapshot
# {
# name: name,
# phone: phone,
# code: code,
# ident: ident,
# email: email
# }
# end
class << self
# non-EPP

View file

@ -1,4 +1,5 @@
class ContactDisclosure < ActiveRecord::Base
include Versions # version/contact_disclosure_version.rb
belongs_to :contact
def attributes_with_flag

View file

@ -1,4 +1,5 @@
class ContactStatus < ActiveRecord::Base
include Versions # version/contact_status_version.rb
include EppErrors
belongs_to :contact

View file

@ -1,8 +0,0 @@
class ContactVersion < PaperTrail::Version
include UserEvents
scope :deleted, -> { where(event: 'destroy') }
self.table_name = :contact_versions
self.sequence_name = :contact_version_id_seq
end

View file

@ -1,4 +1,5 @@
class Dnskey < ActiveRecord::Base
include Versions # version/dnskey_version.rb
include EppErrors
belongs_to :domain

View file

@ -1,4 +1,7 @@
class Domain < ActiveRecord::Base
include Versions # version/domain_version.rb
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
# TODO: most inputs should be trimmed before validatation, probably some global logic?
paginates_per 10 # just for showoff
@ -17,7 +20,9 @@ class Domain < ActiveRecord::Base
-> { where(domain_contacts: { contact_type: DomainContact::ADMIN }) },
through: :domain_contacts, source: :contact
has_many :nameservers, dependent: :delete_all, after_add: :track_nameserver_add
# TODO: remove old
# has_many :nameservers, dependent: :delete_all, after_add: :track_nameserver_add
has_many :nameservers, dependent: :delete_all
accepts_nested_attributes_for :nameservers, allow_destroy: true,
reject_if: proc { |attrs| attrs[:hostname].blank? }
@ -47,6 +52,10 @@ class Domain < ActiveRecord::Base
before_create :set_validity_dates
before_create :attach_default_contacts
after_save :manage_automatic_statuses
before_save :touch_always_version
def touch_always_version
self.updated_at = Time.now
end
validates :name_dirty, domain_name: true, uniqueness: true
validates :period, numericality: { only_integer: true }
@ -102,9 +111,10 @@ class Domain < ActiveRecord::Base
attr_accessor :owner_contact_typeahead, :update_me
# TODO: remove old
# archiving
# if proc works only on changes on domain sadly
has_paper_trail class_name: 'DomainVersion', meta: { snapshot: :create_snapshot }, if: proc(&:new_version)
# has_paper_trail class_name: 'DomainVersion', meta: { snapshot: :create_snapshot }, if: proc(&:new_version)
def tech_domain_contacts
domain_contacts.select { |x| x.contact_type == DomainContact::TECH }
@ -114,46 +124,51 @@ class Domain < ActiveRecord::Base
domain_contacts.select { |x| x.contact_type == DomainContact::ADMIN }
end
def new_version
return false if versions.try(:last).try(:snapshot) == create_snapshot
true
end
# TODO: remove old
# def new_version
# return false if versions.try(:last).try(:snapshot) == create_snapshot
# true
# end
def create_version
return true unless PaperTrail.enabled?
return true unless valid?
touch_with_version if new_version
end
# TODO: remove old
# def create_version
# return true unless PaperTrail.enabled?
# return true unless valid?
# touch_with_version if new_version
# end
def track_nameserver_add(_nameserver)
return true if versions.count == 0
return true unless valid? && new_version
# TODO: remove old
# def track_nameserver_add(_nameserver)
# return true if versions.count == 0
# return true unless valid? && new_version
touch_with_version
end
# touch_with_version
# end
def create_snapshot
oc = owner_contact.snapshot if owner_contact.is_a?(Contact)
{
owner_contact: oc,
tech_contacts: tech_contacts.map(&:snapshot),
admin_contacts: admin_contacts.map(&:snapshot),
nameservers: nameservers.map(&:snapshot),
domain: make_snapshot
}.to_yaml
end
# TODO: remove old
# def create_snapshot
# oc = owner_contact.snapshot if owner_contact.is_a?(Contact)
# {
# owner_contact: oc,
# tech_contacts: tech_contacts.map(&:snapshot),
# admin_contacts: admin_contacts.map(&:snapshot),
# nameservers: nameservers.map(&:snapshot),
# domain: make_snapshot
# }.to_yaml
# end
def make_snapshot
{
name: name,
status: status,
period: period,
period_unit: period_unit,
registrar_id: registrar.try(:id),
valid_to: valid_to,
valid_from: valid_from
}
end
# TODO: remove old
# def make_snapshot
# {
# name: name,
# status: status,
# period: period,
# period_unit: period_unit,
# registrar_id: registrar.try(:id),
# valid_to: valid_to,
# valid_from: valid_from
# }
# end
def name=(value)
value.strip!
@ -271,11 +286,20 @@ class Domain < ActiveRecord::Base
end
end
def children_log
log = HashWithIndifferentAccess.new
log[:admin_contacts] = admin_contacts.map {|ac| ac.attributes}
log[:tech_contacts] = tech_contacts.map {|tc| tc.attributes}
log[:nameservers] = nameservers.map {|ns| ns.attributes}
log[:owner_contact] = [owner_contact.try(:attributes)]
log
end
class << self
def convert_period_to_time(period, unit)
return period.to_i.days if unit == 'd'
return period.to_i.days if unit == 'd'
return period.to_i.months if unit == 'm'
return period.to_i.years if unit == 'y'
return period.to_i.years if unit == 'y'
end
end
end

View file

@ -1,10 +1,12 @@
class DomainContact < ActiveRecord::Base
include Versions # version/domain_contact_version.rb
include EppErrors
belongs_to :contact
belongs_to :domain
after_create :domain_snapshot
after_destroy :domain_snapshot
# TODO: remove old
# after_create :domain_snapshot
# after_destroy :domain_snapshot
# after_save :domain_snapshot
attr_accessor :value_typeahead
@ -38,10 +40,11 @@ class DomainContact < ActiveRecord::Base
@value_typeahead || contact.try(:name) || nil
end
def domain_snapshot
return true if domain.nil?
return true if domain.versions.count == 0 # avoid snapshot on creation
domain.create_version
true
end
# TODO: remove old
# def domain_snapshot
# return true if domain.nil?
# return true if domain.versions.count == 0 # avoid snapshot on creation
# domain.create_version
# true
# end
end

View file

@ -1,4 +1,5 @@
class DomainStatus < ActiveRecord::Base
include Versions # version/domain_status_version.rb
include EppErrors
belongs_to :domain
@ -50,9 +51,6 @@ class DomainStatus < ActiveRecord::Base
SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED
]
# archiving
has_paper_trail class_name: 'DomainStatusVersion'
def epp_code_map
{
'2302' => [ # Object exists

View file

@ -1,4 +0,0 @@
class DomainStatusVersion < PaperTrail::Version
self.table_name = :domain_status_versions
self.sequence_name = :domain_status_version_id_seq
end

View file

@ -1,4 +1,5 @@
class DomainTransfer < ActiveRecord::Base
include Versions # version/domain_transfer_version.rb
belongs_to :domain
belongs_to :transfer_from, class_name: 'Registrar'

View file

@ -1,36 +0,0 @@
class DomainVersion < PaperTrail::Version
include UserEvents
include DomainVersionObserver if Setting.whois_enabled # unless Setting.whois_enabled
scope :deleted, -> { where(event: 'destroy') }
self.table_name = :domain_versions
self.sequence_name = :domain_version_id_seq
def load_snapshot
snapshot ? YAML.load(snapshot) : {}
end
def previous?
return true if previous
false
end
def name
name = reify.try(:name)
name = load_snapshot[:domain].try(:[], :name) unless name
name
end
def changed_elements
return [] unless previous?
@changes = []
@previous_snap = previous.load_snapshot
@snap = load_snapshot
[:owner_contact, :tech_contacts, :admin_contacts, :nameservers, :domain].each do |key|
@changes << key unless @snap[key] == @previous_snap[key]
end
@changes
end
end

View file

@ -162,36 +162,36 @@ class Epp::EppDomain < Domain
end
def detach_contacts(contact_list)
to_delete = []
to_destroy = []
contact_list.each do |k, v|
v.each do |x|
contact = domain_contacts.joins(:contact).where(contacts: { code: x[:contact] }, contact_type: k.to_s)
if contact.blank?
add_epp_error('2303', 'contact', x[:contact], [:domain_contacts, :not_found])
else
to_delete << contact
to_destroy << contact
end
end
end
domain_contacts.delete(to_delete)
domain_contacts.destroy(to_destroy)
end
def detach_nameservers(ns_list)
to_delete = []
to_destroy = []
ns_list.each do |ns_attrs|
nameserver = nameservers.where(ns_attrs)
if nameserver.blank?
add_epp_error('2303', 'hostAttr', ns_attrs[:hostname], [:nameservers, :not_found])
else
to_delete << nameserver
to_destroy << nameserver
end
end
nameservers.delete(to_delete)
nameservers.destroy(to_destroy)
end
def detach_statuses(status_list)
to_delete = []
to_destroy = []
status_list.each do |x|
unless DomainStatus::CLIENT_STATUSES.include?(x[:value])
add_epp_error('2303', 'status', x[:value], [:domain_statuses, :not_found])
@ -202,11 +202,11 @@ class Epp::EppDomain < Domain
if status.blank?
add_epp_error('2303', 'status', x[:value], [:domain_statuses, :not_found])
else
to_delete << status
to_destroy << status
end
end
domain_statuses.delete(to_delete)
domain_statuses.destroy(to_destroy)
end
def attach_dnskeys(dnssec_data)
@ -258,13 +258,13 @@ class Epp::EppDomain < Domain
def detach_dnskeys(dnssec_data)
return false unless validate_dnssec_data(dnssec_data)
to_delete = []
to_destroy = []
dnssec_data[:ds_data].each do |x|
ds = dnskeys.where(ds_key_tag: x[:ds_key_tag])
if ds.blank?
add_epp_error('2303', 'keyTag', x[:key_tag], [:dnskeys, :not_found])
else
to_delete << ds
to_destroy << ds
end
end
@ -273,11 +273,11 @@ class Epp::EppDomain < Domain
if ds.blank?
add_epp_error('2303', 'publicKey', x[:public_key], [:dnskeys, :not_found])
else
to_delete << ds
to_destroy << ds
end
end
dnskeys.delete(to_delete)
dnskeys.destroy(to_destroy)
end
### RENEW ###

View file

@ -1,4 +1,5 @@
class Keyrelay < ActiveRecord::Base
include Versions # version/keyrelay_version.rb
include EppErrors
belongs_to :domain
@ -15,6 +16,8 @@ class Keyrelay < ActiveRecord::Base
validate :validate_expiry_relative_xor_expiry_absolute
after_save :touch_domain_version
def epp_code_map
{
'2005' => [

View file

@ -1,4 +1,5 @@
class LegalDocument < ActiveRecord::Base
include Versions # version/legal_document_version.rb
belongs_to :documentable, polymorphic: true
TYPES = %w(pdf bdoc ddoc zip rar gz tar 7z)

View file

@ -1,4 +1,5 @@
class Message < ActiveRecord::Base
include Versions # version/message_version.rb
belongs_to :registrar
before_create -> { self.queued = true }

View file

@ -1,4 +1,5 @@
class Nameserver < ActiveRecord::Base
include Versions # version/nameserver_version.rb
include EppErrors
belongs_to :registrar
@ -10,9 +11,8 @@ class Nameserver < ActiveRecord::Base
validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true }
# rubocop: enable Metrics/LineLength
# archiving
has_paper_trail class_name: 'NameserverVersion'
after_destroy :domain_version
# TODO: remove old
# after_destroy :domain_version
before_validation :normalize_attributes
@ -34,13 +34,14 @@ class Nameserver < ActiveRecord::Base
}
end
def snapshot
{
hostname: hostname,
ipv4: ipv4,
ipv6: ipv6
}
end
# TODO: remove old
# def snapshot
# {
# hostname: hostname,
# ipv4: ipv4,
# ipv6: ipv6
# }
# end
def normalize_attributes
self.hostname = hostname.try(:strip).try(:downcase)
@ -48,9 +49,10 @@ class Nameserver < ActiveRecord::Base
self.ipv6 = ipv6.try(:strip).try(:upcase)
end
def domain_version
domain.create_version if domain
end
# TODO: remove old
# def domain_version
# domain.create_version if domain
# end
def to_s
hostname

View file

@ -1,4 +0,0 @@
class NameserverVersion < PaperTrail::Version
self.table_name = :nameserver_versions
self.sequence_name = :nameserver_version_id_seq
end

View file

@ -1,4 +1,6 @@
class Registrar < ActiveRecord::Base
include Versions # version/registrar_version.rb
has_many :domains, dependent: :restrict_with_error
has_many :contacts, dependent: :restrict_with_error
has_many :api_users, dependent: :restrict_with_error
@ -6,6 +8,7 @@ class Registrar < ActiveRecord::Base
validates :name, :reg_no, :address, :country, :email, presence: true
validates :name, :reg_no, uniqueness: true
after_save :touch_domains_version
validates :email, :billing_email, format: /@/, allow_blank: true

View file

@ -1,2 +1,3 @@
class ReservedDomain < ActiveRecord::Base
include Versions # version/reserved_domain_version.rb
end

View file

@ -1,2 +1,3 @@
class Setting < RailsSettings::CachedSettings
include Versions # version/setting_version.rb
end

View file

@ -1,4 +1,5 @@
class User < ActiveRecord::Base
include Versions # version/user_version.rb
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :trackable, :timeoutable

View file

@ -0,0 +1,5 @@
class AddressVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_addresses
self.sequence_name = :log_addresses_id_seq
end

View file

@ -0,0 +1,5 @@
class ApiUserVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_api_users
self.sequence_name = :log_api_users_id_seq
end

View file

@ -0,0 +1,5 @@
class ContactDisclosureVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_contact_disclosures
self.sequence_name = :log_contact_disclosures_id_seq
end

View file

@ -0,0 +1,5 @@
class ContactStatusVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_contact_statuses
self.sequence_name = :log_contact_statuses_id_seq
end

View file

@ -0,0 +1,9 @@
class ContactVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_contacts
self.sequence_name = :log_contacts_id_seq
# include UserEvents
# scope :deleted, -> { where(event: 'destroy') }
end

View file

@ -0,0 +1,5 @@
class CountryVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_countries
self.sequence_name = :log_countries_id_seq
end

View file

@ -0,0 +1,5 @@
class DnskeyVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_dnskeys
self.sequence_name = :log_dnskeys_id_seq
end

View file

@ -0,0 +1,5 @@
class DomainContactVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_domain_contacts
self.sequence_name = :log_domain_contacts_id_seq
end

View file

@ -0,0 +1,5 @@
class DomainStatusVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_domain_statuses
self.sequence_name = :log_domain_statuses_id_seq
end

View file

@ -0,0 +1,5 @@
class DomainTransferVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_domain_transfers
self.sequence_name = :log_domain_transfers_id_seq
end

View file

@ -0,0 +1,43 @@
class DomainVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_domains
self.sequence_name = :log_domains_id_seq
include UserEvents
# TODO: remove old
# include DomainVersionObserver if Setting.whois_enabled # unless Setting.whois_enabled
scope :deleted, -> { where(event: 'destroy') }
# TODO: remove old
# def load_snapshot
# snapshot ? YAML.load(snapshot) : {}
# end
# TODO: remove old
# def previous?
# return true if previous
# false
# end
# TODO: remove old
# def name
# name = reify.try(:name)
# name = load_snapshot[:domain].try(:[], :name) unless name
# name
# end
# TODO: remove old
# def changed_elements
# return [] unless previous?
# @changes = []
# @previous_snap = previous.load_snapshot
# @snap = load_snapshot
# [:owner_contact, :tech_contacts, :admin_contacts, :nameservers, :domain].each do |key|
# @changes << key unless @snap[key] == @previous_snap[key]
# end
# @changes
# end
end

View file

@ -0,0 +1,5 @@
class KeyrelayVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_keyrelays
self.sequence_name = :log_keyrelays_id_seq
end

View file

@ -0,0 +1,5 @@
class LegalDocumentVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_legal_documents
self.sequence_name = :log_legal_documents_id_seq
end

View file

@ -0,0 +1,5 @@
class MessageVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_messages
self.sequence_name = :log_messages_id_seq
end

View file

@ -0,0 +1,5 @@
class NameserverVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_nameservers
self.sequence_name = :log_nameservers_id_seq
end

View file

@ -0,0 +1,5 @@
class RegistrarVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_registrars
self.sequence_name = :log_registrars_id_seq
end

View file

@ -0,0 +1,5 @@
class ReservedDomainVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_reserved_domains
self.sequence_name = :log_reserved_domains_id_seq
end

View file

@ -0,0 +1,5 @@
class SettingVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_settings
self.sequence_name = :log_settings_id_seq
end

View file

@ -0,0 +1,5 @@
class UserVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_users
self.sequence_name = :log_users_id_seq
end

View file

@ -0,0 +1,5 @@
class ZonefileSettingVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_zonefile_settings
self.sequence_name = :log_zonefile_settings_id_seq
end

View file

@ -1,4 +1,5 @@
class ZonefileSetting < ActiveRecord::Base
include Versions # version/zonefile_setting_version.rb
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, presence: true
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }