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
|
||||
|
||||
def ident_valid_format?
|
||||
case ident_type
|
||||
when 'priv'
|
||||
case ident_country_code
|
||||
when 'EE'
|
||||
code = Isikukood.new(ident)
|
||||
errors.add(:ident, :invalid_EE_identity_format) unless code.valid?
|
||||
case ident_country_code
|
||||
when 'EE'.freeze
|
||||
case ident_type
|
||||
when 'priv'.freeze
|
||||
errors.add(:ident, :invalid_EE_identity_format) unless Isikukood.new(ident).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
|
||||
|
|
|
@ -160,20 +160,20 @@ class Epp::Contact < Contact
|
|||
self.ident_updated_at ||= Time.zone.now # not in use
|
||||
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)
|
||||
at.merge!(ident_country_code: ident_frame.attr('cc'))
|
||||
if ident_frame && ident_attr_valid?(ident_frame)
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
super(at)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue