diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb index 5b0a39bbf..0a8c8f634 100644 --- a/app/controllers/epp/contacts_controller.rb +++ b/app/controllers/epp/contacts_controller.rb @@ -39,7 +39,7 @@ class Epp::ContactsController < EppController def delete authorize! :delete, @contact, @password - if @contact.destroy_and_clean + if @contact.destroy_and_clean(params[:parsed_frame]) render_epp_response '/epp/contacts/delete' else handle_errors(@contact) diff --git a/app/models/contact.rb b/app/models/contact.rb index 0ddf9ef67..a9ef9ba87 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -330,11 +330,25 @@ class Contact < ActiveRecord::Base # TODO: refactor, it should not allow to destroy with normal destroy, # no need separate method # should use only in transaction - def destroy_and_clean + def destroy_and_clean frame if domains_present? errors.add(:domains, :exist) return false end + + legal_document_data = Epp::Domain.parse_legal_document_from_frame(frame) + + if legal_document_data + + doc = LegalDocument.create( + documentable_type: Contact, + document_type: legal_document_data[:type], + body: legal_document_data[:body] + ) + self.legal_documents = [doc] + self.legal_document_id = doc.id + self.save + end destroy end diff --git a/config/locales/en.yml b/config/locales/en.yml index a807c53e8..6b9a7af3c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -355,6 +355,7 @@ en: contact: 'Contact' credit_balance: 'Credit balance' starting_balance: 'Starting balance' + destroyed: 'Destroyed' domain_transfer_requested: 'Domain transfer requested!' domain_transfer_approved: 'Domain transfer approved!'