Add publishable contact field

This commit is contained in:
Thiago Youssef 2022-07-15 16:47:30 -03:00 committed by olegphenomenon
parent 9623b3e207
commit 5c129b24ef
6 changed files with 17 additions and 4 deletions

View file

@ -72,6 +72,8 @@ module Api
contact.disclosed_attributes = disclosed_attributes contact.disclosed_attributes = disclosed_attributes
end end
contact.publishable = reparsed_request_json[:publishable] if reparsed_request_json[:publishable]
logger.debug "Setting.address_processing is set to #{Setting.address_processing}" logger.debug "Setting.address_processing is set to #{Setting.address_processing}"
if Setting.address_processing && params[:address] if Setting.address_processing && params[:address]

View file

@ -64,6 +64,7 @@ class Contact < ApplicationRecord
validate :validate_html validate :validate_html
validate :validate_country_code, if: -> { self.class.address_processing? } validate :validate_country_code, if: -> { self.class.address_processing? }
validates_inclusion_of :publishable, in: [false], unless: -> { registrant? }
after_initialize do after_initialize do
self.status_notes = {} if status_notes.nil? self.status_notes = {} if status_notes.nil?

View file

@ -3,4 +3,8 @@ class Registrant < Contact
def epp_code_map def epp_code_map
{} {}
end end
def publishable?
publishable
end
end end

View file

@ -52,6 +52,7 @@ class WhoisRecord < ApplicationRecord
h[:email] = registrant.email h[:email] = registrant.email
h[:phone] = registrant.phone h[:phone] = registrant.phone
h[:publishable] = registrant.publishable?
h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601) h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601)
h[:registrant_disclosed_attributes] = registrant.disclosed_attributes h[:registrant_disclosed_attributes] = registrant.disclosed_attributes

View file

@ -0,0 +1,5 @@
class AddPublishableToContacts < ActiveRecord::Migration[6.1]
def change
add_column :contacts, :publishable, :boolean, default: false
end
end

View file

@ -670,7 +670,8 @@ CREATE TABLE public.contacts (
up_date timestamp without time zone, up_date timestamp without time zone,
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL, uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
disclosed_attributes character varying[] DEFAULT '{}'::character varying[] NOT NULL, disclosed_attributes character varying[] DEFAULT '{}'::character varying[] NOT NULL,
email_history character varying email_history character varying,
publishable boolean DEFAULT false
); );
@ -5417,6 +5418,5 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220524130709'), ('20220524130709'),
('20220701113409'), ('20220701113409'),
('20220818075833'), ('20220818075833'),
('20221011061840'); ('20221011061840'),
('20220715145808');