mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Contact refactor to new epp errors
This commit is contained in:
parent
6b86af3048
commit
55decf3dd4
5 changed files with 29 additions and 19 deletions
|
@ -5,8 +5,7 @@ module Epp::ContactsHelper
|
||||||
if @contact.save
|
if @contact.save
|
||||||
render '/epp/contacts/create'
|
render '/epp/contacts/create'
|
||||||
else
|
else
|
||||||
handle_contact_errors
|
handle_errors(@contact)
|
||||||
render '/epp/error'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,8 +15,7 @@ module Epp::ContactsHelper
|
||||||
if @contact.update_attributes(contact_and_address_attributes.delete_if { |k, v| v.nil? })
|
if @contact.update_attributes(contact_and_address_attributes.delete_if { |k, v| v.nil? })
|
||||||
render 'epp/contacts/update'
|
render 'epp/contacts/update'
|
||||||
else
|
else
|
||||||
handle_contact_errors
|
handle_errors(@contact)
|
||||||
render '/epp/error'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,6 @@
|
||||||
module EppErrors
|
module EppErrors
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
EPP_CODE_MAP = {
|
|
||||||
'2302' => ['Domain name already exists', 'Domain name is reserved or restricted'],
|
|
||||||
'2306' => ['Registrant is missing', 'Nameservers count must be between 1-13', 'Admin contact is missing'],
|
|
||||||
'2303' => ['Contact was not found'],
|
|
||||||
'2005' => ['Hostname is invalid', 'IP is invalid']
|
|
||||||
}
|
|
||||||
|
|
||||||
EPP_OBJ_MAP = {
|
|
||||||
hostname: 'ns',
|
|
||||||
name_dirty: 'domain'
|
|
||||||
}
|
|
||||||
|
|
||||||
def construct_epp_errors
|
def construct_epp_errors
|
||||||
epp_errors = []
|
epp_errors = []
|
||||||
errors.messages.each do |key, values|
|
errors.messages.each do |key, values|
|
||||||
|
@ -38,7 +26,7 @@ module EppErrors
|
||||||
else
|
else
|
||||||
next unless code = find_epp_code(err)
|
next unless code = find_epp_code(err)
|
||||||
err = {code: code, msg: err}
|
err = {code: code, msg: err}
|
||||||
err[:value] = {val: send(key), obj: EPP_OBJ_MAP[key]} unless self.class.reflect_on_association(key)
|
err[:value] = {val: send(key), obj: self.class::EPP_OBJ} unless self.class.reflect_on_association(key)
|
||||||
epp_errors << err
|
epp_errors << err
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -61,7 +49,7 @@ module EppErrors
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_epp_code(msg)
|
def find_epp_code(msg)
|
||||||
EPP_CODE_MAP.each do |code, values|
|
self.class::EPP_CODE_MAP.each do |code, values|
|
||||||
return code if values.include?(msg)
|
return code if values.include?(msg)
|
||||||
end
|
end
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -2,6 +2,16 @@ class Contact < ActiveRecord::Base
|
||||||
#TODO Foreign contact will get email with activation link/username/temp password
|
#TODO Foreign contact will get email with activation link/username/temp password
|
||||||
#TODO Phone number validation, in first phase very minimam in order to support current registries
|
#TODO Phone number validation, in first phase very minimam in order to support current registries
|
||||||
|
|
||||||
|
include EppErrors
|
||||||
|
|
||||||
|
EPP_CODE_MAP = {
|
||||||
|
'2302' => ['Contact id already exists'],
|
||||||
|
'2303' => [:not_found, :epp_obj_does_not_exist],
|
||||||
|
'2005' => ['Phone nr is invalid', 'Email is invalid']
|
||||||
|
}
|
||||||
|
|
||||||
|
EPP_OBJ = 'contact'
|
||||||
|
|
||||||
has_one :address
|
has_one :address
|
||||||
has_many :domain_contacts
|
has_many :domain_contacts
|
||||||
has_many :domains, through: :domain_contacts
|
has_many :domains, through: :domain_contacts
|
||||||
|
|
|
@ -4,6 +4,14 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
include EppErrors
|
include EppErrors
|
||||||
|
|
||||||
|
EPP_CODE_MAP = {
|
||||||
|
'2302' => ['Domain name already exists', 'Domain name is reserved or restricted'],
|
||||||
|
'2306' => ['Registrant is missing', 'Nameservers count must be between 1-13', 'Admin contact is missing'],
|
||||||
|
'2303' => ['Contact was not found']
|
||||||
|
}
|
||||||
|
|
||||||
|
EPP_OBJ = 'domain'
|
||||||
|
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
belongs_to :owner_contact, class_name: 'Contact'
|
belongs_to :owner_contact, class_name: 'Contact'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
class Nameserver < ActiveRecord::Base
|
class Nameserver < ActiveRecord::Base
|
||||||
include EppErrors
|
include EppErrors
|
||||||
|
|
||||||
|
EPP_CODE_MAP = {
|
||||||
|
'2005' => ['Hostname is invalid', 'IP is invalid']
|
||||||
|
}
|
||||||
|
|
||||||
|
EPP_OBJ = 'ns'
|
||||||
|
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
has_and_belongs_to_many :domains
|
has_and_belongs_to_many :domains
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue