mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 01:35:10 +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
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue