Remove delegations

This commit is contained in:
Artur Beljajev 2019-03-28 00:17:48 +02:00
parent c85ebf542d
commit 0f4a67d696
18 changed files with 30 additions and 46 deletions

View file

@ -12,7 +12,7 @@ class DomainDeleteConfirmEmailJob < Que::Job
def log(domain) def log(domain)
message = "Send DomainDeleteMailer#confirm email for domain #{domain.name} (##{domain.id})" \ message = "Send DomainDeleteMailer#confirm email for domain #{domain.name} (##{domain.id})" \
" to #{domain.registrant_email}" " to #{domain.registrant.email}"
logger.info(message) logger.info(message)
end end

View file

@ -13,7 +13,7 @@ class RegistrantChangeConfirmEmailJob < Que::Job
private private
def log(domain) def log(domain)
message = "Send RegistrantChangeMailer#confirm email for domain #{domain.name} (##{domain.id}) to #{domain.registrant_email}" message = "Send RegistrantChangeMailer#confirm email for domain #{domain.name} (##{domain.id}) to #{domain.registrant.email}"
logger.info(message) logger.info(message)
end end

View file

@ -23,7 +23,7 @@ class RegistrantChangeMailer < ApplicationMailer
def confirmed(domain:, old_registrant:) def confirmed(domain:, old_registrant:)
@domain = domain @domain = domain
recipients = [domain.registrant_email, old_registrant.email] recipients = [domain.registrant.email, old_registrant.email]
subject = default_i18n_subject(domain_name: domain.name) subject = default_i18n_subject(domain_name: domain.name)
mail(to: recipients, subject: subject) mail(to: recipients, subject: subject)

View file

@ -59,7 +59,6 @@ class Contact < ActiveRecord::Base
return nil unless deliver_emails == true return nil unless deliver_emails == true
emails = [] emails = []
emails << [email, email_was] emails << [email, email_was]
# emails << domains.map(&:registrant_email) if domains.present?
emails = emails.flatten.uniq emails = emails.flatten.uniq
emails.each do |e| emails.each do |e|
ContactMailer.email_updated(email_was, e, id, deliver_emails).deliver ContactMailer.email_updated(email_was, e, id, deliver_emails).deliver

View file

@ -59,20 +59,6 @@ class Domain < ActiveRecord::Base
has_many :legal_documents, as: :documentable has_many :legal_documents, as: :documentable
accepts_nested_attributes_for :legal_documents, reject_if: proc { |attrs| attrs[:body].blank? } accepts_nested_attributes_for :legal_documents, reject_if: proc { |attrs| attrs[:body].blank? }
delegate :name, to: :registrant, prefix: true
delegate :code, to: :registrant, prefix: true
delegate :ident, to: :registrant, prefix: true
delegate :email, to: :registrant, prefix: true
delegate :phone, to: :registrant, prefix: true
delegate :street, to: :registrant, prefix: true
delegate :city, to: :registrant, prefix: true
delegate :zip, to: :registrant, prefix: true
delegate :state, to: :registrant, prefix: true
delegate :country, to: :registrant, prefix: true
delegate :name, to: :registrar, prefix: true
delegate :street, to: :registrar, prefix: true
after_initialize do after_initialize do
self.pending_json = {} if pending_json.blank? self.pending_json = {} if pending_json.blank?
self.statuses = [] if statuses.nil? self.statuses = [] if statuses.nil?

View file

@ -1,5 +1,5 @@
class DomainPresenter class DomainPresenter
delegate :name, :transfer_code, :registrant_name, :registrant_id, :registrant_code, to: :domain delegate :name, :transfer_code, :registrant, :registrant_id, to: :domain
def initialize(domain:, view:) def initialize(domain:, view:)
@domain = domain @domain = domain

View file

@ -34,8 +34,8 @@ class Registrar::DomainListCSVPresenter
row = [] row = []
row[0] = domain.name row[0] = domain.name
row[1] = domain.transfer_code row[1] = domain.transfer_code
row[2] = domain.registrant_name row[2] = domain.registrant.name
row[3] = domain.registrant_code row[3] = domain.registrant.code
row[4] = domain.expire_date row[4] = domain.expire_date
row row

View file

@ -7,13 +7,13 @@
%dd= link_to(@domain.registrant, [:admin, @domain.registrant]) %dd= link_to(@domain.registrant, [:admin, @domain.registrant])
%dt= t(:id) %dt= t(:id)
%dd= @domain.registrant_code %dd= @domain.registrant.code
%dt= t(:identity_code) %dt= t(:identity_code)
%dd= @domain.registrant_ident %dd= @domain.registrant.ident
%dt= t(:email) %dt= t(:email)
%dd= @domain.registrant_email %dd= @domain.registrant.email
%dt= t(:phone) %dt= t(:phone)
%dd= @domain.registrant_phone %dd= @domain.registrant.phone

View file

@ -12,7 +12,7 @@ xml.epp_head do
xml.tag!('domain:status', 's' => s) xml.tag!('domain:status', 's' => s)
end end
xml.tag!('domain:registrant', @domain.registrant_code) xml.tag!('domain:registrant', @domain.registrant.code)
@domain.tech_contacts.each do |tc| @domain.tech_contacts.each do |tc|
xml.tag!('domain:contact', tc.code, 'type' => 'tech') xml.tag!('domain:contact', tc.code, 'type' => 'tech')

View file

@ -1,6 +1,6 @@
Tere Tere
<br><br> <br><br>
Domeeni <%= @domain.name %> kustutamise taotlust ei kinnitatud tähtaegselt registreerija <%= @domain.registrant_name %> poolt. Domeeni <%= @domain.name %> kustutamine on sellest tulenevalt tühistatud. Domeeni <%= @domain.name %> kustutamise taotlust ei kinnitatud tähtaegselt registreerija <%= @domain.registrant.name %> poolt. Domeeni <%= @domain.name %> kustutamine on sellest tulenevalt tühistatud.
<br><br> <br><br>
Lugupidamisega<br> Lugupidamisega<br>
Eesti Interneti Sihtasutus Eesti Interneti Sihtasutus
@ -9,7 +9,7 @@ Eesti Interneti Sihtasutus
<br><br> <br><br>
Hi, Hi,
<br><br> <br><br>
Domain <%= @domain.name %> deletion was not approved in time by the registrant <%= @domain.registrant_name %>. Thus the deletion of domain <%= @domain.name %> is cancelled. Domain <%= @domain.name %> deletion was not approved in time by the registrant <%= @domain.registrant.name %>. Thus the deletion of domain <%= @domain.name %> is cancelled.
<br><br> <br><br>
Best Regards,<br> Best Regards,<br>
Estonian Internet Foundation Estonian Internet Foundation

View file

@ -1,6 +1,6 @@
Tere Tere
Domeeni <%= @domain.name %> kustutamise taotlust ei kinnitatud tähtaegselt registreerija <%= @domain.registrant_name %> poolt. Domeeni <%= @domain.name %> kustutamine on sellest tulenevalt tühistatud. Domeeni <%= @domain.name %> kustutamise taotlust ei kinnitatud tähtaegselt registreerija <%= @domain.registrant.name %> poolt. Domeeni <%= @domain.name %> kustutamine on sellest tulenevalt tühistatud.
Lugupidamisega Lugupidamisega
Eesti Interneti Sihtasutus Eesti Interneti Sihtasutus
@ -9,7 +9,7 @@ Eesti Interneti Sihtasutus
Hi, Hi,
Domain <%= @domain.name %> deletion was not approved in time by the registrant <%= @domain.registrant_name %>. Thus the deletion of domain <%= @domain.name %> is cancelled. Domain <%= @domain.name %> deletion was not approved in time by the registrant <%= @domain.registrant.name %>. Thus the deletion of domain <%= @domain.name %> is cancelled.
Best Regards, Best Regards,
Estonian Internet Foundation Estonian Internet Foundation

View file

@ -1,6 +1,6 @@
Tere Tere
<br><br> <br><br>
Domeeni <%= @domain.name %> kustutamise taotlus on registreerija <%= @domain.registrant_name %> poolt tagasi lükatud. Domeeni <%= @domain.name %> kustutamise taotlus on registreerija <%= @domain.registrant.name %> poolt tagasi lükatud.
<br><br> <br><br>
Lugupidamisega<br> Lugupidamisega<br>
Eesti Interneti Sihtasutus Eesti Interneti Sihtasutus
@ -9,7 +9,7 @@ Eesti Interneti Sihtasutus
<br><br> <br><br>
Hi, Hi,
<br><br> <br><br>
Domain <%= @domain.name %> deletion was rejected by the registrant <%= @domain.registrant_name %>. Domain <%= @domain.name %> deletion was rejected by the registrant <%= @domain.registrant.name %>.
<br><br> <br><br>
Best Regards,<br> Best Regards,<br>
Estonian Internet Foundation Estonian Internet Foundation

View file

@ -1,6 +1,6 @@
Tere Tere
Domeeni <%= @domain.name %> kustutamise taotlus on registreerija <%= @domain.registrant_name %> poolt tagasi lükatud. Domeeni <%= @domain.name %> kustutamise taotlus on registreerija <%= @domain.registrant.name %> poolt tagasi lükatud.
Lugupidamisega Lugupidamisega
Eesti Interneti Sihtasutus Eesti Interneti Sihtasutus
@ -9,7 +9,7 @@ Eesti Interneti Sihtasutus
Hi, Hi,
Domain <%= @domain.name %> deletion was rejected by the registrant <%= @domain.registrant_name %>. Domain <%= @domain.name %> deletion was rejected by the registrant <%= @domain.registrant.name %>.
Best Regards, Best Regards,
Estonian Internet Foundation Estonian Internet Foundation

View file

@ -29,7 +29,7 @@
%p= t('.registrant') + ':' %p= t('.registrant') + ':'
.column-values .column-values
%p= @domain.name %p= @domain.name
%p= "#{@domain.registrant_name} (#{@domain.registrant.ident})" %p= "#{@domain.registrant.name} (#{@domain.registrant.ident})"
.row .row
.col-md-12.text-center .col-md-12.text-center

View file

@ -30,7 +30,7 @@
%p= t(:new_pending_registrant) + ':' %p= t(:new_pending_registrant) + ':'
.column-values .column-values
%p= @domain.name %p= @domain.name
%p= "#{@domain.registrant_name} (#{@domain.registrant.ident})" %p= "#{@domain.registrant.name} (#{@domain.registrant.ident})"
%p= "#{@domain.pending_registrant.try(:name)} (#{@domain.pending_registrant.try(:ident)})" %p= "#{@domain.pending_registrant.try(:name)} (#{@domain.pending_registrant.try(:ident)})"
.row .row

View file

@ -81,9 +81,8 @@ RSpec.describe DomainPresenter do
domain_delegatable_attributes = %i( domain_delegatable_attributes = %i(
name name
transfer_code transfer_code
registrant_name registrant
registrant_id registrant_id
registrant_code
) )
domain_delegatable_attributes.each do |attribute_name| domain_delegatable_attributes.each do |attribute_name|

View file

@ -46,7 +46,7 @@ RSpec.describe 'EPP domain:update' do
end end
it 'keeps same registrant' do it 'keeps same registrant' do
expect { request; domain.reload }.to_not change { domain.registrant_code } expect { request; domain.reload }.to_not change { domain.registrant.code }
end end
it 'does not ask for confirmation' do it 'does not ask for confirmation' do
@ -91,7 +91,7 @@ RSpec.describe 'EPP domain:update' do
end end
it 'does not change registrant without confirmation' do it 'does not change registrant without confirmation' do
expect { request; domain.reload }.to_not change { domain.registrant_code } expect { request; domain.reload }.to_not change { domain.registrant.code }
end end
it 'asks for confirmation' do it 'asks for confirmation' do
@ -147,7 +147,7 @@ RSpec.describe 'EPP domain:update' do
end end
it 'keeps same registrant' do it 'keeps same registrant' do
expect { request; domain.reload }.to_not change { domain.registrant_code } expect { request; domain.reload }.to_not change { domain.registrant.code }
end end
it 'does not ask for confirmation' do it 'does not ask for confirmation' do
@ -192,7 +192,7 @@ RSpec.describe 'EPP domain:update' do
end end
it 'changes registrant without confirmation' do it 'changes registrant without confirmation' do
expect { request; domain.reload }.to change { domain.registrant_code }.from('OLD-CODE').to('NEW-CODE') expect { request; domain.reload }.to change { domain.registrant.code }.from('OLD-CODE').to('NEW-CODE')
end end
it 'does not ask for confirmation' do it 'does not ask for confirmation' do

View file

@ -47,7 +47,7 @@ RSpec.describe 'EPP domain:update' do
end end
it 'changes registrant' do it 'changes registrant' do
expect { request; domain.reload }.to change { domain.registrant_code }.from('old-code').to('new-code') expect { request; domain.reload }.to change { domain.registrant.code }.from('old-code').to('new-code')
end end
it 'does not send confirmation email' do it 'does not send confirmation email' do
@ -90,7 +90,7 @@ RSpec.describe 'EPP domain:update' do
end end
it 'does not change registrant' do it 'does not change registrant' do
expect { request; domain.reload }.to_not change { domain.registrant_code } expect { request; domain.reload }.to_not change { domain.registrant.code }
end end
it 'sends confirmation and notice emails' do it 'sends confirmation and notice emails' do
@ -139,7 +139,7 @@ RSpec.describe 'EPP domain:update' do
end end
it 'changes registrant' do it 'changes registrant' do
expect { request; domain.reload }.to change { domain.registrant_code }.from('old-code').to('new-code') expect { request; domain.reload }.to change { domain.registrant.code }.from('old-code').to('new-code')
end end
it 'does not send confirmation email' do it 'does not send confirmation email' do
@ -182,7 +182,7 @@ RSpec.describe 'EPP domain:update' do
end end
it 'changes registrant' do it 'changes registrant' do
expect { request; domain.reload }.to change { domain.registrant_code }.from('old-code').to('new-code') expect { request; domain.reload }.to change { domain.registrant.code }.from('old-code').to('new-code')
end end
it 'does not send confirmation email' do it 'does not send confirmation email' do