mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 21:54:48 +02:00
author Karl Erik Õunapuu <karlerik@kreative.ee> 1591359032 +0300 committer Alex Sherman <yul.golem@gmail.com> 1617029320 +0500 CsyncJob: Don't respect IPv6 if nessecary
46 lines
912 B
Ruby
46 lines
912 B
Ruby
module Actions
|
|
class ContactDelete
|
|
attr_reader :contact
|
|
attr_reader :new_attributes
|
|
attr_reader :legal_document
|
|
attr_reader :ident
|
|
attr_reader :user
|
|
|
|
def initialize(contact, legal_document = nil)
|
|
@legal_document = legal_document
|
|
@contact = contact
|
|
end
|
|
|
|
def call
|
|
maybe_attach_legal_doc
|
|
|
|
if contact.linked?
|
|
contact.errors.add(:domains, :exist)
|
|
return
|
|
end
|
|
|
|
if contact.delete_prohibited?
|
|
contact.errors.add(:statuses, :delete_prohibited)
|
|
return
|
|
end
|
|
|
|
commit
|
|
end
|
|
|
|
def maybe_attach_legal_doc
|
|
return unless legal_document
|
|
|
|
document = contact.legal_documents.create(
|
|
document_type: legal_document[:type],
|
|
body: legal_document[:body]
|
|
)
|
|
|
|
contact.legal_document_id = document.id
|
|
contact.save
|
|
end
|
|
|
|
def commit
|
|
contact.destroy
|
|
end
|
|
end
|
|
end
|