From 410914e16ebf3d0aacf13698ed3e39cd6e687c91 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Wed, 3 Jun 2015 10:06:40 +0300 Subject: [PATCH 1/2] Contact change notification email content update #2558 --- app/models/contact.rb | 18 +++++++++++++++++ .../contact_mailer/email_updated.html.erb | 12 ++++++----- .../contact_mailer/email_updated.text.erb | 14 +++++++------ spec/models/contact_spec.rb | 20 +++++++++++++++++++ 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 5cbc6ac53..f2de0a4fd 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -7,6 +7,7 @@ class Contact < ActiveRecord::Base has_many :domains, through: :domain_contacts has_many :statuses, class_name: 'ContactStatus', dependent: :destroy has_many :legal_documents, as: :documentable + has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id' # when contant is registrant accepts_nested_attributes_for :legal_documents @@ -184,4 +185,21 @@ class Contact < ActiveRecord::Base errors.add(:ident, :invalid_country_code) end end + + def related_domain_descriptions + @desc = {} + + registrant_domains.each do |dom| + @desc[dom.name] ||= [] + @desc[dom.name] << :registrant + end + + domain_contacts.each do |dc| + @desc[dc.domain.name] ||= [] + @desc[dc.domain.name] << dc.name.downcase.to_sym + @desc[dc.domain.name] = @desc[dc.domain.name].compact + end + + @desc + end end diff --git a/app/views/contact_mailer/email_updated.html.erb b/app/views/contact_mailer/email_updated.html.erb index c461659b1..438bbdbb5 100644 --- a/app/views/contact_mailer/email_updated.html.erb +++ b/app/views/contact_mailer/email_updated.html.erb @@ -6,10 +6,10 @@ uus aadress: <%= @contact.email %>

Eposti aadressile saadetakse domeenidega seotud infot seal hulgas kinnitustaotluseid omaniku vahetuse ja domeeni kustutamise korral. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduga oma registripidaja poole. Teie registripidaja on <%= @contact.registrar.name %>

-<% if @contact.domain_contacts.present? %> +<% if @contact.related_domain_descriptions.present? %> Muudatusega seotud domeenid:
-<% @contact.domain_contacts.each do |dc| %> - <%= dc.domain.name %> (<%= dc.name %>)
+<% @contact.related_domain_descriptions.each do |domain, desc| %> + <%= domain %> (<%= desc.map { |d| t(:d) }.join(', ') %>)
<% end %> <% end %>
@@ -35,9 +35,11 @@ new address: <% @contact.email %>

E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @contact.registrar.name %>

+<% if @contact.related_domain_descriptions.present? %> Domains affected by this update:
-<% @contact.domain_contacts.each do |dc| %> - <%= dc.domain.name %> (<%= dc.name %>)
+<% @contact.related_domain_descriptions.each do |domain, desc| %> + <%= domain %> (<%= desc.map { |d| t(:d) }.join(', ') %>)
+<% end %> <% end %>
Contact information:
diff --git a/app/views/contact_mailer/email_updated.text.erb b/app/views/contact_mailer/email_updated.text.erb index 5d70bca79..a304c5c66 100644 --- a/app/views/contact_mailer/email_updated.text.erb +++ b/app/views/contact_mailer/email_updated.text.erb @@ -6,11 +6,11 @@ uus aadress: <%= @contact.email %> Eposti aadressile saadetakse domeenidega seotud infot seal hulgas kinnitustaotluseid omaniku vahetuse ja domeeni kustutamise korral. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduga oma registripidaja poole. Teie registripidaja on <%= @contact.registrar.name %> -<% if @contact.domain_contacts.present? %> +<% if @contact.related_domain_descriptions.present? %> Muudatusega seotud domeenid: -<% @contact.domain_contacts.each do |dc| %> - <%= dc.domain.name %> (<%= dc.name %>) -<% end %> + <% @contact.related_domain_descriptions.each do |domain, desc| %> + <%= domain %> (<%= desc.map { |d| t(:d) }.join(', ') %>) + <% end %> <% end %> Kontaktandmed: @@ -35,9 +35,11 @@ new address: <% @contact.email %> E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @contact.registrar.name %> +<% if @contact.related_domain_descriptions.present? %> Domains affected by this update: -<% @contact.domain_contacts.each do |dc| %> - <%= dc.domain.name %> (<%= dc.name %>) + <% @contact.related_domain_descriptions.each do |domain, desc| %> + <%= domain %> (<%= desc.map { |d| t(:d) }.join(', ') %>) + <% end %> <% end %> Contact information: diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 107f72106..86fe6fc90 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -99,6 +99,10 @@ describe Contact do @contact.valid? @contact.errors[:code].should == ['is too long (maximum is 100 characters)'] end + + it 'should have no related domain descriptions' do + @contact.related_domain_descriptions.should == {} + end end context 'with valid attributes' do @@ -189,6 +193,22 @@ describe Contact do # contact.statuses.map(&:value).should == %w(ok linked) end + context 'as birthday' do + before do + @domain = Fabricate(:domain) + end + + it 'should have related domain descriptions hash' do + contact = @domain.registrant + contact.related_domain_descriptions.should == { "#{@domain.name}" => [:registrant] } + end + + it 'should have related domain descriptions hash' do + contact = @domain.contacts.first + contact.related_domain_descriptions.should == { "#{@domain.name}" => [:admin] } + end + end + context 'as birthday' do before :all do @contact.ident_type = 'birthday' From 245bcf2b6bb85f2a9bdea57a97851b96d9286291 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Wed, 3 Jun 2015 10:39:07 +0300 Subject: [PATCH 2/2] Add contact email translations #2558 --- app/views/contact_mailer/email_updated.html.erb | 4 ++-- app/views/contact_mailer/email_updated.text.erb | 4 ++-- config/locales/en.yml | 2 ++ config/locales/et.yml | 3 +++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/views/contact_mailer/email_updated.html.erb b/app/views/contact_mailer/email_updated.html.erb index 438bbdbb5..e4785444b 100644 --- a/app/views/contact_mailer/email_updated.html.erb +++ b/app/views/contact_mailer/email_updated.html.erb @@ -9,7 +9,7 @@ Eposti aadressile saadetakse domeenidega seotud infot seal hulgas kinnitustaotlu <% if @contact.related_domain_descriptions.present? %> Muudatusega seotud domeenid:
<% @contact.related_domain_descriptions.each do |domain, desc| %> - <%= domain %> (<%= desc.map { |d| t(:d) }.join(', ') %>)
+ <%= domain %> (<%= desc.map { |d| t(d, locale: :et) }.join(', ') %>)
<% end %> <% end %>
@@ -38,7 +38,7 @@ E-mail addresses are used to send important information regarding your registere <% if @contact.related_domain_descriptions.present? %> Domains affected by this update:
<% @contact.related_domain_descriptions.each do |domain, desc| %> - <%= domain %> (<%= desc.map { |d| t(:d) }.join(', ') %>)
+ <%= domain %> (<%= desc.map { |d| t(d, locale: :en) }.join(', ') %>)
<% end %> <% end %>
diff --git a/app/views/contact_mailer/email_updated.text.erb b/app/views/contact_mailer/email_updated.text.erb index a304c5c66..61d875351 100644 --- a/app/views/contact_mailer/email_updated.text.erb +++ b/app/views/contact_mailer/email_updated.text.erb @@ -9,7 +9,7 @@ Eposti aadressile saadetakse domeenidega seotud infot seal hulgas kinnitustaotlu <% if @contact.related_domain_descriptions.present? %> Muudatusega seotud domeenid: <% @contact.related_domain_descriptions.each do |domain, desc| %> - <%= domain %> (<%= desc.map { |d| t(:d) }.join(', ') %>) + <%= domain %> (<%= desc.map { |d| t(d, locale: :et) }.join(', ') %>) <% end %> <% end %> @@ -38,7 +38,7 @@ E-mail addresses are used to send important information regarding your registere <% if @contact.related_domain_descriptions.present? %> Domains affected by this update: <% @contact.related_domain_descriptions.each do |domain, desc| %> - <%= domain %> (<%= desc.map { |d| t(:d) }.join(', ') %>) + <%= domain %> (<%= desc.map { |d| t(d, locale: :en) }.join(', ') %>) <% end %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 954e89eeb..9203bf6ff 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -810,3 +810,5 @@ en: invalid_csr_or_crt: 'Invalid CSR or CRT' webserver_missing_client_cert_directive: 'Webserver missing client cert directive' webserver_client_cert_directive_should_be_required: 'Webserver client cert directive should be required' + tech: Tech contact + admin: Admin contact diff --git a/config/locales/et.yml b/config/locales/et.yml index 37e1e9dea..2e56c701f 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -2,3 +2,6 @@ et: username: 'Kasutajanimi' password: 'Parool' log_in: 'Logi sisse' + registrant: 'Registreerija' + tech: Tehniline kontakt + admin: Halduskontakt