mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +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
|
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)
|
||||||
|
|
|
@ -330,11 +330,25 @@ 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
|
||||||
|
|
||||||
|
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
|
destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -355,6 +355,7 @@ en:
|
||||||
contact: 'Contact'
|
contact: 'Contact'
|
||||||
credit_balance: 'Credit balance'
|
credit_balance: 'Credit balance'
|
||||||
starting_balance: 'Starting balance'
|
starting_balance: 'Starting balance'
|
||||||
|
destroyed: 'Destroyed'
|
||||||
|
|
||||||
domain_transfer_requested: 'Domain transfer requested!'
|
domain_transfer_requested: 'Domain transfer requested!'
|
||||||
domain_transfer_approved: 'Domain transfer approved!'
|
domain_transfer_approved: 'Domain transfer approved!'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue