new contact honors new format

This commit is contained in:
Priit Tark 2015-05-05 18:38:54 +03:00
parent ede71f8e61
commit 3fb9664e5b
9 changed files with 133 additions and 113 deletions

View file

@ -51,20 +51,9 @@ class Epp::Contact < Contact
def new(frame, registrar)
return super if frame.blank?
custom_code = frame.css('id').text
# add prefix when needed
if custom_code.present?
custom_code.sub!(/^CID:/, '')
prefix = custom_code.split(':').first
custom_code = "#{registrar.code}:#{custom_code}" if prefix != registrar.code
custom_code = nil if custom_code == registrar.code
custom_code.upcase! if custom_code.present?
end
super(
attrs_from(frame).merge(
code: custom_code,
code: frame.css('id').text,
registrar: registrar
)
)

View file

@ -448,9 +448,8 @@ class Epp::Domain < Domain
def transfer_contact(contact_id, registrar_id)
oc = Contact.find(contact_id) # n+1 workaround
oc.code_overwrite_allowed = true
oc.generate_code
oc.registrar_id = registrar_id
oc.generate_new_code!
oc.save!
oc
end