mirror of
https://github.com/internetee/registry.git
synced 2025-07-13 14:35:05 +02:00
Added ident country code and improved other ident things
This commit is contained in:
parent
e9b77c5b0f
commit
44f11de5c8
13 changed files with 117 additions and 66 deletions
|
@ -94,6 +94,13 @@ class Epp::ContactsController < EppController
|
|||
'postalInfo > name', 'postalInfo > addr > city',
|
||||
'postalInfo > addr > cc', 'ident', 'voice', 'email'
|
||||
)
|
||||
ident = params[:parsed_frame].css('ident')
|
||||
if ident.present? && ident.text != 'birthday' && ident.attr('cc').blank?
|
||||
epp_errors << {
|
||||
code: '2003',
|
||||
msg: I18n.t('errors.messages.required_attribute_missing', key: 'ident country code missing')
|
||||
}
|
||||
end
|
||||
@prefix = nil
|
||||
requires 'extension > extdata > legalDocument'
|
||||
end
|
||||
|
|
|
@ -8,4 +8,13 @@ module ApplicationHelper
|
|||
return '' if unstable_env.nil?
|
||||
"background-image: url(#{image_path(unstable_env.to_s + '.png')});"
|
||||
end
|
||||
|
||||
def ident_indicator(contact)
|
||||
case contact.ident_type
|
||||
when 'birthday'
|
||||
"[#{contact.ident_type}]"
|
||||
else
|
||||
"[#{contact.ident_country_code} #{contact.ident_type}]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,8 +19,9 @@ class Contact < ActiveRecord::Base
|
|||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/
|
||||
validates :email, format: /@/
|
||||
validates :ident, format: /\d{4}-\d{2}-\d{2}/, if: proc { |c| c.ident_type == 'birthday' }
|
||||
validate :ident_must_be_valid
|
||||
validates :ident_country_code, presence: true, if: proc { |c| %w(bic priv).include? c.ident_type }
|
||||
validates :code, uniqueness: { message: :epp_id_taken }
|
||||
validate :ident_valid_format?
|
||||
|
||||
delegate :street, to: :address
|
||||
delegate :city, to: :address
|
||||
|
@ -29,19 +30,17 @@ class Contact < ActiveRecord::Base
|
|||
delegate :country_code, to: :address
|
||||
delegate :country, to: :address
|
||||
|
||||
before_validation :set_ident_country_code
|
||||
before_create :generate_code
|
||||
before_create :generate_auth_info
|
||||
after_create :ensure_disclosure
|
||||
|
||||
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
||||
|
||||
IDENT_TYPE_ICO = 'ico'
|
||||
IDENT_TYPE_BIC = 'bic'
|
||||
IDENT_TYPES = [
|
||||
IDENT_TYPE_ICO, # Company registry code (or similar)
|
||||
'bic', # Business registry code
|
||||
IDENT_TYPE_BIC, # Company registry code (or similar)
|
||||
'priv', # National idendtification number
|
||||
'op', # Estonian ID, depricated
|
||||
'passport', # Passport number, depricated
|
||||
'birthday' # Birthday date
|
||||
]
|
||||
|
||||
|
@ -75,24 +74,27 @@ class Contact < ActiveRecord::Base
|
|||
name
|
||||
end
|
||||
|
||||
def ident_must_be_valid
|
||||
# TODO: Ident can also be passport number or company registry code.
|
||||
# so have to make changes to validations (and doc/schema) accordingly
|
||||
return true unless ident.present? && ident_type.present? && ident_type == 'op'
|
||||
code = Isikukood.new(ident)
|
||||
errors.add(:ident, 'bad format') unless code.valid?
|
||||
def ident_valid_format?
|
||||
case ident_type
|
||||
when 'priv'
|
||||
case ident_country_code
|
||||
when 'EE'
|
||||
code = Isikukood.new(ident)
|
||||
errors.add(:ident, :not_valid_EE_identity_format) unless code.valid?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_disclosure
|
||||
create_disclosure! unless disclosure
|
||||
end
|
||||
|
||||
def juridical?
|
||||
ident_type == IDENT_TYPE_ICO
|
||||
def bic?
|
||||
ident_type == IDENT_TYPE_BIC
|
||||
end
|
||||
|
||||
def citizen?
|
||||
ident_type != IDENT_TYPE_ICO
|
||||
def priv?
|
||||
ident_type != IDENT_TYPE_BIC
|
||||
end
|
||||
|
||||
# generate random id for contact
|
||||
|
@ -124,4 +126,14 @@ class Contact < ActiveRecord::Base
|
|||
end
|
||||
destroy
|
||||
end
|
||||
|
||||
def set_ident_country_code
|
||||
return true unless ident_country_code_changed? && ident_country_code.present?
|
||||
code = Country.new(ident_country_code)
|
||||
if code
|
||||
self.ident_country_code = code.alpha2
|
||||
else
|
||||
errors.add(:ident_country_code, 'is not following ISO_3166-1 alpha 2 format')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -211,7 +211,7 @@ class Domain < ActiveRecord::Base
|
|||
attach_contact(DomainContact::TECH, owner_contact)
|
||||
end
|
||||
|
||||
return unless admin_domain_contacts.count.zero? && owner_contact.citizen?
|
||||
return unless admin_domain_contacts.count.zero? && owner_contact.priv?
|
||||
attach_contact(DomainContact::ADMIN, owner_contact)
|
||||
end
|
||||
|
||||
|
|
|
@ -20,8 +20,9 @@ class Epp::Contact < Contact
|
|||
at[:auth_info] = f.css('authInfo pw').text if f.css('authInfo pw').present?
|
||||
|
||||
if f.css('ident').present? && f.css('ident').attr('type').present?
|
||||
at[:ident] = f.css('ident').text
|
||||
at[:ident_type] = f.css('ident').attr('type').text
|
||||
at[:ident] = f.css('ident').text
|
||||
at[:ident_type] = f.css('ident').attr('type').try(:text)
|
||||
at[:ident_country_code] = f.css('ident').attr('cc').try(:text)
|
||||
end
|
||||
|
||||
at[:address_attributes] = {}.with_indifferent_access
|
||||
|
@ -69,7 +70,8 @@ class Epp::Contact < Contact
|
|||
'2005' => [ # Value syntax error
|
||||
[:phone, :invalid],
|
||||
[:email, :invalid],
|
||||
[:ident, :invalid]
|
||||
[:ident, :invalid],
|
||||
[:ident, :not_valid_EE_identity_format]
|
||||
]
|
||||
}
|
||||
end
|
||||
|
|
|
@ -129,7 +129,7 @@ class Epp::EppDomain < Domain
|
|||
next
|
||||
end
|
||||
|
||||
if k == :admin && contact.juridical?
|
||||
if k == :admin && contact.bic?
|
||||
add_epp_error('2306', 'contact', x[:contact], [:domain_contacts, :admin_contact_can_be_only_citizen])
|
||||
next
|
||||
end
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t('address')
|
||||
%h3.panel-title= t(:address)
|
||||
.panel-body
|
||||
- unless @contact.address.nil?
|
||||
%dl.dl-horizontal
|
||||
%dt= t('street')
|
||||
- if @contact.bic?
|
||||
%dt= t(:org_name)
|
||||
%dd= @contact.org_name
|
||||
|
||||
%dt= t(:street)
|
||||
%dd= @contact.street
|
||||
|
||||
%dt= t('city')
|
||||
%dt= t(:city)
|
||||
%dd= @contact.city
|
||||
|
||||
%dt= t('zip')
|
||||
%dt= t(:zip)
|
||||
%dd= @contact.zip
|
||||
|
||||
%dt= t('state')
|
||||
%dt= t(:state)
|
||||
%dd= @contact.state
|
||||
|
||||
%dt= t('country')
|
||||
%dt= t(:country)
|
||||
%dd= @contact.country
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t(:ident)
|
||||
%dd= @contact.ident + ' [' + @contact.ident_type + ']'
|
||||
%dd= "#{@contact.ident} #{ident_indicator(@contact)}"
|
||||
|
||||
%br
|
||||
|
||||
|
@ -14,9 +14,6 @@
|
|||
%dt= t(:phone)
|
||||
%dd= @contact.phone
|
||||
|
||||
%dt= t(:org_name)
|
||||
%dd= @contact.org_name
|
||||
|
||||
- if @contact.fax
|
||||
%dt= t(:fax)
|
||||
%dd= @contact.fax
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue