mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
Version refactored
This commit is contained in:
parent
c1949e7069
commit
3e2be53853
48 changed files with 379 additions and 147 deletions
|
@ -17,3 +17,6 @@
|
|||
color: #777
|
||||
padding-top: 15px
|
||||
font-size: 10px
|
||||
|
||||
.nowrap
|
||||
white-space: nowrap
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -16,13 +16,23 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def user_for_paper_trail
|
||||
if defined?(current_api_user) && current_api_user.present?
|
||||
"#{current_api_user.id}-api-#{current_api_user.username}"
|
||||
# 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
|
||||
|
|
|
@ -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
|
||||
|
|
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
|
|
@ -5,6 +5,7 @@ module Versions
|
|||
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
|
||||
|
@ -18,5 +19,14 @@ module Versions
|
|||
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,5 +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
|
||||
|
@ -50,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 }
|
||||
|
@ -280,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
|
||||
|
|
|
@ -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 ###
|
||||
|
|
|
@ -16,6 +16,8 @@ class Keyrelay < ActiveRecord::Base
|
|||
|
||||
validate :validate_expiry_relative_xor_expiry_absolute
|
||||
|
||||
after_save :touch_domain_version
|
||||
|
||||
def epp_code_map
|
||||
{
|
||||
'2005' => [
|
||||
|
|
|
@ -8,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,4 +1,5 @@
|
|||
class AddressVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_addresses
|
||||
self.sequence_name = :log_addresses_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class ApiUserVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_api_users
|
||||
self.sequence_name = :log_api_users_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class ContactDisclosureVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_contact_disclosures
|
||||
self.sequence_name = :log_contact_disclosures_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class ContactStatusVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_contact_statuses
|
||||
self.sequence_name = :log_contact_statuses_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class ContactVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_contacts
|
||||
self.sequence_name = :log_contacts_id_seq
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class CountryVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_countries
|
||||
self.sequence_name = :log_countries_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class DnskeyVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_dnskeys
|
||||
self.sequence_name = :log_dnskeys_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class DomainContactVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_domain_contacts
|
||||
self.sequence_name = :log_domain_contacts_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class DomainStatusVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_domain_statuses
|
||||
self.sequence_name = :log_domain_statuses_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class DomainTransferVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_domain_transfers
|
||||
self.sequence_name = :log_domain_transfers_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class DomainVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
|
||||
self.table_name = :log_domains
|
||||
self.sequence_name = :log_domains_id_seq
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class KeyrelayVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_keyrelays
|
||||
self.sequence_name = :log_keyrelays_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class LegalDocumentVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_legal_documents
|
||||
self.sequence_name = :log_legal_documents_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class MessageVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_messages
|
||||
self.sequence_name = :log_messages_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class NameserverVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_nameservers
|
||||
self.sequence_name = :log_nameservers_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class RegistrarVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_registrars
|
||||
self.sequence_name = :log_registrars_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class ReservedDomainVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_reserved_domains
|
||||
self.sequence_name = :log_reserved_domains_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class SettingVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_settings
|
||||
self.sequence_name = :log_settings_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class UserVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_users
|
||||
self.sequence_name = :log_users_id_seq
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class ZonefileSettingVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_zonefile_settings
|
||||
self.sequence_name = :log_zonefile_settings_id_seq
|
||||
end
|
||||
|
|
|
@ -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,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
|
||||
|
|
|
@ -12,3 +12,15 @@ elsif File.basename($PROGRAM_NAME) == "rake"
|
|||
# rake username does not work when spring enabled
|
||||
PaperTrail.whodunnit = "rake-#{`whoami`.strip} #{ARGV.join ' '}"
|
||||
end
|
||||
|
||||
class PaperSession
|
||||
class << self
|
||||
def session
|
||||
@session ||= Time.now.to_s(:db)
|
||||
end
|
||||
|
||||
def session=(code)
|
||||
@session = code
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,11 @@ Rails.application.routes.draw do
|
|||
resources :legal_documents
|
||||
|
||||
resources :keyrelays
|
||||
resources :domains
|
||||
|
||||
resources :domains do
|
||||
resources :domain_versions
|
||||
end
|
||||
|
||||
resources :settings
|
||||
resources :registrars do
|
||||
collection do
|
||||
|
@ -43,7 +47,6 @@ Rails.application.routes.draw do
|
|||
|
||||
resources :users
|
||||
resources :api_users
|
||||
resources :domain_versions
|
||||
|
||||
resources :delayed_jobs
|
||||
|
||||
|
|
5
db/migrate/20150130155904_add_name_server_version_ids.rb
Normal file
5
db/migrate/20150130155904_add_name_server_version_ids.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddNameServerVersionIds < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :log_domains, :nameserver_version_ids, :text, array: true, default: []
|
||||
end
|
||||
end
|
7
db/migrate/20150130180452_add_meta_to_domain.rb
Normal file
7
db/migrate/20150130180452_add_meta_to_domain.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class AddMetaToDomain < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :log_domains, :nameserver_version_ids, :nameserver_ids
|
||||
add_column :log_domains, :tech_contact_ids, :text, array: true, default: []
|
||||
add_column :log_domains, :admin_contact_ids, :text, array: true, default: []
|
||||
end
|
||||
end
|
13
db/migrate/20150130191056_add_session_id_to_log.rb
Normal file
13
db/migrate/20150130191056_add_session_id_to_log.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class AddSessionIdToLog < ActiveRecord::Migration
|
||||
def change
|
||||
%w(address contact_disclosure contact contact_status country dnskey
|
||||
domain_contact domain domain_status domain_transfer api_user keyrelay
|
||||
legal_document message nameserver registrar
|
||||
reserved_domain setting user zonefile_setting
|
||||
).each do |name|
|
||||
table_name = name.tableize
|
||||
add_column "log_#{table_name}", :session, :string
|
||||
add_column "log_#{table_name}", :children, :json
|
||||
end
|
||||
end
|
||||
end
|
51
db/schema.rb
51
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150129144652) do
|
||||
ActiveRecord::Schema.define(version: 20150130191056) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -260,6 +260,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_addresses", ["item_type", "item_id"], name: "index_log_addresses_on_item_type_and_item_id", using: :btree
|
||||
|
@ -273,6 +275,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_api_users", ["item_type", "item_id"], name: "index_log_api_users_on_item_type_and_item_id", using: :btree
|
||||
|
@ -286,6 +290,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_contact_disclosures", ["item_type", "item_id"], name: "index_log_contact_disclosures_on_item_type_and_item_id", using: :btree
|
||||
|
@ -299,6 +305,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_contact_statuses", ["item_type", "item_id"], name: "index_log_contact_statuses_on_item_type_and_item_id", using: :btree
|
||||
|
@ -312,6 +320,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_contacts", ["item_type", "item_id"], name: "index_log_contacts_on_item_type_and_item_id", using: :btree
|
||||
|
@ -325,6 +335,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_countries", ["item_type", "item_id"], name: "index_log_countries_on_item_type_and_item_id", using: :btree
|
||||
|
@ -338,6 +350,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_dnskeys", ["item_type", "item_id"], name: "index_log_dnskeys_on_item_type_and_item_id", using: :btree
|
||||
|
@ -351,6 +365,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_domain_contacts", ["item_type", "item_id"], name: "index_log_domain_contacts_on_item_type_and_item_id", using: :btree
|
||||
|
@ -364,6 +380,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_domain_statuses", ["item_type", "item_id"], name: "index_log_domain_statuses_on_item_type_and_item_id", using: :btree
|
||||
|
@ -377,19 +395,26 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_domain_transfers", ["item_type", "item_id"], name: "index_log_domain_transfers_on_item_type_and_item_id", using: :btree
|
||||
add_index "log_domain_transfers", ["whodunnit"], name: "index_log_domain_transfers_on_whodunnit", using: :btree
|
||||
|
||||
create_table "log_domains", force: :cascade do |t|
|
||||
t.string "item_type", null: false
|
||||
t.integer "item_id", null: false
|
||||
t.string "event", null: false
|
||||
t.string "item_type", null: false
|
||||
t.integer "item_id", null: false
|
||||
t.string "event", null: false
|
||||
t.string "whodunnit"
|
||||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.text "nameserver_ids", default: [], array: true
|
||||
t.text "tech_contact_ids", default: [], array: true
|
||||
t.text "admin_contact_ids", default: [], array: true
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_domains", ["item_type", "item_id"], name: "index_log_domains_on_item_type_and_item_id", using: :btree
|
||||
|
@ -403,6 +428,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_keyrelays", ["item_type", "item_id"], name: "index_log_keyrelays_on_item_type_and_item_id", using: :btree
|
||||
|
@ -416,6 +443,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_legal_documents", ["item_type", "item_id"], name: "index_log_legal_documents_on_item_type_and_item_id", using: :btree
|
||||
|
@ -429,6 +458,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_messages", ["item_type", "item_id"], name: "index_log_messages_on_item_type_and_item_id", using: :btree
|
||||
|
@ -442,6 +473,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_nameservers", ["item_type", "item_id"], name: "index_log_nameservers_on_item_type_and_item_id", using: :btree
|
||||
|
@ -455,6 +488,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_registrars", ["item_type", "item_id"], name: "index_log_registrars_on_item_type_and_item_id", using: :btree
|
||||
|
@ -468,6 +503,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_reserved_domains", ["item_type", "item_id"], name: "index_log_reserved_domains_on_item_type_and_item_id", using: :btree
|
||||
|
@ -481,6 +518,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_settings", ["item_type", "item_id"], name: "index_log_settings_on_item_type_and_item_id", using: :btree
|
||||
|
@ -494,6 +533,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_users", ["item_type", "item_id"], name: "index_log_users_on_item_type_and_item_id", using: :btree
|
||||
|
@ -507,6 +548,8 @@ ActiveRecord::Schema.define(version: 20150129144652) do
|
|||
t.json "object"
|
||||
t.json "object_changes"
|
||||
t.datetime "created_at"
|
||||
t.string "session"
|
||||
t.json "children"
|
||||
end
|
||||
|
||||
add_index "log_zonefile_settings", ["item_type", "item_id"], name: "index_log_zonefile_settings_on_item_type_and_item_id", using: :btree
|
||||
|
|
|
@ -77,7 +77,7 @@ describe 'EPP Contact', epp: true do
|
|||
log.request_command.should == 'create'
|
||||
log.request_object.should == 'contact'
|
||||
log.request_successful.should == true
|
||||
log.api_user_name.should == 'gitlab'
|
||||
log.api_user_name.should == '1-api-gitlab'
|
||||
log.api_user_registrar.should == 'Registrar OÜ'
|
||||
end
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ describe 'EPP Domain', epp: true do
|
|||
log.request_command.should == 'create'
|
||||
log.request_object.should == 'domain'
|
||||
log.request_successful.should == false
|
||||
log.api_user_name.should == 'registrar1'
|
||||
log.api_user_name.should == '1-api-registrar1'
|
||||
log.api_user_registrar.should == 'Registrar OÜ'
|
||||
log.request.should_not be_blank
|
||||
log.response.should_not be_blank
|
||||
|
@ -819,7 +819,7 @@ describe 'EPP Domain', epp: true do
|
|||
log.request_command.should == 'transfer'
|
||||
log.request_object.should == 'domain'
|
||||
log.request_successful.should == true
|
||||
log.api_user_name.should == 'registrar2'
|
||||
log.api_user_name.should == '2-api-registrar2'
|
||||
log.api_user_registrar.should == 'registrar2'
|
||||
log.request.should_not be_blank
|
||||
log.response.should_not be_blank
|
||||
|
|
|
@ -33,7 +33,7 @@ describe 'EPP Poll', epp: true do
|
|||
log.request_command.should == 'poll'
|
||||
log.request_object.should == 'poll'
|
||||
log.request_successful.should == true
|
||||
log.api_user_name.should == 'registrar1'
|
||||
log.api_user_name.should == '1-api-registrar1'
|
||||
log.api_user_registrar.should == 'Registrar OÜ'
|
||||
log.request.should_not be_blank
|
||||
log.response.should_not be_blank
|
||||
|
|
|
@ -66,7 +66,7 @@ describe 'EPP Session', epp: true do
|
|||
log = ApiLog::EppLog.last
|
||||
log.request_command.should == 'login'
|
||||
log.request_successful.should == false
|
||||
log.api_user_name.should == 'gitlab'
|
||||
log.api_user_name.should == '1-api-gitlab'
|
||||
log.api_user_registrar.should == 'Registrar OÜ'
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Fabricator(:epp_session) do
|
||||
session_id 'test'
|
||||
data { { epp_user_id: 1 } }
|
||||
data { { api_user_id: 1 } }
|
||||
end
|
||||
|
|
|
@ -27,8 +27,8 @@ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
|||
ActiveRecord::Migration.maintain_test_schema!
|
||||
|
||||
RSpec.configure do |config|
|
||||
# config.filter_run focus: true
|
||||
# config.run_all_when_everything_filtered = true
|
||||
config.filter_run focus: true
|
||||
config.run_all_when_everything_filtered = true
|
||||
|
||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue