mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 13:36:15 +02:00
Remove contact code cache from domain contacts table
This commit is contained in:
parent
3852620180
commit
750bf0821c
11 changed files with 42 additions and 50 deletions
|
@ -14,8 +14,8 @@ module Repp
|
||||||
api :GET, '/repp/v1/domains/:domain_name/contacts'
|
api :GET, '/repp/v1/domains/:domain_name/contacts'
|
||||||
desc "View domain's admin and tech contacts"
|
desc "View domain's admin and tech contacts"
|
||||||
def index
|
def index
|
||||||
admin_contacts = @domain.admin_domain_contacts.pluck(:contact_code_cache)
|
admin_contacts = @domain.admin_domain_contacts.map(&:contact).pluck(:code)
|
||||||
tech_contacts = @domain.tech_domain_contacts.pluck(:contact_code_cache)
|
tech_contacts = @domain.tech_domain_contacts.map(&:contact).pluck(:code)
|
||||||
|
|
||||||
data = { admin_contacts: admin_contacts, tech_contacts: tech_contacts }
|
data = { admin_contacts: admin_contacts, tech_contacts: tech_contacts }
|
||||||
render_success(data: data)
|
render_success(data: data)
|
||||||
|
@ -38,7 +38,6 @@ module Repp
|
||||||
def cta(action = 'add')
|
def cta(action = 'add')
|
||||||
params[:contacts].each { |c| c[:action] = action }
|
params[:contacts].each { |c| c[:action] = action }
|
||||||
action = Actions::DomainUpdate.new(@domain, contact_create_params, false)
|
action = Actions::DomainUpdate.new(@domain, contact_create_params, false)
|
||||||
|
|
||||||
# rubocop:disable Style/AndOr
|
# rubocop:disable Style/AndOr
|
||||||
handle_errors(@domain) and return unless action.call
|
handle_errors(@domain) and return unless action.call
|
||||||
# rubocop:enable Style/AndOr
|
# rubocop:enable Style/AndOr
|
||||||
|
|
|
@ -120,7 +120,7 @@ module Actions
|
||||||
contact = Contact.find_by(code: contact_code)
|
contact = Contact.find_by(code: contact_code)
|
||||||
arr = admin ? @admin_contacts : @tech_contacts
|
arr = admin ? @admin_contacts : @tech_contacts
|
||||||
if contact
|
if contact
|
||||||
arr << { contact_id: contact.id, contact_code_cache: contact.code }
|
arr << { contact_id: contact.id }
|
||||||
else
|
else
|
||||||
domain.add_epp_error('2303', 'contact', contact_code, %i[domain_contacts not_found])
|
domain.add_epp_error('2303', 'contact', contact_code, %i[domain_contacts not_found])
|
||||||
end
|
end
|
||||||
|
|
|
@ -125,8 +125,7 @@ module Actions
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_validate_email(props)
|
def start_validate_email(props)
|
||||||
contact_code = props[0][:contact_code_cache]
|
contact = Contact.find(props[0][:contact_id])
|
||||||
contact = Contact.find_by(code: contact_code)
|
|
||||||
|
|
||||||
return if contact.nil?
|
return if contact.nil?
|
||||||
|
|
||||||
|
@ -206,7 +205,7 @@ module Actions
|
||||||
domain.add_epp_error('2306', 'contact', code,
|
domain.add_epp_error('2306', 'contact', code,
|
||||||
%i[domain_contacts admin_contact_can_be_only_private_person])
|
%i[domain_contacts admin_contact_can_be_only_private_person])
|
||||||
else
|
else
|
||||||
add ? { contact_id: obj.id, contact_code_cache: obj.code } : { id: obj.id, _destroy: 1 }
|
add ? { contact_id: obj.id } : { id: obj.id, _destroy: 1 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -161,14 +161,6 @@ class Domain < ApplicationRecord
|
||||||
attribute: 'hostname'
|
attribute: 'hostname'
|
||||||
}
|
}
|
||||||
|
|
||||||
validates :tech_domain_contacts, uniqueness_multi: {
|
|
||||||
attribute: 'contact_code_cache'
|
|
||||||
}
|
|
||||||
|
|
||||||
validates :admin_domain_contacts, uniqueness_multi: {
|
|
||||||
attribute: 'contact_code_cache'
|
|
||||||
}
|
|
||||||
|
|
||||||
validates :dnskeys, uniqueness_multi: {
|
validates :dnskeys, uniqueness_multi: {
|
||||||
attribute: 'public_key'
|
attribute: 'public_key'
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,32 +6,20 @@ class DomainContact < ApplicationRecord
|
||||||
belongs_to :contact
|
belongs_to :contact
|
||||||
belongs_to :domain
|
belongs_to :domain
|
||||||
|
|
||||||
|
validates :contact, presence: true
|
||||||
|
|
||||||
|
after_destroy :update_contact
|
||||||
attr_accessor :value_typeahead
|
attr_accessor :value_typeahead
|
||||||
|
|
||||||
self.ignored_columns = %w[legacy_domain_id legacy_contact_id]
|
self.ignored_columns = %w[legacy_domain_id legacy_contact_id]
|
||||||
|
|
||||||
def epp_code_map
|
|
||||||
{
|
|
||||||
'2302' => [
|
|
||||||
[:contact_code_cache, :taken, { value: { obj: 'contact', val: contact_code_cache } }]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def name
|
def name
|
||||||
return 'Tech' if type == 'TechDomainContact'
|
return 'Tech' if type == 'TechDomainContact'
|
||||||
return 'Admin' if type == 'AdminDomainContact'
|
return 'Admin' if type == 'AdminDomainContact'
|
||||||
|
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
validates :contact, presence: true
|
|
||||||
|
|
||||||
before_save :update_contact_code_cache
|
|
||||||
def update_contact_code_cache
|
|
||||||
self.contact_code_cache = contact.code
|
|
||||||
end
|
|
||||||
|
|
||||||
after_destroy :update_contact
|
|
||||||
def update_contact
|
def update_contact
|
||||||
Contact.find(contact_id).save
|
Contact.find(contact_id).save
|
||||||
end
|
end
|
||||||
|
|
|
@ -96,8 +96,6 @@ en:
|
||||||
contact:
|
contact:
|
||||||
blank: 'Contact was not found'
|
blank: 'Contact was not found'
|
||||||
taken: 'Contact already exists on this domain'
|
taken: 'Contact already exists on this domain'
|
||||||
contact_code_cache:
|
|
||||||
taken: 'Contact already exists on this domain'
|
|
||||||
|
|
||||||
domain_status:
|
domain_status:
|
||||||
attributes:
|
attributes:
|
||||||
|
@ -628,7 +626,7 @@ en:
|
||||||
contact_ident: 'Contact ident'
|
contact_ident: 'Contact ident'
|
||||||
results_per_page: 'Results per page'
|
results_per_page: 'Results per page'
|
||||||
nameserver_hostname: 'Nameserver hostname'
|
nameserver_hostname: 'Nameserver hostname'
|
||||||
result_count:
|
result_count:
|
||||||
zero: 'No results'
|
zero: 'No results'
|
||||||
other: '%{count} results'
|
other: '%{count} results'
|
||||||
one: '1 result'
|
one: '1 result'
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
class AddCodeCacheForDomainContact < ActiveRecord::Migration[6.0]
|
class AddCodeCacheForDomainContact < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
add_column :domain_contacts, :contact_code_cache, :string
|
# add_column :domain_contacts, :contact_code_cache, :string
|
||||||
|
#
|
||||||
DomainContact.all.each do |x|
|
# DomainContact.all.each do |x|
|
||||||
x.contact_code_cache = x.contact.code
|
# x.contact_code_cache = x.contact.code
|
||||||
x.save
|
# x.save
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RemoveContactCodeCacheFromDomainContacts < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
# remove_column :domain_contacts, :contact_code_cache
|
||||||
|
end
|
||||||
|
end
|
|
@ -51,6 +51,20 @@ CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
|
||||||
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
|
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQL statements executed';
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
|
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -848,7 +862,6 @@ CREATE TABLE public.domain_contacts (
|
||||||
domain_id integer,
|
domain_id integer,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone,
|
||||||
contact_code_cache character varying,
|
|
||||||
creator_str character varying,
|
creator_str character varying,
|
||||||
updator_str character varying,
|
updator_str character varying,
|
||||||
type character varying,
|
type character varying,
|
||||||
|
@ -1091,7 +1104,6 @@ CREATE TABLE public.invoices (
|
||||||
buyer_vat_no character varying,
|
buyer_vat_no character varying,
|
||||||
issue_date date NOT NULL,
|
issue_date date NOT NULL,
|
||||||
e_invoice_sent_at timestamp without time zone,
|
e_invoice_sent_at timestamp without time zone,
|
||||||
payment_link character varying,
|
|
||||||
CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date))
|
CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -5083,13 +5095,13 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20220106123143'),
|
('20220106123143'),
|
||||||
('20220113201642'),
|
('20220113201642'),
|
||||||
('20220113220809'),
|
('20220113220809'),
|
||||||
|
('20220228093211'),
|
||||||
('20220316140727'),
|
('20220316140727'),
|
||||||
('20220406085500'),
|
('20220406085500'),
|
||||||
|
('20220412130856'),
|
||||||
('20220413073315'),
|
('20220413073315'),
|
||||||
('20220413084536'),
|
('20220413084536'),
|
||||||
('20220413084748'),
|
('20220413084748'),
|
||||||
('20220124105717'),
|
('20220504090512');
|
||||||
('20220216113112'),
|
|
||||||
('20220228093211'),
|
|
||||||
('20220412130856');
|
|
||||||
|
|
||||||
|
|
|
@ -9980,7 +9980,7 @@ RESPONSE:
|
||||||
</value>
|
</value>
|
||||||
</result>
|
</result>
|
||||||
<result code="2302">
|
<result code="2302">
|
||||||
<msg lang="en">Contact already exists on this domain [contact_code_cache]</msg>
|
<msg lang="en">Contact already exists on this domain [contact_code]</msg>
|
||||||
<value xmlns:obj="urn:ietf:params:xml:ns:obj">
|
<value xmlns:obj="urn:ietf:params:xml:ns:obj">
|
||||||
<obj:contact>FIXED:MAK21</obj:contact>
|
<obj:contact>FIXED:MAK21</obj:contact>
|
||||||
</value>
|
</value>
|
||||||
|
@ -10505,7 +10505,7 @@ RESPONSE:
|
||||||
</value>
|
</value>
|
||||||
</result>
|
</result>
|
||||||
<result code="2302">
|
<result code="2302">
|
||||||
<msg lang="en">Contact already exists on this domain [contact_code_cache]</msg>
|
<msg lang="en">Contact already exists on this domain [contact_code]</msg>
|
||||||
<value xmlns:obj="urn:ietf:params:xml:ns:obj">
|
<value xmlns:obj="urn:ietf:params:xml:ns:obj">
|
||||||
<obj:contact>FIXED:SH6021836789</obj:contact>
|
<obj:contact>FIXED:SH6021836789</obj:contact>
|
||||||
</value>
|
</value>
|
||||||
|
@ -14058,4 +14058,3 @@ RESPONSE:
|
||||||
</response>
|
</response>
|
||||||
</epp>
|
</epp>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Serializers
|
||||||
# rubocop:enable Metrics/AbcSize
|
# rubocop:enable Metrics/AbcSize
|
||||||
|
|
||||||
def contacts
|
def contacts
|
||||||
domain.domain_contacts.map { |c| { code: c.contact_code_cache, type: c.type } }
|
domain.domain_contacts.map { |c| { code: c.contact.code, type: c.type } }
|
||||||
end
|
end
|
||||||
|
|
||||||
def nameservers
|
def nameservers
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue