Merge branch 'master' of github.com:domify/registry

This commit is contained in:
Martin Lensment 2015-04-02 18:31:05 +03:00
commit 53023b455c
33 changed files with 746 additions and 143 deletions

View file

@ -72,7 +72,7 @@ class Ability
can :manage, LegalDocument
can :read, ApiLog::EppLog
can :read, ApiLog::ReppLog
can :index, :delayed_job
# can :index, :delayed_job
can :create, :zonefile
can :access, :settings_menu
end

View file

@ -1,36 +1,3 @@
module DomainVersionObserver
extend ActiveSupport::Concern
# TODO: remove old
# included do
# after_save :delayed_whois_update
# end
# 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 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 domain_name
# name = reify.try(:name)
# name = load_snapshot[:domain][:name] if event == 'create'
# return name if name
# end
end

View file

@ -39,10 +39,14 @@ class Contact < ActiveRecord::Base
scope :current_registrars, ->(id) { where(registrar_id: id) }
BIC = 'bic'
PRIV = 'priv'
BIRTHDAY = 'birthday'
PASSPORT = 'passport'
IDENT_TYPES = [
BIC, # Company registry code (or similar)
'priv', # National idendtification number
'birthday' # Birthday date
BIC, # Company registry code (or similar)
PRIV, # National idendtification number
BIRTHDAY # Birthday date
]
class << self
@ -84,7 +88,7 @@ class Contact < ActiveRecord::Base
end
def to_s
name
name || '[no name]'
end
def ident_valid_format?

View file

@ -73,9 +73,9 @@ class Dnskey < ActiveRecord::Base
hex = [domain.name_in_wire_format, flags_hex, protocol_hex, alg_hex, public_key_hex].join
bin = self.class.hex_to_bin(hex)
if Setting.ds_algorithm == 1
if ds_digest_type == 1
self.ds_digest = Digest::SHA1.hexdigest(bin).upcase
elsif Setting.ds_algorithm == 2
elsif ds_digest_type == 2
self.ds_digest = Digest::SHA256.hexdigest(bin).upcase
end
end

View file

@ -236,7 +236,7 @@ class Domain < ActiveRecord::Base
# rubocop:disable Metrics/MethodLength
def update_whois_body
new_whois_body = <<-EOS
self.whois_body = <<-EOS
This Whois Server contains information on
Estonian Top Level Domain ee TLD
@ -261,11 +261,8 @@ class Domain < ActiveRecord::Base
changed: #{registrar.updated_at.to_s(:db)}
EOS
return if whois_body == new_whois_body
update_column(whois_body: new_whois_body)
update_whois_server
end
handle_asynchronously :update_whois_body
# rubocop:enable Metrics/MethodLength
def contacts_body

View file

@ -0,0 +1,8 @@
module Legacy
class Contact < Db
self.table_name = :contact
belongs_to :object_registry, foreign_key: :id
belongs_to :object, foreign_key: :id
belongs_to :object_state, foreign_key: :id, primary_key: :object_id
end
end

14
app/models/legacy/db.rb Normal file
View file

@ -0,0 +1,14 @@
module Legacy
class Db < ActiveRecord::Base
self.abstract_class = true
begin
establish_connection :fred
rescue ActiveRecord::AdapterNotSpecified => e
logger.info "'fred' database not configured, please update your database.yml file: #{e}"
end
def readonly?
true
end
end
end

View file

@ -0,0 +1,5 @@
module Legacy
class Dnskey < Db
self.table_name = :dnskey
end
end

View file

@ -0,0 +1,15 @@
module Legacy
class Domain < Db
self.table_name = :domain
belongs_to :object_registry, foreign_key: :id
belongs_to :object, foreign_key: :id
belongs_to :nsset, foreign_key: :nsset
# belongs_to :registrant, foreign_key: :registrant, primary_key: :legacy_id, class_name: '::Contact'
has_many :object_states, -> { where('valid_to IS NULL') }, foreign_key: :object_id
has_many :dnskeys, foreign_key: :keysetid, primary_key: :keyset
has_many :domain_contact_maps, foreign_key: :domainid
has_many :nsset_contact_maps, foreign_key: :nssetid, primary_key: :nsset
end
end

View file

@ -0,0 +1,7 @@
module Legacy
class DomainContactMap < Db
self.table_name = :domain_contact_map
# belongs_to :contact, foreign_key: :contactid, primary_key: :legacy_id, class_name: '::Contact'
end
end

View file

@ -0,0 +1,5 @@
module Legacy
class EnumObjectState < Db
self.table_name = :enum_object_states
end
end

View file

@ -0,0 +1,7 @@
module Legacy
class Host < Db
self.table_name = :host
has_many :host_ipaddr_maps, foreign_key: :hostid
end
end

View file

@ -0,0 +1,5 @@
module Legacy
class HostIpaddrMap < Db
self.table_name = :host_ipaddr_map
end
end

View file

@ -0,0 +1,7 @@
module Legacy
class Nsset < Db
self.table_name = :nsset
has_many :hosts, foreign_key: :nssetid
end
end

View file

@ -0,0 +1,5 @@
module Legacy
class NssetContactMap < Db
self.table_name = :nsset_contact_map
end
end

View file

@ -0,0 +1,10 @@
module Legacy
class Object < Db
self.table_name = :object
def self.instance_method_already_implemented?(method_name)
return true if method_name == 'update'
super
end
end
end

View file

@ -0,0 +1,7 @@
module Legacy
class ObjectRegistry < Db
self.table_name = :object_registry
self.inheritance_column = nil
belongs_to :registrar, foreign_key: :crid, primary_key: :legacy_id, class_name: '::Registrar'
end
end

View file

@ -0,0 +1,80 @@
module Legacy
class ObjectState < Db
self.table_name = :object_state
def name
# legacy values
# 2 => "serverRenewProhibited",
# 5 => "serverOutzoneManual",
# 6 => "serverInzoneManual",
# 7 => "serverBlocked",
# 8 => "expirationWarning",
# 9 => "expired",
# 10 => "unguarded",
# 11 => "validationWarning1",
# 12 => "validationWarning2",
# 13 => "notValidated",
# 14 => "nssetMissing",
# 15 => "outzone",
# 18 => "serverRegistrantChangeProhibited",
# 19 => "deleteWarning",
# 20 => "outzoneUnguarded",
# 1 => "serverDeleteProhibited",
# 3 => "serverTransferProhibited",
# 4 => "serverUpdateProhibited",
# 16 => "linked",
# 17 => "deleteCandidate",
# 21 => "forceDelete"
# new values
map = {
2 => "serverRenewProhibited",
5 => "serverHold",
6 => "serverManualInzone",
7 => "serverBlocked",
9 => "expired",
11 => "validationWarning1",
13 => "notValidated",
14 => "nssetMissing",
15 => "serverHold",
18 => "serverRegistrantChangeProhibited",
1 => "serverDeleteProhibited",
3 => "serverTransferProhibited",
4 => "serverUpdateProhibited",
16 => "linked",
17 => "deleteCandidate", # grupistaatus
21 => "forceDelete" # grupistaatus
}
map[state_id]
end
def desc
map = {
1 => "Delete prohibited",
2 => "Registration renew prohibited",
3 => "Sponsoring registrar change prohibited",
4 => "Update prohibited",
7 => "Domain blocked",
8 => "Expires within 30 days",
9 => "Expired",
10 => "Domain is 30 days after expiration",
11 => "Validation of domain expire in 30 days",
12 => "Validation of domain expire in 15 days",
13 => "Domain not validated",
14 => "Domain has not associated nsset",
15 => "Domain is not generated into zone",
16 => "Has relation to other records in registry",
17 => "Object is going to be deleted",
18 => "Registrant change prohibited",
19 => "Domain will be deleted in 11 days",
20 => "Domain is out of zone after 30 days from expiration",
21 => "Domain is forced to delete",
5 => "Domain is administratively kept out of zone",
6 => "Domain is administratively kept in zone"
}
map[state_id]
end
end
end

View file

@ -0,0 +1,5 @@
module Legacy
class Registrar < Db
self.table_name = :registrar
end
end

View file

@ -48,7 +48,7 @@
-# %li= link_to t(:domains_history), admin_domain_versions_path
%li= link_to t(:epp_logs), admin_epp_logs_path
%li= link_to t(:repp_logs), admin_repp_logs_path
%li= link_to t(:background_jobs), admin_delayed_jobs_path
-# %li= link_to t(:background_jobs), admin_delayed_jobs_path
%li.divider
%li.dropdown-header= t('users')