mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Removed ridiculous has/get_relation from contact
This commit is contained in:
parent
3c79ca33b8
commit
6d15739f8a
2 changed files with 19 additions and 35 deletions
|
@ -70,25 +70,16 @@ class Contact < ActiveRecord::Base
|
|||
Domain.find_by(owner_contact_id: id)
|
||||
end
|
||||
|
||||
#TODO Refactor the relation methods to something more sensible
|
||||
def get_relation( model = :domain_contacts )
|
||||
send(model)
|
||||
rescue NoMethodError => e
|
||||
nil
|
||||
end
|
||||
|
||||
def has_relation( model = :domain_contacts )
|
||||
relation = get_relation(model)
|
||||
return true unless relation.nil? || relation.blank?
|
||||
false
|
||||
def relations_with_domain?
|
||||
return true if domain_contacts.present? || domains_owned.present?
|
||||
return false
|
||||
end
|
||||
|
||||
#should use only in transaction
|
||||
def destroy_and_clean
|
||||
clean_up_address
|
||||
|
||||
if has_relation(:domain_contacts) || domains_owned.present?
|
||||
#errors.add(:contact, msg: I18n.t('errors.messages.epp_obj_association_error'), value: { obj: 'contact', val: code })
|
||||
if relations_with_domain?
|
||||
errors.add(:domains, :exist)
|
||||
return false
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue