mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 18:26:06 +02:00
Merge pull request #110 from internetee/115040781-legaldoc_on_delete
115040781 legaldoc on delete
This commit is contained in:
commit
798b5739e0
3 changed files with 17 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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!'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue