mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 18:29:40 +02:00
Merge pull request #57 from internetee/story/109590460-setting-ident
Story/109590460 setting ident
This commit is contained in:
commit
438b22f19d
2 changed files with 23 additions and 19 deletions
|
@ -236,12 +236,16 @@ class Contact < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def ident_valid_format?
|
def ident_valid_format?
|
||||||
case ident_type
|
case ident_country_code
|
||||||
when 'priv'
|
when 'EE'.freeze
|
||||||
case ident_country_code
|
case ident_type
|
||||||
when 'EE'
|
when 'priv'.freeze
|
||||||
code = Isikukood.new(ident)
|
errors.add(:ident, :invalid_EE_identity_format) unless Isikukood.new(ident).valid?
|
||||||
errors.add(:ident, :invalid_EE_identity_format) unless code.valid?
|
when 'org'.freeze
|
||||||
|
# !%w(1 7 8 9).freeze.include?(ident.first) ||
|
||||||
|
if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/)
|
||||||
|
errors.add(:ident, :invalid_EE_identity_format)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -160,20 +160,20 @@ class Epp::Contact < Contact
|
||||||
self.ident_updated_at ||= Time.zone.now # not in use
|
self.ident_updated_at ||= Time.zone.now # not in use
|
||||||
ident_frame = frame.css('ident').first
|
ident_frame = frame.css('ident').first
|
||||||
|
|
||||||
if ident_frame && ident_attr_valid?(ident_frame) && ident_country_code.blank? && ident_type.in?(%w(org priv).freeze)
|
if ident_frame && ident_attr_valid?(ident_frame)
|
||||||
at.merge!(ident_country_code: ident_frame.attr('cc'))
|
org_priv = %w(org priv).freeze
|
||||||
|
if ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.include?(ident_frame.attr('type'))
|
||||||
|
at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_frame.attr('type'))
|
||||||
|
elsif ident_type == "birthday" && ident !=~ /\d{4}-\d{2}-\d{2}/ && (Date.parse(ident) rescue false)
|
||||||
|
at.merge!(ident: ident_frame.text)
|
||||||
|
at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present?
|
||||||
|
elsif ident_type.blank? && ident_country_code.blank?
|
||||||
|
at.merge!(ident_type: ident_frame.attr('type'))
|
||||||
|
at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present?
|
||||||
|
else
|
||||||
|
throw :epp_error, {code: '2306', msg: I18n.t(:ident_update_error)}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deprecated
|
|
||||||
# if ident_updated_at.present?
|
|
||||||
# throw :epp_error, {
|
|
||||||
# code: '2306',
|
|
||||||
# msg: I18n.t(:ident_update_error)
|
|
||||||
# }
|
|
||||||
# else
|
|
||||||
# at.merge!(self.class.ident_attrs(frame.css('ident').first))
|
|
||||||
# self.ident_updated_at = Time.zone.now
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
super(at)
|
super(at)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue