mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Merge pull request #72 from internetee/story/109590460-ident-update
Story/109590460 ident update
This commit is contained in:
commit
d38d2eeb6f
3 changed files with 8 additions and 5 deletions
|
@ -29,7 +29,7 @@ class Contact < ActiveRecord::Base
|
||||||
uniqueness: { message: :epp_id_taken },
|
uniqueness: { message: :epp_id_taken },
|
||||||
format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid },
|
format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid },
|
||||||
length: { maximum: 100, message: :too_long_contact_code }
|
length: { maximum: 100, message: :too_long_contact_code }
|
||||||
validate :ident_valid_format?
|
validate :val_ident_valid_format?
|
||||||
validate :uniq_statuses?
|
validate :uniq_statuses?
|
||||||
validate :validate_html
|
validate :validate_html
|
||||||
|
|
||||||
|
@ -235,16 +235,17 @@ class Contact < ActiveRecord::Base
|
||||||
name || '[no name]'
|
name || '[no name]'
|
||||||
end
|
end
|
||||||
|
|
||||||
def ident_valid_format?
|
def val_ident_valid_format?
|
||||||
case ident_country_code
|
case ident_country_code
|
||||||
when 'EE'.freeze
|
when 'EE'.freeze
|
||||||
|
err_msg = "invalid_EE_identity_format#{"_update" if id}".to_sym
|
||||||
case ident_type
|
case ident_type
|
||||||
when 'priv'.freeze
|
when 'priv'.freeze
|
||||||
errors.add(:ident, :invalid_EE_identity_format) unless Isikukood.new(ident).valid?
|
errors.add(:ident, err_msg) unless Isikukood.new(ident).valid?
|
||||||
when 'org'.freeze
|
when 'org'.freeze
|
||||||
# !%w(1 7 8 9).freeze.include?(ident.first) ||
|
# !%w(1 7 8 9).freeze.include?(ident.first) ||
|
||||||
if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/)
|
if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/)
|
||||||
errors.add(:ident, :invalid_EE_identity_format)
|
errors.add(:ident, err_msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -123,6 +123,7 @@ class Epp::Contact < Contact
|
||||||
[:email, :invalid],
|
[:email, :invalid],
|
||||||
[:ident, :invalid],
|
[:ident, :invalid],
|
||||||
[:ident, :invalid_EE_identity_format],
|
[:ident, :invalid_EE_identity_format],
|
||||||
|
[:ident, :invalid_EE_identity_format_update],
|
||||||
[:ident, :invalid_birthday_format],
|
[:ident, :invalid_birthday_format],
|
||||||
[:ident, :invalid_country_code],
|
[:ident, :invalid_country_code],
|
||||||
[:ident_type, :missing],
|
[:ident_type, :missing],
|
||||||
|
@ -164,7 +165,7 @@ class Epp::Contact < Contact
|
||||||
org_priv = %w(org priv).freeze
|
org_priv = %w(org priv).freeze
|
||||||
if ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.include?(ident_frame.attr('type'))
|
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'))
|
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)
|
elsif ident_type == "birthday" && !ident[/\A\d{4}-\d{2}-\d{2}\z/] && (Date.parse(ident) rescue false)
|
||||||
at.merge!(ident: ident_frame.text)
|
at.merge!(ident: ident_frame.text)
|
||||||
at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present?
|
at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present?
|
||||||
elsif ident_type.blank? && ident_country_code.blank?
|
elsif ident_type.blank? && ident_country_code.blank?
|
||||||
|
|
|
@ -49,6 +49,7 @@ en:
|
||||||
ident:
|
ident:
|
||||||
blank: "Required parameter missing - ident"
|
blank: "Required parameter missing - ident"
|
||||||
invalid_EE_identity_format: "Ident not in valid Estonian identity format."
|
invalid_EE_identity_format: "Ident not in valid Estonian identity format."
|
||||||
|
invalid_EE_identity_format_update: "Ident not in valid Estonian identity format. Please create new contact"
|
||||||
invalid_birthday_format: "Ident not in valid birthady format, should be YYYY-MM-DD"
|
invalid_birthday_format: "Ident not in valid birthady format, should be YYYY-MM-DD"
|
||||||
invalid_country_code: "Ident country code is not valid, should be in ISO_3166-1 alpha 2 format"
|
invalid_country_code: "Ident country code is not valid, should be in ISO_3166-1 alpha 2 format"
|
||||||
domains:
|
domains:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue