From 431eaf54392dead044fe33c8a624818f43a7fcfc Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 17 Mar 2016 18:32:55 +0200 Subject: [PATCH 1/3] 1150040781-contact_delete_legal_doc --- app/controllers/epp/contacts_controller.rb | 2 +- app/models/contact.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 9b4902e0b..d01bac152 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -330,11 +330,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 From 4e51adb08e2f5b02d75ce992ebdbe56a341cec79 Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 24 Mar 2016 12:01:10 +0200 Subject: [PATCH 2/3] 115040781-legal_doc_check_and_save --- app/models/contact.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index d01bac152..3d4ca419c 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -335,9 +335,19 @@ class Contact < ActiveRecord::Base 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 + + 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 From 0e35641702c542050ef97122a960ae8677a56994 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 29 Mar 2016 12:56:23 +0300 Subject: [PATCH 3/3] 115040781-translation_added --- config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 27495c382..30418d17a 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!'