mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Merge pull request #2263 from internetee/834-fix-domain-history-records
Fix domain status history view
This commit is contained in:
commit
57bd4afb85
6 changed files with 53 additions and 28 deletions
|
@ -64,19 +64,19 @@ module Versions
|
|||
|
||||
module ClassMethods
|
||||
def all_versions_for(ids, time)
|
||||
ver_klass = paper_trail.version_class
|
||||
from_history = ver_klass.where(item_id: ids.to_a).
|
||||
order(:item_id).
|
||||
preceding(time + 1, true).
|
||||
select("distinct on (item_id) #{ver_klass.table_name}.*").
|
||||
map do |ver|
|
||||
valid_columns = ver.item_type.constantize&.column_names
|
||||
o = new(ver.object&.slice(*valid_columns))
|
||||
o.version_loader = ver
|
||||
changes = ver.object_changes.to_h&.slice(*valid_columns)
|
||||
changes.each { |k, v| o.public_send("#{k}=", v[-1]) }
|
||||
o
|
||||
end
|
||||
ver_klass = paper_trail.version_class
|
||||
from_history = ver_klass.where(item_id: ids.to_a)
|
||||
.order(:item_id)
|
||||
.preceding(time + 1, true)
|
||||
.select("distinct on (item_id) #{ver_klass.table_name}.*")
|
||||
.map do |ver|
|
||||
valid_columns = ver.item_type.constantize&.column_names
|
||||
o = new(ver.object&.slice(*valid_columns))
|
||||
o.version_loader = ver
|
||||
changes = ver.object_changes.to_h&.slice(*valid_columns)
|
||||
changes.each { |k, v| o.public_send("#{k}=", v[-1]) }
|
||||
o
|
||||
end
|
||||
not_in_history = where(id: (ids.to_a - from_history.map(&:id)))
|
||||
|
||||
from_history + not_in_history
|
||||
|
|
|
@ -469,6 +469,7 @@ class Domain < ApplicationRecord
|
|||
return false unless pending_update?
|
||||
return false unless registrant_verification_asked?
|
||||
return false unless registrant_verification_token == token
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -476,6 +477,7 @@ class Domain < ApplicationRecord
|
|||
return false unless pending_delete?
|
||||
return false unless registrant_verification_asked?
|
||||
return false unless registrant_verification_token == token
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -492,10 +494,12 @@ class Domain < ApplicationRecord
|
|||
|
||||
def pending_delete!
|
||||
return true if pending_delete?
|
||||
|
||||
self.epp_pending_delete = true # for epp
|
||||
|
||||
# TODO: if this were to ever return true, that would be wrong. EPP would report sucess pending
|
||||
return true unless registrant_verification_asked?
|
||||
|
||||
pending_delete_confirmation!
|
||||
save(validate: false) # should check if this did succeed
|
||||
|
||||
|
@ -560,6 +564,7 @@ class Domain < ApplicationRecord
|
|||
def pending_registrant
|
||||
return '' if pending_json.blank?
|
||||
return '' if pending_json['new_registrant_id'].blank?
|
||||
|
||||
Registrant.find_by(id: pending_json['new_registrant_id'])
|
||||
end
|
||||
|
||||
|
@ -590,10 +595,13 @@ class Domain < ApplicationRecord
|
|||
|
||||
# special handling for admin changing status
|
||||
def admin_status_update(update)
|
||||
update_unless_locked_by_registrant(update)
|
||||
update_not_by_locked_statuses(update)
|
||||
return unless update
|
||||
|
||||
PaperTrail.request(enabled: false) do
|
||||
update_unless_locked_by_registrant(update)
|
||||
update_not_by_locked_statuses(update)
|
||||
end
|
||||
|
||||
# check for deleted status
|
||||
statuses.each do |s|
|
||||
unless update.include? s
|
||||
|
@ -658,7 +666,7 @@ class Domain < ApplicationRecord
|
|||
end
|
||||
|
||||
def manage_automatic_statuses
|
||||
if !self.class.nameserver_required?
|
||||
unless self.class.nameserver_required?
|
||||
deactivate if nameservers.reject(&:marked_for_destruction?).empty?
|
||||
activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count
|
||||
end
|
||||
|
@ -679,11 +687,11 @@ class Domain < ApplicationRecord
|
|||
def children_log
|
||||
log = HashWithIndifferentAccess.new
|
||||
log[:admin_contacts] = admin_contact_ids
|
||||
log[:tech_contacts] = tech_contact_ids
|
||||
log[:nameservers] = nameserver_ids
|
||||
log[:dnskeys] = dnskey_ids
|
||||
log[:legal_documents]= [legal_document_id]
|
||||
log[:registrant] = [registrant_id]
|
||||
log[:tech_contacts] = tech_contact_ids
|
||||
log[:nameservers] = nameserver_ids
|
||||
log[:dnskeys] = dnskey_ids
|
||||
log[:legal_documents] = [legal_document_id]
|
||||
log[:registrant] = [registrant_id]
|
||||
log
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue