Merge pull request #125 from internetee/story/117991277-ident-cc

Story/117991277 ident cc
This commit is contained in:
Timo Võhmar 2016-04-20 15:45:55 +03:00
commit 3dfe64995f
2 changed files with 8 additions and 2 deletions

View file

@ -81,7 +81,7 @@ class Contact < ActiveRecord::Base
ORG = 'org' ORG = 'org'
PRIV = 'priv' PRIV = 'priv'
BIRTHDAY = 'birthday' BIRTHDAY = 'birthday'.freeze
PASSPORT = 'passport' PASSPORT = 'passport'
IDENT_TYPES = [ IDENT_TYPES = [
@ -252,6 +252,8 @@ class Contact < ActiveRecord::Base
if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/) if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/)
errors.add(:ident, err_msg) errors.add(:ident, err_msg)
end end
when BIRTHDAY
errors.add(:ident, err_msg)
end end
end end
end end
@ -284,6 +286,10 @@ class Contact < ActiveRecord::Base
!org? !org?
end end
def birthday?
ident_type == BIRTHDAY
end
def generate_auth_info def generate_auth_info
return if @generate_auth_info_disabled return if @generate_auth_info_disabled
return if auth_info.present? return if auth_info.present?

View file

@ -173,7 +173,7 @@ class Epp::Contact < Contact
elsif ident_type == "birthday" && !ident[/\A\d{4}-\d{2}-\d{2}\z/] && (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 == "birthday" && ident_country_code.blank? elsif ident_type == "birthday" && ident_country_code.blank?
at.merge!(ident_country_code: ident_frame.attr('cc')) at.merge!(ident_country_code: ident_frame.attr('cc'))
elsif ident_type.blank? && ident_country_code.blank? elsif ident_type.blank? && ident_country_code.blank?
at.merge!(ident_type: ident_frame.attr('type')) at.merge!(ident_type: ident_frame.attr('type'))