mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 08:43:37 +02:00
Merge branch '105839906-reduce-history-of-db-objects' into staging
This commit is contained in:
commit
b93cdc29bf
4 changed files with 31 additions and 19 deletions
|
@ -424,7 +424,6 @@ class Domain < ActiveRecord::Base
|
||||||
pending_json_cache = pending_json
|
pending_json_cache = pending_json
|
||||||
token = registrant_verification_token
|
token = registrant_verification_token
|
||||||
asked_at = registrant_verification_asked_at
|
asked_at = registrant_verification_asked_at
|
||||||
changes_cache = changes
|
|
||||||
new_registrant_id = registrant.id
|
new_registrant_id = registrant.id
|
||||||
new_registrant_email = registrant.email
|
new_registrant_email = registrant.email
|
||||||
new_registrant_name = registrant.name
|
new_registrant_name = registrant.name
|
||||||
|
@ -438,7 +437,6 @@ class Domain < ActiveRecord::Base
|
||||||
self.registrant_verification_token = token
|
self.registrant_verification_token = token
|
||||||
self.registrant_verification_asked_at = asked_at
|
self.registrant_verification_asked_at = asked_at
|
||||||
set_pending_update
|
set_pending_update
|
||||||
pending_json['domain'] = changes_cache
|
|
||||||
pending_json['new_registrant_id'] = new_registrant_id
|
pending_json['new_registrant_id'] = new_registrant_id
|
||||||
pending_json['new_registrant_email'] = new_registrant_email
|
pending_json['new_registrant_email'] = new_registrant_email
|
||||||
pending_json['new_registrant_name'] = new_registrant_name
|
pending_json['new_registrant_name'] = new_registrant_name
|
||||||
|
@ -564,8 +562,8 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def pending_registrant
|
def pending_registrant
|
||||||
return '' if pending_json.blank?
|
return '' if pending_json.blank?
|
||||||
return '' if pending_json['domain']['registrant_id'].blank?
|
return '' if pending_json['new_registrant_id'].blank?
|
||||||
Registrant.find_by(id: pending_json['domain']['registrant_id'].last)
|
Registrant.find_by(id: pending_json['new_registrant_id'].last)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_auth_info
|
def generate_auth_info
|
||||||
|
@ -757,11 +755,11 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def children_log
|
def children_log
|
||||||
log = HashWithIndifferentAccess.new
|
log = HashWithIndifferentAccess.new
|
||||||
log[:admin_contacts] = admin_contacts.map(&:attributes)
|
log[:admin_contacts] = admin_contact_ids
|
||||||
log[:tech_contacts] = tech_contacts.map(&:attributes)
|
log[:tech_contacts] = tech_contact_ids
|
||||||
log[:nameservers] = nameservers.map(&:attributes)
|
log[:nameservers] = nameserver_ids
|
||||||
log[:registrant] = [registrant.try(:attributes)]
|
log[:registrant] = [registrant_id]
|
||||||
log[:domain_statuses] = domain_statuses.map(&:attributes)
|
log[:domain_statuses] = domain_status_ids
|
||||||
log
|
log
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
class LegalDocument < ActiveRecord::Base
|
class LegalDocument < ActiveRecord::Base
|
||||||
include Versions # version/legal_document_version.rb
|
|
||||||
belongs_to :documentable, polymorphic: true
|
|
||||||
|
|
||||||
if ENV['legal_document_types'].present?
|
if ENV['legal_document_types'].present?
|
||||||
TYPES = ENV['legal_document_types'].split(',').map(&:strip)
|
TYPES = ENV['legal_document_types'].split(',').map(&:strip)
|
||||||
else
|
else
|
||||||
TYPES = %w(pdf bdoc ddoc zip rar gz tar 7z odt doc docx)
|
TYPES = %w(pdf bdoc ddoc zip rar gz tar 7z odt doc docx).freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :body
|
attr_accessor :body
|
||||||
|
|
||||||
before_save :save_to_filesystem
|
belongs_to :documentable, polymorphic: true
|
||||||
|
|
||||||
|
before_create :add_creator
|
||||||
|
before_save :save_to_filesystem
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def save_to_filesystem
|
def save_to_filesystem
|
||||||
loop do
|
loop do
|
||||||
rand = SecureRandom.random_number.to_s.last(4)
|
rand = SecureRandom.random_number.to_s.last(4)
|
||||||
|
@ -25,4 +28,9 @@ class LegalDocument < ActiveRecord::Base
|
||||||
File.open(path, 'wb') { |f| f.write(Base64.decode64(body)) } unless Rails.env.test?
|
File.open(path, 'wb') { |f| f.write(Base64.decode64(body)) } unless Rails.env.test?
|
||||||
self.path = path
|
self.path = path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_creator
|
||||||
|
self.creator_str = ::PaperTrail.whodunnit
|
||||||
|
true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
class LegalDocumentVersion < PaperTrail::Version
|
|
||||||
include VersionSession
|
|
||||||
self.table_name = :log_legal_documents
|
|
||||||
self.sequence_name = :log_legal_documents_id_seq
|
|
||||||
end
|
|
11
db/migrate/20151117081204_drop_log_legal_documents.rb
Normal file
11
db/migrate/20151117081204_drop_log_legal_documents.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class DropLogLegalDocuments < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
drop_table :log_legal_documents
|
||||||
|
remove_column :legal_documents, :updated_at
|
||||||
|
remove_column :legal_documents, :updator_str
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
# we don't want it back
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue