diff --git a/app/models/domain.rb b/app/models/domain.rb index 3356e2a77..9845e8ac8 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -424,7 +424,6 @@ class Domain < ActiveRecord::Base pending_json_cache = pending_json token = registrant_verification_token asked_at = registrant_verification_asked_at - changes_cache = changes new_registrant_id = registrant.id new_registrant_email = registrant.email new_registrant_name = registrant.name @@ -438,7 +437,6 @@ class Domain < ActiveRecord::Base self.registrant_verification_token = token self.registrant_verification_asked_at = asked_at set_pending_update - pending_json['domain'] = changes_cache pending_json['new_registrant_id'] = new_registrant_id pending_json['new_registrant_email'] = new_registrant_email pending_json['new_registrant_name'] = new_registrant_name @@ -564,8 +562,8 @@ class Domain < ActiveRecord::Base def pending_registrant return '' if pending_json.blank? - return '' if pending_json['domain']['registrant_id'].blank? - Registrant.find_by(id: pending_json['domain']['registrant_id'].last) + return '' if pending_json['new_registrant_id'].blank? + Registrant.find_by(id: pending_json['new_registrant_id'].last) end def generate_auth_info @@ -757,11 +755,11 @@ class Domain < ActiveRecord::Base def children_log log = HashWithIndifferentAccess.new - log[:admin_contacts] = admin_contacts.map(&:attributes) - log[:tech_contacts] = tech_contacts.map(&:attributes) - log[:nameservers] = nameservers.map(&:attributes) - log[:registrant] = [registrant.try(:attributes)] - log[:domain_statuses] = domain_statuses.map(&:attributes) + log[:admin_contacts] = admin_contact_ids + log[:tech_contacts] = tech_contact_ids + log[:nameservers] = nameserver_ids + log[:registrant] = [registrant_id] + log[:domain_statuses] = domain_status_ids log end diff --git a/app/models/legal_document.rb b/app/models/legal_document.rb index f1a63e976..f9d4cb4eb 100644 --- a/app/models/legal_document.rb +++ b/app/models/legal_document.rb @@ -1,16 +1,19 @@ class LegalDocument < ActiveRecord::Base - include Versions # version/legal_document_version.rb - belongs_to :documentable, polymorphic: true - if ENV['legal_document_types'].present? TYPES = ENV['legal_document_types'].split(',').map(&:strip) 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 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 loop do 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? self.path = path end + + def add_creator + self.creator_str = ::PaperTrail.whodunnit + true + end end diff --git a/app/models/version/legal_document_version.rb b/app/models/version/legal_document_version.rb deleted file mode 100644 index d812b9720..000000000 --- a/app/models/version/legal_document_version.rb +++ /dev/null @@ -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 diff --git a/db/migrate/20151117081204_drop_log_legal_documents.rb b/db/migrate/20151117081204_drop_log_legal_documents.rb new file mode 100644 index 000000000..2746a5d11 --- /dev/null +++ b/db/migrate/20151117081204_drop_log_legal_documents.rb @@ -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