mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 09:21:43 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
187316078b
8 changed files with 66 additions and 12 deletions
|
@ -41,6 +41,11 @@ module Epp
|
|||
render 'epp/contacts/info'
|
||||
end
|
||||
|
||||
def renew_contact
|
||||
epp_errors << { code: '2101', msg: t(:'errors.messages.unimplemented_command') }
|
||||
handle_errors
|
||||
end
|
||||
|
||||
## HELPER METHODS
|
||||
|
||||
private
|
||||
|
@ -48,14 +53,12 @@ module Epp
|
|||
## CREATE
|
||||
def validate_contact_create_request
|
||||
@ph = params_hash['epp']['command']['create']['create']
|
||||
xml_attrs_present?(@ph, [%w(id),
|
||||
%w(authInfo pw),
|
||||
%w(postalInfo)])
|
||||
xml_attrs_present?(@ph, [%w(id), %w(authInfo pw), %w(postalInfo)])
|
||||
|
||||
return epp_errors.empty? unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array)
|
||||
|
||||
xml_attrs_array_present?(@ph['postalInfo'], [%w(name),
|
||||
%w(addr city),
|
||||
%w(addr cc)])
|
||||
(epp_errors << Address.validate_postal_info_types(parsed_frame)).flatten!
|
||||
xml_attrs_array_present?(@ph['postalInfo'], [%w(name), %w(addr city), %w(addr cc)])
|
||||
end
|
||||
|
||||
## UPDATE
|
||||
|
|
|
@ -14,6 +14,23 @@ class Address < ActiveRecord::Base
|
|||
# validates_inclusion_of :type, in: TYPES
|
||||
|
||||
class << self
|
||||
|
||||
def validate_postal_info_types(parsed_frame)
|
||||
errors, used = [], []
|
||||
|
||||
parsed_frame.css('postalInfo').each do |pi|
|
||||
attr = pi.attributes['type'].try(:value)
|
||||
errors << { code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type')} and next unless attr
|
||||
if !TYPES.include?(attr)
|
||||
errors << { code: 2005, msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr }}
|
||||
next
|
||||
end
|
||||
errors << { code: 2005, msg: I18n.t('errors.messages.repeating_postal_info') } and next if used.include?(attr)
|
||||
used << attr
|
||||
end
|
||||
errors
|
||||
end
|
||||
|
||||
def extract_attributes(ah)
|
||||
address_hash = {}
|
||||
[ah].flatten.each do |pi|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue