Merge branch 'master' of github.com:internetee/registry

This commit is contained in:
Martin Lensment 2014-08-18 13:15:38 +03:00
commit 0c5b7c4cb8
3 changed files with 61 additions and 6 deletions

View file

@ -71,8 +71,32 @@ class Contact < ActiveRecord::Base
return false
end
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
end
#should use only in transaction
def destroy_and_clean
clean_up_address
destroy
rescue
errors.add(:contact, msg: I18n.t('errors.messages.epp_command_failed'), value: { obj: 'contact', val: code })
false
end
class << self
def extract_attributes ph, type=:create
contact_hash = {
@ -107,4 +131,11 @@ class Contact < ActiveRecord::Base
end
end
private
def clean_up_address
address.destroy if address
end
end