mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
parent
59db269240
commit
d695d95ad7
15 changed files with 184 additions and 30 deletions
|
@ -45,6 +45,22 @@ module Api
|
|||
contact.email = params[:email] if params[:email].present?
|
||||
contact.phone = params[:phone] if params[:phone].present?
|
||||
|
||||
# Needed to support passing empty array, which otherwise gets parsed to nil
|
||||
# https://github.com/rails/rails/pull/13157
|
||||
reparsed_request_json = ActiveSupport::JSON.decode(request.body.string)
|
||||
.with_indifferent_access
|
||||
disclosed_attributes = reparsed_request_json[:disclosed_attributes]
|
||||
|
||||
if disclosed_attributes
|
||||
if contact.org?
|
||||
error_msg = "Legal person's data cannot be concealed. Please remove this parameter."
|
||||
render json: { errors: [{ disclosed_attributes: [error_msg] }] }, status: :bad_request
|
||||
return
|
||||
end
|
||||
|
||||
contact.disclosed_attributes = disclosed_attributes
|
||||
end
|
||||
|
||||
if Setting.address_processing && params[:address]
|
||||
address = Contact::Address.new(params[:address][:street],
|
||||
params[:address][:zip],
|
||||
|
|
26
app/models/concerns/contact/disclosable.rb
Normal file
26
app/models/concerns/contact/disclosable.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Concerns
|
||||
module Contact
|
||||
module Disclosable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
attr_accessor :disclosable_attributes
|
||||
end
|
||||
|
||||
included do
|
||||
self.disclosable_attributes = %w[name email]
|
||||
validate :validate_disclosed_attributes
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_disclosed_attributes
|
||||
return if disclosed_attributes.empty?
|
||||
|
||||
has_undisclosable_attributes = (disclosed_attributes - self.class.disclosable_attributes)
|
||||
.any?
|
||||
errors.add(:disclosed_attributes, :invalid) if has_undisclosable_attributes
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,6 +4,7 @@ class Contact < ActiveRecord::Base
|
|||
include UserEvents
|
||||
include Concerns::Contact::Transferable
|
||||
include Concerns::Contact::Identical
|
||||
include Concerns::Contact::Disclosable
|
||||
|
||||
belongs_to :original, class_name: self.name
|
||||
belongs_to :registrar, required: true
|
||||
|
|
|
@ -52,22 +52,18 @@ class WhoisRecord < ActiveRecord::Base
|
|||
|
||||
h[:email] = registrant.email
|
||||
h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601)
|
||||
h[:registrant_disclosed_attributes] = registrant.disclosed_attributes
|
||||
|
||||
h[:admin_contacts] = []
|
||||
domain.admin_contacts.each do |ac|
|
||||
h[:admin_contacts] << {
|
||||
name: ac.name,
|
||||
email: ac.email,
|
||||
changed: ac.updated_at.try(:to_s, :iso8601)
|
||||
}
|
||||
|
||||
domain.admin_contacts.each do |contact|
|
||||
h[:admin_contacts] << contact_json_hash(contact)
|
||||
end
|
||||
|
||||
h[:tech_contacts] = []
|
||||
domain.tech_contacts.each do |tc|
|
||||
h[:tech_contacts] << {
|
||||
name: tc.name,
|
||||
email: tc.email,
|
||||
changed: tc.updated_at.try(:to_s, :iso8601)
|
||||
}
|
||||
|
||||
domain.tech_contacts.each do |contact|
|
||||
h[:tech_contacts] << contact_json_hash(contact)
|
||||
end
|
||||
|
||||
# update registar triggers when adding new attributes
|
||||
|
@ -109,4 +105,13 @@ class WhoisRecord < ActiveRecord::Base
|
|||
def disclaimer_text
|
||||
Setting.registry_whois_disclaimer
|
||||
end
|
||||
|
||||
def contact_json_hash(contact)
|
||||
{
|
||||
name: contact.name,
|
||||
email: contact.email,
|
||||
changed: contact.updated_at.try(:to_s, :iso8601),
|
||||
disclosed_attributes: contact.disclosed_attributes,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<div class="form-group">
|
||||
<% if f.object.new_record? %>
|
||||
<div class="col-md-offset-4 col-md-8">
|
||||
<%= t '.no_reference_no_hint' %>
|
||||
<%= t '.no_reference_number_hint' %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="col-md-4 control-label">
|
||||
|
@ -60,7 +60,7 @@
|
|||
|
||||
<div class="col-md-7">
|
||||
<%= f.text_field :reference_no, disabled: true,
|
||||
title: t('.disabled_reference_no_hint'),
|
||||
title: t('.disabled_reference_number_hint'),
|
||||
class: 'form-control' %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue