Ident type update #2834

This commit is contained in:
Priit Tark 2015-09-17 17:52:47 +03:00
parent 2a81641130
commit fd52172500
9 changed files with 32 additions and 25 deletions

View file

@ -23,7 +23,7 @@ class Contact < ActiveRecord::Base
validates :ident,
format: { with: /\d{4}-\d{2}-\d{2}/, message: :invalid_birthday_format },
if: proc { |c| c.ident_type == 'birthday' }
validates :ident_country_code, presence: true, if: proc { |c| %w(bic priv).include? c.ident_type }
validates :ident_country_code, presence: true, if: proc { |c| %w(org priv).include? c.ident_type }
validates :code,
uniqueness: { message: :epp_id_taken },
format: { with: /\A[\w\-\:]*\Z/i, message: :invalid },
@ -64,13 +64,13 @@ class Contact < ActiveRecord::Base
scope :current_registrars, ->(id) { where(registrar_id: id) }
BIC = 'bic'
ORG = 'org'
PRIV = 'priv'
BIRTHDAY = 'birthday'
PASSPORT = 'passport'
IDENT_TYPES = [
BIC, # Company registry code (or similar)
ORG, # Company registry code (or similar)
PRIV, # National idendtification number
BIRTHDAY # Birthday date
]
@ -226,12 +226,13 @@ class Contact < ActiveRecord::Base
false
end
def bic?
ident_type == BIC
def org?
ident_type == ORG
end
# it might mean priv or birthday type
def priv?
ident_type != BIC
!org?
end
def generate_auth_info

View file

@ -267,8 +267,8 @@ module Depp
Country.new(country_code)
end
def bic?
ident_type == 'bic'
def org?
ident_type == 'org'
end
def priv?

View file

@ -137,7 +137,7 @@ class Epp::Domain < Domain
return if registrant.blank?
regt = Registrant.find(registrant.id) # temp for bullet
tech_contacts << regt if tech_domain_contacts.blank?
admin_contacts << regt if admin_domain_contacts.blank? && regt.priv?
admin_contacts << regt if admin_domain_contacts.blank? && !regt.org?
end
# rubocop: disable Metrics/PerceivedComplexity
@ -283,7 +283,7 @@ class Epp::Domain < Domain
end
if action != 'rem'
if x['type'] == 'admin' && c.bic?
if x['type'] == 'admin' && c.org?
add_epp_error('2306', 'contact', x.text, [:domain_contacts, :admin_contact_can_be_only_private_person])
next
end