Merge branch '115040781-legaldoc_on_delete' into staging

This commit is contained in:
Stas 2016-03-21 15:54:49 +02:00
commit 195c9fc242
2 changed files with 6 additions and 2 deletions

View file

@ -41,7 +41,7 @@ class Epp::ContactsController < EppController
def delete def delete
authorize! :delete, @contact, @password authorize! :delete, @contact, @password
if @contact.destroy_and_clean if @contact.destroy_and_clean(params[:parsed_frame])
render_epp_response '/epp/contacts/delete' render_epp_response '/epp/contacts/delete'
else else
handle_errors(@contact) handle_errors(@contact)

View file

@ -339,11 +339,15 @@ class Contact < ActiveRecord::Base
# TODO: refactor, it should not allow to destroy with normal destroy, # TODO: refactor, it should not allow to destroy with normal destroy,
# no need separate method # no need separate method
# should use only in transaction # should use only in transaction
def destroy_and_clean def destroy_and_clean frame
if domains_present? if domains_present?
errors.add(:domains, :exist) errors.add(:domains, :exist)
return false return false
end 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 destroy
end end