diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb index b9af62d7a..117aaabc0 100644 --- a/app/controllers/epp/contacts_controller.rb +++ b/app/controllers/epp/contacts_controller.rb @@ -41,7 +41,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 3f2897bf9..614d7d1f9 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -339,11 +339,15 @@ 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 + if doc = Epp::Contact.attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame)) + frame.css("legalDocument").first.content = doc.path if doc && doc.persisted? + self.legal_document_id = doc.id + end destroy end