mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 00:12:03 +02:00
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:
commit
7537bb3712
91 changed files with 1614 additions and 698 deletions
|
@ -17,3 +17,6 @@
|
|||
color: #777
|
||||
padding-top: 15px
|
||||
font-size: 10px
|
||||
|
||||
.nowrap
|
||||
white-space: nowrap
|
||||
|
|
|
@ -3,7 +3,7 @@ class Admin::ApiUsersController < AdminController
|
|||
before_action :set_api_user, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@q = ApiUser.search(params[:q])
|
||||
@q = ApiUser.includes(:registrar).search(params[:q])
|
||||
@api_users = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
|
|
|
@ -2,12 +2,16 @@ class Admin::DomainVersionsController < AdminController
|
|||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@q = DomainVersion.deleted.search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
@domain = Domain.find(params[:domain_id])
|
||||
@versions = @domain.versions
|
||||
end
|
||||
|
||||
def show
|
||||
@versions = DomainVersion.where(item_id: params[:id])
|
||||
@name = @versions.last.name
|
||||
end
|
||||
# def index
|
||||
# # @q = DomainVersion.deleted.search(params[:q])
|
||||
# # @domains = @q.result.page(params[:page])
|
||||
# end
|
||||
|
||||
# def show
|
||||
# @versions = DomainVersion.where(item_id: params[:id])
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,26 @@ class ApplicationController < ActionController::Base
|
|||
return session[:user_return_to].to_s if session[:user_return_to] && session[:user_return_to] != login_path
|
||||
admin_dashboard_path
|
||||
end
|
||||
|
||||
def user_for_paper_trail
|
||||
if defined?(current_api_user) && current_api_user.present?
|
||||
# Most of the time it's not loaded in correct time because PaperTrail before filter kicks in
|
||||
# before current_api_user is defined. PaperTrail is triggered also at current_api_user
|
||||
api_user_log_str(current_api_user)
|
||||
elsif current_user.present?
|
||||
"#{current_user.id}-#{current_user.username}"
|
||||
else
|
||||
'public'
|
||||
end
|
||||
end
|
||||
|
||||
def api_user_log_str(user)
|
||||
if user.present?
|
||||
"#{user.id}-api-#{user.username}"
|
||||
else
|
||||
'api-public'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
module Shared::UserStamper
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def stamp(obj)
|
||||
return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id)
|
||||
# def stamp(obj)
|
||||
# return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id)
|
||||
|
||||
if obj.new_record?
|
||||
obj.created_by_id = current_api_user.id
|
||||
else
|
||||
obj.updated_by_id = current_api_user.id
|
||||
end
|
||||
# if obj.new_record?
|
||||
# obj.created_by_id = current_api_user.id
|
||||
# else
|
||||
# obj.updated_by_id = current_api_user.id
|
||||
# end
|
||||
|
||||
true
|
||||
end
|
||||
# true
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
class Epp::ContactsController < EppController
|
||||
include Shared::UserStamper ## Refactor this?
|
||||
helper WhodunnitHelper ## Refactor this?
|
||||
|
||||
def user_for_paper_trail ## Refactor this?
|
||||
current_api_user ? "#{current_api_user.id}-ApiUser" : nil
|
||||
end
|
||||
|
||||
def create
|
||||
@contact = Contact.new(contact_and_address_attributes)
|
||||
@contact.registrar = current_api_user.registrar
|
||||
render_epp_response '/epp/contacts/create' and return if stamp(@contact) && @contact.save
|
||||
render_epp_response '/epp/contacts/create' and return if @contact.save
|
||||
handle_errors(@contact)
|
||||
end
|
||||
|
||||
|
@ -18,8 +13,8 @@ class Epp::ContactsController < EppController
|
|||
code = params_hash['epp']['command']['update']['update'][:id]
|
||||
|
||||
@contact = Contact.where(code: code).first
|
||||
# if update_rights? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update))
|
||||
if owner? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update))
|
||||
# if update_rights? && @contact.update_attributes(contact_and_address_attributes(:update))
|
||||
if owner? && @contact.update_attributes(contact_and_address_attributes(:update))
|
||||
render_epp_response 'epp/contacts/update'
|
||||
else
|
||||
contact_exists?(code)
|
||||
|
|
|
@ -22,7 +22,14 @@ class EppController < ApplicationController
|
|||
end
|
||||
|
||||
def current_api_user
|
||||
@current_api_user ||= ApiUser.find(epp_session[:api_user_id]) if epp_session[:api_user_id]
|
||||
return @current_api_user if @current_api_user
|
||||
|
||||
@current_api_user ||= ApiUser.find_by_id(epp_session[:api_user_id])
|
||||
# by default PaperTrail uses before filter and at that
|
||||
# time current_api_user is not yet present
|
||||
::PaperTrail.whodunnit = api_user_log_str(@current_api_user)
|
||||
::PaperSession.session = epp_session.session_id if epp_session.session_id.present?
|
||||
@current_api_user
|
||||
end
|
||||
|
||||
# ERROR + RESPONSE HANDLING
|
||||
|
@ -198,7 +205,7 @@ class EppController < ApplicationController
|
|||
request_successful: epp_errors.empty?,
|
||||
request_object: params[:epp_object_type],
|
||||
response: @response,
|
||||
api_user_name: @api_user.try(:to_s) || current_api_user.try(:to_s),
|
||||
api_user_name: PaperTrail.whodunnit,
|
||||
api_user_registrar: @api_user.try(:registrar).try(:to_s) || current_api_user.try(:registrar).try(:to_s),
|
||||
ip: request.ip
|
||||
})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
class AddressVersion < PaperTrail::Version
|
||||
self.table_name = :address_versions
|
||||
self.sequence_name = :address_version_id_seq
|
||||
end
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
12
app/models/concerns/version_session.rb
Normal file
12
app/models/concerns/version_session.rb
Normal 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
|
32
app/models/concerns/versions.rb
Normal file
32
app/models/concerns/versions.rb
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class ContactDisclosure < ActiveRecord::Base
|
||||
include Versions # version/contact_disclosure_version.rb
|
||||
belongs_to :contact
|
||||
|
||||
def attributes_with_flag
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class ContactStatus < ActiveRecord::Base
|
||||
include Versions # version/contact_status_version.rb
|
||||
include EppErrors
|
||||
|
||||
belongs_to :contact
|
||||
|
|
|
@ -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
|
|
@ -1,4 +1,5 @@
|
|||
class Dnskey < ActiveRecord::Base
|
||||
include Versions # version/dnskey_version.rb
|
||||
include EppErrors
|
||||
|
||||
belongs_to :domain
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
class DomainStatusVersion < PaperTrail::Version
|
||||
self.table_name = :domain_status_versions
|
||||
self.sequence_name = :domain_status_version_id_seq
|
||||
end
|
|
@ -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'
|
||||
|
|
|
@ -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
|
|
@ -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 ###
|
||||
|
|
|
@ -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' => [
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Message < ActiveRecord::Base
|
||||
include Versions # version/message_version.rb
|
||||
belongs_to :registrar
|
||||
|
||||
before_create -> { self.queued = true }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
class NameserverVersion < PaperTrail::Version
|
||||
self.table_name = :nameserver_versions
|
||||
self.sequence_name = :nameserver_version_id_seq
|
||||
end
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
class ReservedDomain < ActiveRecord::Base
|
||||
include Versions # version/reserved_domain_version.rb
|
||||
end
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
class Setting < RailsSettings::CachedSettings
|
||||
include Versions # version/setting_version.rb
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
5
app/models/version/address_version.rb
Normal file
5
app/models/version/address_version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddressVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_addresses
|
||||
self.sequence_name = :log_addresses_id_seq
|
||||
end
|
5
app/models/version/api_user_version.rb
Normal file
5
app/models/version/api_user_version.rb
Normal 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
|
5
app/models/version/contact_disclosure_version.rb
Normal file
5
app/models/version/contact_disclosure_version.rb
Normal 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
|
5
app/models/version/contact_status_version.rb
Normal file
5
app/models/version/contact_status_version.rb
Normal 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
|
9
app/models/version/contact_version.rb
Normal file
9
app/models/version/contact_version.rb
Normal 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
|
5
app/models/version/country_version.rb
Normal file
5
app/models/version/country_version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class CountryVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_countries
|
||||
self.sequence_name = :log_countries_id_seq
|
||||
end
|
5
app/models/version/dnskey_version.rb
Normal file
5
app/models/version/dnskey_version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class DnskeyVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_dnskeys
|
||||
self.sequence_name = :log_dnskeys_id_seq
|
||||
end
|
5
app/models/version/domain_contact_version.rb
Normal file
5
app/models/version/domain_contact_version.rb
Normal 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
|
5
app/models/version/domain_status_version.rb
Normal file
5
app/models/version/domain_status_version.rb
Normal 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
|
5
app/models/version/domain_transfer_version.rb
Normal file
5
app/models/version/domain_transfer_version.rb
Normal 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
|
43
app/models/version/domain_version.rb
Normal file
43
app/models/version/domain_version.rb
Normal 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
|
5
app/models/version/keyrelay_version.rb
Normal file
5
app/models/version/keyrelay_version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class KeyrelayVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_keyrelays
|
||||
self.sequence_name = :log_keyrelays_id_seq
|
||||
end
|
5
app/models/version/legal_document_version.rb
Normal file
5
app/models/version/legal_document_version.rb
Normal 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
|
5
app/models/version/message_version.rb
Normal file
5
app/models/version/message_version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class MessageVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_messages
|
||||
self.sequence_name = :log_messages_id_seq
|
||||
end
|
5
app/models/version/nameserver_version.rb
Normal file
5
app/models/version/nameserver_version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class NameserverVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_nameservers
|
||||
self.sequence_name = :log_nameservers_id_seq
|
||||
end
|
5
app/models/version/registrar_version.rb
Normal file
5
app/models/version/registrar_version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class RegistrarVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_registrars
|
||||
self.sequence_name = :log_registrars_id_seq
|
||||
end
|
5
app/models/version/reserved_domain_version.rb
Normal file
5
app/models/version/reserved_domain_version.rb
Normal 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
|
5
app/models/version/setting_version.rb
Normal file
5
app/models/version/setting_version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class SettingVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_settings
|
||||
self.sequence_name = :log_settings_id_seq
|
||||
end
|
5
app/models/version/user_version.rb
Normal file
5
app/models/version/user_version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class UserVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_users
|
||||
self.sequence_name = :log_users_id_seq
|
||||
end
|
5
app/models/version/zonefile_setting_version.rb
Normal file
5
app/models/version/zonefile_setting_version.rb
Normal 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
|
|
@ -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 }
|
||||
|
||||
|
|
|
@ -1,63 +1,125 @@
|
|||
%td{ class: changes.include?(:domain) ? 'edit-highlight' : 'no-highlight' }
|
||||
- if children[:domain]
|
||||
%p{:style => "font-size:x-small;"}
|
||||
= children[:domain][:period]
|
||||
= children[:domain][:period_unit] if children[:domain][:period]
|
||||
- if children[:domain][:valid_to] && children[:domain][:valid_from]
|
||||
= ","
|
||||
= l(children[:domain][:valid_from], format: :date) + '-' + l(children[:domain][:valid_to], format: :date)
|
||||
- if children[:domain].try(:[], :registrar_id)
|
||||
= ","
|
||||
= Registrar.find(children[:domain][:registrar_id]).try(:name)
|
||||
- if children[:domain][:status]
|
||||
= ',' + children[:domain][:status]
|
||||
|
||||
|
||||
%td{ class: changes.include?(:owner_contact) ? 'edit-highlight' : 'no-highlight' }
|
||||
- if children[:owner_contact]
|
||||
%p{:style => "font-size:x-small;"}
|
||||
= children[:owner_contact][:name]
|
||||
= ","
|
||||
= children[:owner_contact][:phone]
|
||||
= ","
|
||||
= children[:owner_contact][:email]
|
||||
= ","
|
||||
= children[:owner_contact][:code]
|
||||
|
||||
%td{ class: changes.include?(:admin_contacts) ? 'edit-highlight' : 'no-highlight' }
|
||||
- if children[:admin_contacts]
|
||||
- children[:admin_contacts].each do |ac|
|
||||
%p{:style => "font-size:x-small;"}
|
||||
= ac[:name]
|
||||
= ","
|
||||
= ac[:phone]
|
||||
= ","
|
||||
= ac[:email]
|
||||
= ","
|
||||
= ac[:code]
|
||||
|
||||
%td{ class: changes.include?(:tech_contacts) ? 'edit-highlight' : 'no-highlight' }
|
||||
- if children[:tech_contacts]
|
||||
- children[:tech_contacts].each do |tc|
|
||||
%p{:style => "font-size:x-small;"}
|
||||
= tc[:name]
|
||||
= ","
|
||||
= tc[:phone]
|
||||
= ","
|
||||
= tc[:email]
|
||||
= ","
|
||||
= tc[:code]
|
||||
|
||||
%td{ class: changes.include?(:nameservers) ? 'edit-highlight' : 'no-highlight' }
|
||||
- if children[:nameservers]
|
||||
- children[:nameservers].each do |ns|
|
||||
%p{:style => "font-size:x-small;"}
|
||||
= ns[:hostname]
|
||||
= ","
|
||||
= ns[:ipv4] || ns[:ipv6]
|
||||
- children = HashWithIndifferentAccess.new(version.children)
|
||||
- nameservers = children[:nameservers] || []
|
||||
- tech_contacts = children[:tech_contacts] || []
|
||||
- admin_contacts = children[:admin_contacts] || []
|
||||
- owner_contact = children[:owner_contact] || []
|
||||
|
||||
%td
|
||||
%p{ :style => 'font-size:x-small;' }
|
||||
= l(version.created_at, format: :short)
|
||||
= whodunnit_with_protocol(version.whodunnit)
|
||||
%p.nowrap
|
||||
= l(domain.updated_at, format: :short)
|
||||
= version.event
|
||||
%p.text-right
|
||||
= version.terminator
|
||||
|
||||
%td
|
||||
%p
|
||||
= "#{domain.period}#{domain.period_unit}"
|
||||
= "#{l(domain.valid_from, format: :date)} - #{l(domain.valid_to, format: :date)}"
|
||||
%p
|
||||
= domain.status
|
||||
|
||||
%td
|
||||
- owner_contact.each do |oc|
|
||||
%p
|
||||
= oc[:name]
|
||||
= oc[:phone]
|
||||
= oc[:email]
|
||||
%p
|
||||
= oc[:code]
|
||||
|
||||
%td
|
||||
- admin_contacts.each do |ac|
|
||||
%p
|
||||
= ac[:name]
|
||||
= ac[:phone]
|
||||
= ac[:email]
|
||||
%p
|
||||
= ac[:code]
|
||||
|
||||
%td
|
||||
- tech_contacts.each do |tc|
|
||||
%p
|
||||
= tc[:name]
|
||||
= tc[:phone]
|
||||
= tc[:email]
|
||||
%p
|
||||
= tc[:code]
|
||||
|
||||
%td
|
||||
- nameservers.each do |ns|
|
||||
%p
|
||||
= ns[:hostname]
|
||||
%br
|
||||
= ns[:ipv4]
|
||||
= ns[:ipv6]
|
||||
|
||||
%td
|
||||
%p
|
||||
= domain.registrar.name
|
||||
|
||||
-# %td
|
||||
-# = version.children.inspect
|
||||
|
||||
-# %td{ class: changes.include?(:domain) ? 'edit-highlight' : 'no-highlight' }
|
||||
-# - if children[:domain]
|
||||
-# %p{:style => "font-size:x-small;"}
|
||||
-# = children[:domain][:period]
|
||||
-# = children[:domain][:period_unit] if children[:domain][:period]
|
||||
-# - if children[:domain][:valid_to] && children[:domain][:valid_from]
|
||||
-# = ","
|
||||
-# = l(children[:domain][:valid_from], format: :date) + '-' + l(children[:domain][:valid_to], format: :date)
|
||||
-# - if children[:domain].try(:[], :registrar_id)
|
||||
-# = ","
|
||||
-# = Registrar.find(children[:domain][:registrar_id]).try(:name)
|
||||
-# - if children[:domain][:status]
|
||||
-# = ',' + children[:domain][:status]
|
||||
|
||||
|
||||
-# %td{ class: changes.include?(:owner_contact) ? 'edit-highlight' : 'no-highlight' }
|
||||
-# - if children[:owner_contact]
|
||||
-# %p{:style => "font-size:x-small;"}
|
||||
-# = children[:owner_contact][:name]
|
||||
-# = ","
|
||||
-# = children[:owner_contact][:phone]
|
||||
-# = ","
|
||||
-# = children[:owner_contact][:email]
|
||||
-# = ","
|
||||
-# = children[:owner_contact][:code]
|
||||
|
||||
-# %td{ class: changes.include?(:admin_contacts) ? 'edit-highlight' : 'no-highlight' }
|
||||
-# - if children[:admin_contacts]
|
||||
-# - children[:admin_contacts].each do |ac|
|
||||
-# %p{:style => "font-size:x-small;"}
|
||||
-# = ac[:name]
|
||||
-# = ","
|
||||
-# = ac[:phone]
|
||||
-# = ","
|
||||
-# = ac[:email]
|
||||
-# = ","
|
||||
-# = ac[:code]
|
||||
|
||||
-# %td{ class: changes.include?(:tech_contacts) ? 'edit-highlight' : 'no-highlight' }
|
||||
-# - if children[:tech_contacts]
|
||||
-# - children[:tech_contacts].each do |tc|
|
||||
-# %p{:style => "font-size:x-small;"}
|
||||
-# = tc[:name]
|
||||
-# = ","
|
||||
-# = tc[:phone]
|
||||
-# = ","
|
||||
-# = tc[:email]
|
||||
-# = ","
|
||||
-# = tc[:code]
|
||||
|
||||
-# %td{ class: changes.include?(:nameservers) ? 'edit-highlight' : 'no-highlight' }
|
||||
-# - if children[:nameservers]
|
||||
-# - children[:nameservers].each do |ns|
|
||||
-# %p{:style => "font-size:x-small;"}
|
||||
-# = ns[:hostname]
|
||||
-# = ","
|
||||
-# = ns[:ipv4] || ns[:ipv6]
|
||||
|
||||
-# %td
|
||||
-# %p{ :style => 'font-size:x-small;' }
|
||||
-# = l(version.created_at, format: :short)
|
||||
-# = whodunnit_with_protocol(version.whodunnit)
|
||||
-# = version.event
|
||||
|
|
|
@ -1,28 +1,31 @@
|
|||
.row
|
||||
.col-sm-12
|
||||
%h2.text-center-xs= t('domains')
|
||||
.col-sm-6
|
||||
%h2.text-center-xs
|
||||
= "#{t(:domain_history)}: #{@domain.name}"
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
|
||||
%hr
|
||||
.row
|
||||
.col-md-12
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-1'}
|
||||
= t('name')
|
||||
%th{class: 'col-xs-1'}
|
||||
= sort_link(@q, 'whodunnit')
|
||||
%th{class: 'col-xs-1'}
|
||||
= sort_link(@q, 'created_at')
|
||||
%th{class: 'col-xs-1'}= t(:timestap)
|
||||
%th{class: 'col-xs-2'}= t(:period)
|
||||
%th{class: 'col-xs-2'}= t(:owner)
|
||||
%th{class: 'col-xs-2'}= t(:admin)
|
||||
%th{class: 'col-xs-2'}= t(:tech)
|
||||
%th{class: 'col-xs-2'}= t(:nameservers)
|
||||
%th{class: 'col-xs-2'}= t(:registrar)
|
||||
|
||||
%tbody
|
||||
- @domains.each do |domain|
|
||||
- obj = domain.reify
|
||||
%tr
|
||||
%td= link_to(obj.name, admin_domain_version_path(obj))
|
||||
%td= whodunnit_with_protocol(domain.whodunnit) unless domain.whodunnit.nil?
|
||||
%td= l(obj.created_at, format: :short)
|
||||
%tr.small
|
||||
= render 'admin/domain_versions/version',
|
||||
domain: @domain, version: @domain.versions.last
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
= paginate @domains
|
||||
- @domain.versions.not_creates.reverse.each do |version|
|
||||
%tr.small
|
||||
= render 'admin/domain_versions/version',
|
||||
domain: version.reify, version: version.previous
|
||||
|
|
28
app/views/admin/domain_versions/oldindex.haml
Normal file
28
app/views/admin/domain_versions/oldindex.haml
Normal file
|
@ -0,0 +1,28 @@
|
|||
-# .row
|
||||
-# .col-sm-12
|
||||
-# %h2.text-center-xs= t('domains')
|
||||
-# %hr
|
||||
-# .row
|
||||
-# .col-md-12
|
||||
-# .table-responsive
|
||||
-# %table.table.table-hover.table-bordered.table-condensed
|
||||
-# %thead
|
||||
-# %tr
|
||||
-# %th{class: 'col-xs-1'}
|
||||
-# = t('name')
|
||||
-# %th{class: 'col-xs-1'}
|
||||
-# = sort_link(@q, 'whodunnit')
|
||||
-# %th{class: 'col-xs-1'}
|
||||
-# = sort_link(@q, 'created_at')
|
||||
|
||||
-# %tbody
|
||||
-# - @domains.each do |domain|
|
||||
-# - obj = domain.reify
|
||||
-# %tr
|
||||
-# %td= link_to(obj.name, admin_domain_version_path(obj))
|
||||
-# %td= whodunnit_with_protocol(domain.whodunnit) unless domain.whodunnit.nil?
|
||||
-# %td= l(obj.created_at, format: :short)
|
||||
|
||||
-# .row
|
||||
-# .col-md-12
|
||||
-# = paginate @domains
|
|
@ -1,29 +0,0 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h2.text-center-xs
|
||||
= "#{t(:domain_history)} for " + @name.to_s
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
|
||||
%hr
|
||||
.row
|
||||
.col-md-12
|
||||
.table-responsive
|
||||
%table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-2'}= t(:'domain_info')
|
||||
%th{class: 'col-xs-2'}= t(:'owner_contact')
|
||||
%th{class: 'col-xs-2'}= t(:'admin_contacts')
|
||||
%th{class: 'col-xs-2'}= t(:'tech_contacts')
|
||||
%th{class: 'col-xs-2'}= t(:'nameservers')
|
||||
%th{class: 'col-xs-1'}= t(:'changes_info')
|
||||
|
||||
%tbody
|
||||
- @versions.each do |version|
|
||||
%tr
|
||||
- children = version.load_snapshot
|
||||
- next unless children.is_a?(Hash)
|
||||
- children = HashWithIndifferentAccess.new(children)
|
||||
- changes = version.changed_elements
|
||||
= render 'admin/domain_versions/version', children: children, version: version, changes: changes
|
|
@ -4,8 +4,8 @@
|
|||
= "#{t('domain_details')}"
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
= link_to(t('edit_statuses'), edit_admin_domain_path(@domain), class: 'btn btn-primary')
|
||||
= link_to(t(:'history'), admin_domain_version_path(@domain.id), method: :get, class: 'btn btn-primary')
|
||||
= link_to(t(:edit_statuses), edit_admin_domain_path(@domain), class: 'btn btn-primary')
|
||||
= link_to(t(:history), admin_domain_domain_versions_path(@domain.id), method: :get, class: 'btn btn-primary')
|
||||
|
||||
%hr
|
||||
.row
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
.row
|
||||
.col-md-12
|
||||
%hr
|
||||
= paginate @epp_logs
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
%li.dropdown-header= t('system')
|
||||
%li= link_to t('settings'), admin_settings_path
|
||||
%li= link_to t('zonefile'), admin_zonefile_settings_path
|
||||
%li= link_to t(:domains_history), admin_domain_versions_path
|
||||
-# %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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue