Fix some more CC issues

This commit is contained in:
Karl Erik Õunapuu 2020-10-13 13:33:39 +03:00
parent cdf28befca
commit aac74e26f1
No known key found for this signature in database
GPG key ID: C9DD647298A34764
4 changed files with 17 additions and 17 deletions

View file

@ -4,7 +4,6 @@ module Epp
class ContactsController < BaseController class ContactsController < BaseController
before_action :find_contact, only: [:info, :update, :delete] before_action :find_contact, only: [:info, :update, :delete]
before_action :find_password, only: [:info, :update, :delete] before_action :find_password, only: [:info, :update, :delete]
helper_method :address_processing?
def info def info
authorize! :info, @contact, @password authorize! :info, @contact, @password
@ -68,11 +67,13 @@ module Epp
private private
def opt_addr? def opt_addr?
!address_processing? && address_given? !Contact.address_processing? && address_given?
end end
def action_call_response(action:) def action_call_response(action:)
# rubocop:disable Style/AndOr
(handle_errors(@contact) and return) unless action.call (handle_errors(@contact) and return) unless action.call
# rubocop:enable Style/AndOr
if opt_addr? if opt_addr?
@response_code = 1100 @response_code = 1100
@ -123,8 +124,7 @@ module Epp
'postalInfo > addr > cc', 'postalInfo > addr > cc',
] ]
required_attributes.concat(address_attributes) if address_processing? required_attributes.concat(address_attributes) if Contact.address_processing?
requires(*required_attributes) requires(*required_attributes)
ident = params[:parsed_frame].css('ident') ident = params[:parsed_frame].css('ident')
@ -200,9 +200,5 @@ module Epp
def address_given? def address_given?
params[:parsed_frame].css('postalInfo addr').size != 0 params[:parsed_frame].css('postalInfo addr').size != 0
end end
def address_processing?
Contact.address_processing?
end
end end
end end

View file

@ -27,12 +27,7 @@ module Actions
def validate_ident def validate_ident
validate_ident_integrity validate_ident_integrity
validate_ident_birthday
if ident.present? && ident[:ident_type] != 'birthday' && ident[:ident_country_code].blank?
contact.add_epp_error('2003', nil, 'ident_country_code',
I18n.t('errors.messages.required_ident_attribute_missing'))
@error = true
end
identifier = ::Contact::Ident.new(code: ident[:ident], type: ident[:ident_type], identifier = ::Contact::Ident.new(code: ident[:ident], type: ident[:ident_type],
country_code: ident[:ident_country_code]) country_code: ident[:ident_country_code])
@ -54,6 +49,15 @@ module Actions
end end
end end
def validate_ident_birthday
return if ident.blank?
return unless ident[:ident_type] != 'birthday' && ident[:ident_country_code].blank?
contact.add_epp_error('2003', nil, 'ident_country_code',
I18n.t('errors.messages.required_ident_attribute_missing'))
@error = true
end
def maybe_attach_legal_doc def maybe_attach_legal_doc
return unless legal_document return unless legal_document

View file

@ -18,7 +18,7 @@ xml.epp_head do
if can? :view_full_info, @contact, @password if can? :view_full_info, @contact, @password
xml.tag!('contact:org', @contact.org_name) if @contact.org_name.present? xml.tag!('contact:org', @contact.org_name) if @contact.org_name.present?
if address_processing? if Contact.address_processing?
xml.tag!('contact:addr') do xml.tag!('contact:addr') do
xml.tag!('contact:street', @contact.street) xml.tag!('contact:street', @contact.street)
xml.tag!('contact:city', @contact.city) xml.tag!('contact:city', @contact.city)
@ -31,7 +31,7 @@ xml.epp_head do
else else
xml.tag!('contact:org', 'No access') xml.tag!('contact:org', 'No access')
if address_processing? if Contact.address_processing?
xml.tag!('contact:addr') do xml.tag!('contact:addr') do
xml.tag!('contact:street', 'No access') xml.tag!('contact:street', 'No access')
xml.tag!('contact:city', 'No access') xml.tag!('contact:city', 'No access')

View file

@ -5,7 +5,7 @@
.col-md-8 .col-md-8
= render 'registrar/contacts/form/general', f: f = render 'registrar/contacts/form/general', f: f
- if address_processing? - if Contact.address_processing?
.row .row
.col-md-8 .col-md-8
= render 'registrar/contacts/form/address', f: f = render 'registrar/contacts/form/address', f: f