Do not require address in registrar area unless address_processing is enabled

#251
This commit is contained in:
Artur Beljajev 2016-12-19 08:06:23 +02:00
parent 99a928fd3a
commit 8cc2d030b8
4 changed files with 110 additions and 45 deletions

View file

@ -1,5 +1,6 @@
class Registrar::ContactsController < Registrar::DeppController # EPP controller
before_action :init_epp_contact
helper_method :address_processing?
def index
authorize! :view, Depp::Contact
@ -134,4 +135,8 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller
params[:q][:valid_to_lteq] = ca_cache
end
def address_processing?
Contact.address_processing?
end
end

View file

@ -150,18 +150,21 @@ module Depp
postalInfo: {
name: { value: name },
org: { value: org_name },
addr: {
street: { value: street },
city: { value: city },
sp: { value: state },
pc: { value: zip },
cc: { value: country_code }
}
},
voice: { value: phone },
email: { value: email }
}
if ::Contact.address_processing?
hash[:postalInfo][:addr] = {
street: { value: street },
city: { value: city },
sp: { value: state },
pc: { value: zip },
cc: { value: country_code },
}
end
hash[:id] = nil if code.blank?
create_xml = Depp::Contact.epp_xml.create(hash, extension_xml(:create))
@ -182,36 +185,41 @@ module Depp
self.phone = params[:phone]
self.org_name = params[:org_name]
self.street = params[:street]
self.city = params[:city]
self.zip = params[:zip]
self.state = params[:state]
self.country_code = params[:country_code]
update_xml = Depp::Contact.epp_xml.update(
{
id: { value: id },
chg: {
postalInfo: {
name: { value: name },
org: { value: org_name },
addr: {
street: { value: street },
city: { value: city },
sp: { value: state },
pc: { value: zip },
cc: { value: country_code }
}
},
voice: { value: phone },
email: { value: email },
authInfo: {
pw: { value: password }
}
if ::Contact.address_processing?
self.street = params[:street]
self.city = params[:city]
self.zip = params[:zip]
self.state = params[:state]
self.country_code = params[:country_code]
end
attributes = {
id: { value: id },
chg: {
postalInfo: {
name: { value: name },
org: { value: org_name },
},
voice: { value: phone },
email: { value: email },
authInfo: {
pw: { value: password }
}
},
extension_xml(:update)
)
}
}
if ::Contact.address_processing?
attributes[:chg][:postalInfo][:addr] = {
street: { value: street },
city: { value: city },
sp: { value: state },
pc: { value: zip },
cc: { value: country_code }
}
end
update_xml = Depp::Contact.epp_xml.update(attributes, extension_xml(:update))
data = Depp::Contact.user.request(update_xml)
handle_errors(data)
end

View file

@ -4,21 +4,21 @@
.panel-body
.form-group
.col-md-3.control-label
= f.label :street, t(:street) + '*'
= f.label :street, t(:street)
.col-md-7
= f.text_field :street, class: 'form-control', required: true
= f.text_field :street, class: 'form-control', required: address_processing?
.form-group
.col-md-3.control-label
= f.label :city, t(:city) + '*'
= f.label :city, t(:city)
.col-md-7
= f.text_field :city, class: 'form-control', required: true
= f.text_field :city, class: 'form-control', required: address_processing?
.form-group
.col-md-3.control-label
= f.label :zip, t(:zip) + '*'
= f.label :zip, t(:zip)
.col-md-7
= f.text_field :zip, class: 'form-control', required: true
= f.text_field :zip, class: 'form-control', required: address_processing?
.form-group
.col-md-3.control-label
@ -28,9 +28,10 @@
.form-group
.col-md-3.control-label
= f.label :country_code, t(:country) + '*'
= f.label :country_code, t(:country)
.col-md-7
- country_selected = f.object.persisted? ? f.object.country_code : 'EE'
= f.select(:country_code, SortedCountry.all_options(country_selected),
{ include_blank: true }, required: true)
= f.select(:country_code,
SortedCountry.all_options(country_selected),
{ include_blank: true },
required: address_processing?)