From 58e35d5683e412bada6a98a4ea263e07790feef6 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 1 Dec 2015 15:01:35 +0200 Subject: [PATCH 01/98] 108868838-new_method_and_templates --- app/mailers/domain_mailer.rb | 12 ++++ app/models/domain.rb | 1 + .../expiration_reminder.html.erb | 72 +++++++++++++++++++ .../expiration_reminder.text.erb | 72 +++++++++++++++++++ config/locales/en.yml | 1 + 5 files changed, 158 insertions(+) create mode 100644 app/views/mailers/domain_mailer/expiration_reminder.html.erb create mode 100644 app/views/mailers/domain_mailer/expiration_reminder.text.erb diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 7fe92130b..979da1d52 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -176,6 +176,18 @@ class DomainMailer < ApplicationMailer name: @domain.name)} [#{@domain.name}]") end + def expiration_reminder(domain_id, should_deliver) + @domain = Domain.find_by(id: domain_id) + return unless @domain + return if delivery_off?(@domain, should_deliver) + + return if whitelist_blocked?(@domain.registrant.email) + mail(to: format(@domain.registrant.email), + subject: "#{I18n.t(:expiration_remind_subject, + name: @domain.name)} [#{@domain.name}]") + end + + def force_delete(domain_id, should_deliver) @domain = Domain.find_by(id: domain_id) return if delivery_off?(@domain, should_deliver) diff --git a/app/models/domain.rb b/app/models/domain.rb index 64b7ff5a6..9664e4f26 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -263,6 +263,7 @@ class Domain < ActiveRecord::Base domains.each do |domain| next unless domain.expirable? domain.set_graceful_expired + DomainMailer.expiration_reminder(domain.id, deliver_emails).deliver STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? domain.save end diff --git a/app/views/mailers/domain_mailer/expiration_reminder.html.erb b/app/views/mailers/domain_mailer/expiration_reminder.html.erb new file mode 100644 index 000000000..61ecccd90 --- /dev/null +++ b/app/views/mailers/domain_mailer/expiration_reminder.html.erb @@ -0,0 +1,72 @@ +Domeen <%= @domain.name %> on aegunud +Lugupeetud .ee domeeni kasutaja + +Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates [% outzonedate %] internetis kättesaadav. Alates [% deletedate %] on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. + +Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja [% registrar %] poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. + +Domeeni <%= @domain.name %> kohta on registris järgmised andmed: + +Registreerija: [% registrant %] +[% haldus_est_html %] Tehniline kontakt: [% %] +Registripidaja: [% registrar %] +Nimeserverid: [% %] +Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. http://eedirekt.internet.ee/registrant. + +Parimate soovidega + +Eesti Interneti Sihtasutus +Paldiski mnt 80, 10617 Tallinn +Registrikood: 90010019 +E-post: info@internet.ee +Tel: +372 727 1000 +

+
+

+The <%= @domain.name %> domain has expired +Dear user of .ee domain, + +The domain name <%= @domain.name %> has expired and will not be available on the Internet from [% outzonedate %]. From [% deletedate %], the <%= @domain.name %> domain will be available for registration on a first come first served basis. + +To renew the domain registration, please contact your registrar [% registrar %]. You can find the registrar's contacts at http://www.internet.ee/en/registripidajad/. + +The following data for the <%= @domain.name %> domain have been entered into the registry: + +Registrant: [% registrant %] +[% haldus_eng_html %] Technical contact: [% %] +Registrar: [% registrar %] +Name servers: [% %] +You can find an overview of all your domains at the registrant's portal. http://eedirekt.internet.ee/registrant. + +Sincerely + +Estonian Internet Foundation +Paldiski mnt 80, 10617 Tallinn +Business Registry no: 90010019 +E-mail: info@internet.ee +Phone: +372 727 1000 + +-------------------------------------- + +Домен <%= @domain.name %> устарел +Уважаемый пользователь домена .ee + +Доменное имя <%= @domain.name %> устарело и с [% outzonedate %] недоступно в Интернете. С [% deletedate %] домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". + +Для продления регистрации домена просим обратиться к своему регистратору [% registrar %]. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/. + +Относительно домена <%= @domain.name %> в реестр внесены следующие данные: + +Регистрант: [% registrant %] +[% haldus_rus_html %] Технический контакт: [% %] +Регистратор: [% registrar %] +Серверы доменных имен: [% %] +Обзор всех связанных с Вами доменов можете получить на портале регистранта. http://eedirekt.internet.ee/registrant. + +С наилучшими пожеланиями + +Целевое учреждение Eesti Internet +Paldiski mnt 80, 10617 Tallinn +Регистрационный код: 90010019 +Э-почта: info@internet.ee +Тел.: +372 727 1000 \ No newline at end of file diff --git a/app/views/mailers/domain_mailer/expiration_reminder.text.erb b/app/views/mailers/domain_mailer/expiration_reminder.text.erb new file mode 100644 index 000000000..258dff655 --- /dev/null +++ b/app/views/mailers/domain_mailer/expiration_reminder.text.erb @@ -0,0 +1,72 @@ +Domeen <%= @domain.name %> on aegunud +Lugupeetud .ee domeeni kasutaja + +Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= @domain.outzone_at %> internetis kättesaadav. Alates <%= @domain.delete_at %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. + +Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @domain.registrar %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. + +Domeeni <%= @domain.name %> kohta on registris järgmised andmed: + +Registreerija: <%= @domain.registrant %> +[% haldus_est_html %] Tehniline kontakt: <%= @domain.tech_domain_contacts %> +Registripidaja: <%= @domain.registrar %> +Nimeserverid: <%= @domain.nameservers %> +Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. http://eedirekt.internet.ee/registrant. + +Parimate soovidega + +Eesti Interneti Sihtasutus +Paldiski mnt 80, 10617 Tallinn +Registrikood: 90010019 +E-post: info@internet.ee +Tel: +372 727 1000 + +-------------------------------------- + +The <%= @domain.name %> domain has expired +Dear user of .ee domain, + +The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= @domain.outzone_at %>. From <%= @domain.delete_at %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. + +To renew the domain registration, please contact your registrar <%= @domain.registrar %>. You can find the registrar's contacts at http://www.internet.ee/en/registripidajad/. + +The following data for the <%= @domain.name %> domain have been entered into the registry: + +Registrant: <%= @domain.registrant %> +[% haldus_eng_html %] Technical contact: <%= @domain.tech_domain_contacts %> +Registrar: <%= @domain.registrar %> +Name servers: <%= @domain.nameservers %> +You can find an overview of all your domains at the registrant's portal. http://eedirekt.internet.ee/registrant. + +Sincerely + +Estonian Internet Foundation +Paldiski mnt 80, 10617 Tallinn +Business Registry no: 90010019 +E-mail: info@internet.ee +Phone: +372 727 1000 + +-------------------------------------- + +Домен <%= @domain.name %> устарел +Уважаемый пользователь домена .ee + +Доменное имя <%= @domain.name %> устарело и с <%= @domain.outzone_at %> недоступно в Интернете. С <%= @domain.delete_at %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". + +Для продления регистрации домена просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/. + +Относительно домена <%= @domain.name %> в реестр внесены следующие данные: + +Регистрант: <%= @domain.registrant %> +[% haldus_rus_html %] Технический контакт: <%= @domain.tech_domain_contacts %> +Регистратор: <%= @domain.registrar %> +Серверы доменных имен: <%= @domain.nameservers %> +Обзор всех связанных с Вами доменов можете получить на портале регистранта. http://eedirekt.internet.ee/registrant. + +С наилучшими пожеланиями + +Целевое учреждение Eesti Internet +Paldiski mnt 80, 10617 Tallinn +Регистрационный код: 90010019 +Э-почта: info@internet.ee +Тел.: +372 727 1000 \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 07f4ebc0a..16e643b16 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -925,3 +925,4 @@ en: list_format_is_in_yaml: 'List format is in YAML' if_auth_info_is_left_empty_it_will_be_auto_generated: 'If auth info is left empty, it will be auto generated.' each_domain_name_must_end_with_colon_sign: 'Each domain name must end with colon (:) sign.' + expiration_remind_subject: 'The %{name} domain has expired' From 3169d6c32568654306693407137de1c2b063eef5 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 1 Dec 2015 15:33:59 +0200 Subject: [PATCH 02/98] 108868838-logic_update --- app/mailers/domain_mailer.rb | 4 +--- app/models/domain.rb | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 979da1d52..3788dd510 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -176,11 +176,9 @@ class DomainMailer < ApplicationMailer name: @domain.name)} [#{@domain.name}]") end - def expiration_reminder(domain_id, should_deliver) + def expiration_reminder(domain_id) @domain = Domain.find_by(id: domain_id) return unless @domain - return if delivery_off?(@domain, should_deliver) - return if whitelist_blocked?(@domain.registrant.email) mail(to: format(@domain.registrant.email), subject: "#{I18n.t(:expiration_remind_subject, diff --git a/app/models/domain.rb b/app/models/domain.rb index 9664e4f26..06a108f72 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -263,7 +263,7 @@ class Domain < ActiveRecord::Base domains.each do |domain| next unless domain.expirable? domain.set_graceful_expired - DomainMailer.expiration_reminder(domain.id, deliver_emails).deliver + DomainMailer.expiration_reminder(domain.id).deliver STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? domain.save end From c3d675cedca43d6cea1c5341949f5982c44a0bf2 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 2 Dec 2015 12:09:04 +0200 Subject: [PATCH 03/98] mailer variable fix --- app/models/domain.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index cc35807d5..b190f7936 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -241,7 +241,7 @@ class Domain < ActiveRecord::Base DomainMailer.pending_update_expired_notification_for_new_registrant(domain.id).deliver end if domain.pending_delete? || domain.pending_delete_confirmation? - DomainMailer.pending_delete_expired_notification(domain.id, deliver_emails).deliver + DomainMailer.pending_delete_expired_notification(domain.id, true).deliver end domain.clean_pendings! unless Rails.env.test? From a6100298f0341c3a3330dba4ee8a9e1e1f51576a Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 2 Dec 2015 12:25:20 +0200 Subject: [PATCH 04/98] Story#109317508 commented sending email to registrant em email change --- app/models/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 7ebfaf684..f5a177eef 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -48,7 +48,7 @@ class Contact < ActiveRecord::Base return nil unless deliver_emails == true emails = [] emails << [email, email_was] - emails << domains.map(&:registrant_email) if domains.present? + # emails << domains.map(&:registrant_email) if domains.present? emails = emails.flatten.uniq emails.each do |e| ContactMailer.email_updated(email_was, e, id, deliver_emails).deliver From 2dd2b7e1e1093269ac6ccb70c6a9b27b5c89c5ea Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 2 Dec 2015 17:27:19 +0200 Subject: [PATCH 05/98] 108868838-templates --- .../expiration_reminder.html.erb | 133 +++++++++--------- .../expiration_reminder.text.erb | 39 ++--- 2 files changed, 89 insertions(+), 83 deletions(-) diff --git a/app/views/mailers/domain_mailer/expiration_reminder.html.erb b/app/views/mailers/domain_mailer/expiration_reminder.html.erb index 61ecccd90..63c08b1d2 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.html.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.html.erb @@ -1,72 +1,75 @@ -Domeen <%= @domain.name %> on aegunud -Lugupeetud .ee domeeni kasutaja - -Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates [% outzonedate %] internetis kättesaadav. Alates [% deletedate %] on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. - -Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja [% registrar %] poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. - +Domeen <%= @domain.name %> on aegunud
+Lugupeetud .ee domeeni kasutaja
+
+Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :short) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :short) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. +

+Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @domain.registrar.name %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. +

Domeeni <%= @domain.name %> kohta on registris järgmised andmed: - -Registreerija: [% registrant %] -[% haldus_est_html %] Tehniline kontakt: [% %] -Registripidaja: [% registrar %] -Nimeserverid: [% %] -Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. http://eedirekt.internet.ee/registrant. - +

+Registreerija: <%= @domain.registrant_name %>
+Halduskontakt: [% haldus_est_html %]
+Tehniline kontakt: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %>
+Registripidaja: <%= @domain.registrar.name %>
+Nimeserverid: <%= @domain.nameservers.join(', ') %>
+Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. http://eedirekt.internet.ee/registrant.
+

Parimate soovidega - -Eesti Interneti Sihtasutus -Paldiski mnt 80, 10617 Tallinn -Registrikood: 90010019 -E-post: info@internet.ee -Tel: +372 727 1000 +

+Eesti Interneti Sihtasutus
+Paldiski mnt 80, 10617 Tallinn
+Registrikood: 90010019
+E-post: info@internet.ee
+Tel: +372 727 1000





-The <%= @domain.name %> domain has expired -Dear user of .ee domain, - -The domain name <%= @domain.name %> has expired and will not be available on the Internet from [% outzonedate %]. From [% deletedate %], the <%= @domain.name %> domain will be available for registration on a first come first served basis. - -To renew the domain registration, please contact your registrar [% registrar %]. You can find the registrar's contacts at http://www.internet.ee/en/registripidajad/. - -The following data for the <%= @domain.name %> domain have been entered into the registry: - -Registrant: [% registrant %] -[% haldus_eng_html %] Technical contact: [% %] -Registrar: [% registrar %] -Name servers: [% %] -You can find an overview of all your domains at the registrant's portal. http://eedirekt.internet.ee/registrant. - +The <%= @domain.name %> domain has expired
+Dear user of .ee domain,
+
+The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :short) %>. From <%= l(@domain.delete_at, format: :short) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. +

+To renew the domain registration, please contact your registrar <%= @domain.registrar.name %>. You can find the registrar's contacts at http://www.internet.ee/en/registripidajad/. +

+The following data for the <%= @domain.name %> domain have been entered into the registry: +

+Registrant: <%= @domain.registrant_name %>
+Administrative contact: [% haldus_eng_html %]
+Technical contact: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %>
+Registrar: <%= @domain.registrar.name %>
+Name servers: <%= @domain.nameservers.join(', ') %>
+You can find an overview of all your domains at the registrant's portal. http://eedirekt.internet.ee/registrant.
+

Sincerely - -Estonian Internet Foundation -Paldiski mnt 80, 10617 Tallinn -Business Registry no: 90010019 -E-mail: info@internet.ee -Phone: +372 727 1000 - --------------------------------------- - -Домен <%= @domain.name %> устарел -Уважаемый пользователь домена .ee - -Доменное имя <%= @domain.name %> устарело и с [% outzonedate %] недоступно в Интернете. С [% deletedate %] домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". - -Для продления регистрации домена просим обратиться к своему регистратору [% registrar %]. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/. - -Относительно домена <%= @domain.name %> в реестр внесены следующие данные: - -Регистрант: [% registrant %] -[% haldus_rus_html %] Технический контакт: [% %] -Регистратор: [% registrar %] -Серверы доменных имен: [% %] -Обзор всех связанных с Вами доменов можете получить на портале регистранта. http://eedirekt.internet.ee/registrant. - +

+Estonian Internet Foundation
+Paldiski mnt 80, 10617 Tallinn
+Business Registry no: 90010019
+E-mail: info@internet.ee
+Phone: +372 727 1000
+

+
+

+Домен <%= @domain.name %> устарел
+Уважаемый пользователь домена .ee
+
+Доменное имя <%= @domain.name %> устарело и с <%= l(@domain.outzone_at, format: :short) %> недоступно в Интернете. С <%= l(@domain.delete_at, format: :short) %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". +

+Для продления регистрации домена просим обратиться к своему регистратору <%= @domain.registrar.name %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/. +

+Относительно домена <%= @domain.name %> в реестр внесены следующие данные: +

+Регистрант: <%= @domain.registrant_name %>
+Административный контакт: [% haldus_rus_html %]
+Технический контакт: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %>
+Регистратор: <%= @domain.registrar.name %>
+Серверы доменных имен: <%= @domain.nameservers.join(', ') %>
+Обзор всех связанных с Вами доменов можете получить на портале регистранта. http://eedirekt.internet.ee/registrant.
+

С наилучшими пожеланиями - -Целевое учреждение Eesti Internet -Paldiski mnt 80, 10617 Tallinn -Регистрационный код: 90010019 -Э-почта: info@internet.ee -Тел.: +372 727 1000 \ No newline at end of file +

+Целевое учреждение Eesti Internet
+Paldiski mnt 80, 10617 Tallinn
+Регистрационный код: 90010019
+Э-почта: info@internet.ee
+Тел.: +372 727 1000
\ No newline at end of file diff --git a/app/views/mailers/domain_mailer/expiration_reminder.text.erb b/app/views/mailers/domain_mailer/expiration_reminder.text.erb index 258dff655..aa4d1754d 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.text.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.text.erb @@ -1,16 +1,17 @@ Domeen <%= @domain.name %> on aegunud Lugupeetud .ee domeeni kasutaja -Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= @domain.outzone_at %> internetis kättesaadav. Alates <%= @domain.delete_at %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. +Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :short) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :short) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. -Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @domain.registrar %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. +Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @domain.registrar.name %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. Domeeni <%= @domain.name %> kohta on registris järgmised andmed: -Registreerija: <%= @domain.registrant %> -[% haldus_est_html %] Tehniline kontakt: <%= @domain.tech_domain_contacts %> -Registripidaja: <%= @domain.registrar %> -Nimeserverid: <%= @domain.nameservers %> +Registreerija: <%= @domain.registrant_name %> +Halduskontakt: [% haldus_est_html %] +Tehniline kontakt: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %> +Registripidaja: <%= @domain.registrar.name %> +Nimeserverid: <%= @domain.nameservers.join(', ') %> Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. http://eedirekt.internet.ee/registrant. Parimate soovidega @@ -26,16 +27,17 @@ Tel: +372 727 1000 The <%= @domain.name %> domain has expired Dear user of .ee domain, -The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= @domain.outzone_at %>. From <%= @domain.delete_at %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. +The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :short) %>. From <%= l(@domain.delete_at, format: :short) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. -To renew the domain registration, please contact your registrar <%= @domain.registrar %>. You can find the registrar's contacts at http://www.internet.ee/en/registripidajad/. +To renew the domain registration, please contact your registrar <%= @domain.registrar.name %>. You can find the registrar's contacts at http://www.internet.ee/en/registripidajad/. The following data for the <%= @domain.name %> domain have been entered into the registry: -Registrant: <%= @domain.registrant %> -[% haldus_eng_html %] Technical contact: <%= @domain.tech_domain_contacts %> -Registrar: <%= @domain.registrar %> -Name servers: <%= @domain.nameservers %> +Registrant: <%= @domain.registrant_name %> +Administrative contact: [% haldus_eng_html %] +Technical contact: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %> +Registrar: <%= @domain.registrar.name %> +Name servers: <%= @domain.nameservers.join(', ') %> You can find an overview of all your domains at the registrant's portal. http://eedirekt.internet.ee/registrant. Sincerely @@ -51,16 +53,17 @@ Phone: +372 727 1000 Домен <%= @domain.name %> устарел Уважаемый пользователь домена .ee -Доменное имя <%= @domain.name %> устарело и с <%= @domain.outzone_at %> недоступно в Интернете. С <%= @domain.delete_at %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". +Доменное имя <%= @domain.name %> устарело и с <%= l(@domain.outzone_at, format: :short) %> недоступно в Интернете. С <%= l(@domain.delete_at, format: :short) %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". -Для продления регистрации домена просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/. +Для продления регистрации домена просим обратиться к своему регистратору <%= @domain.registrar.name %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/. Относительно домена <%= @domain.name %> в реестр внесены следующие данные: -Регистрант: <%= @domain.registrant %> -[% haldus_rus_html %] Технический контакт: <%= @domain.tech_domain_contacts %> -Регистратор: <%= @domain.registrar %> -Серверы доменных имен: <%= @domain.nameservers %> +Регистрант: <%= @domain.registrant_name %> +Административный контакт: [% haldus_rus_html %] +Технический контакт: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %> +Регистратор: <%= @domain.registrar.name %> +Серверы доменных имен: <%= @domain.nameservers.join(', ') %> Обзор всех связанных с Вами доменов можете получить на портале регистранта. http://eedirekt.internet.ee/registrant. С наилучшими пожеланиями From cbf5ac137dcca7dc8c1c139112010aeb6b2275c8 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 2 Dec 2015 17:30:35 +0200 Subject: [PATCH 06/98] 109228160-date_logic_changed --- app/models/domain.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index cc35807d5..2d68ca27c 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -392,7 +392,7 @@ class Domain < ActiveRecord::Base end def delete_candidateable? - return false if delete_at > Time.zone.now + return false if valid_to.to_date > Date.today return false if statuses.include?(DomainStatus::DELETE_CANDIDATE) return false if statuses.include?(DomainStatus::SERVER_DELETE_PROHIBITED) true From a341eff35ac56bf3d7120070b77f4c66d60dc40d Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 2 Dec 2015 17:32:57 +0200 Subject: [PATCH 07/98] 109228160-typo --- app/models/domain.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 2d68ca27c..a08397d81 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -392,7 +392,7 @@ class Domain < ActiveRecord::Base end def delete_candidateable? - return false if valid_to.to_date > Date.today + return false if delete_at.to_date > Date.today return false if statuses.include?(DomainStatus::DELETE_CANDIDATE) return false if statuses.include?(DomainStatus::SERVER_DELETE_PROHIBITED) true From 70252f9f87aabb11d4677b0065d3136ad72d43cc Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 12:58:11 +0200 Subject: [PATCH 08/98] Story #109367694 - changed xml text for elements crID, clID and upID --- app/views/epp/contacts/info.xml.builder | 12 +++++------- app/views/epp/domains/info.xml.builder | 13 ++++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 18019208a..3790544e1 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -46,15 +46,13 @@ xml.epp_head do xml.tag!('contact:email', 'No access') end - xml.tag!('contact:clID', @contact.registrar.try(:name)) - if @contact.creator.try(:registrar).blank? && Rails.env.test? - xml.tag!('contact:crID', 'TEST-CREATOR') - else - xml.tag!('contact:crID', @contact.creator.try(:registrar)) - end + xml.tag!('contact:clID', @contact.registrar.try(:code)) + + xml.tag!('contact:crID', @contact.creator.registrar.try(:code)) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) + if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.try(:registrar)) + xml.tag!('contact:upID', @contact.updator.registrar.code) xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 9e1779921..fd6bfeeb6 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -36,19 +36,18 @@ xml.epp_head do ## TODO Find out what this domain:host is all about - xml.tag!('domain:clID', @domain.registrar_name) - - xml.tag!('domain:crID', @domain.creator.try(:registrar)) if @domain.creator + xml.tag!('domain:clID', @domain.registrar.code) + xml.tag!('domain:crID', @domain.creator.registrar.code) if @domain.creator xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) - xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) if @domain.updated_at != @domain.created_at + if @domain.updated_at != @domain.created_at + xml.tag!('domain:upID', @domain.updator.registrar.code) + xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) + end xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601)) - # TODO Make domain stampable - #xml.tag!('domain:upID', @domain.updated_by) - # TODO Make domain transferrable #xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at From 3d41322dc20440c0cd8775349abf65a1d0804fb0 Mon Sep 17 00:00:00 2001 From: teadur Date: Thu, 3 Dec 2015 13:03:25 +0200 Subject: [PATCH 09/98] Update whois.erb --- app/views/for_models/whois.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/for_models/whois.erb b/app/views/for_models/whois.erb index cb6adac75..f1eba3ecf 100644 --- a/app/views/for_models/whois.erb +++ b/app/views/for_models/whois.erb @@ -17,7 +17,7 @@ email: Not Disclosed - Visit www.internet.ee for webbased WHOIS changed: <%= json['changed'].to_s.tr('T',' ').sub('+', ' +') %> <%- if json['admin_contacts'].present? -%> -Administrative contact +Administrative contact: <%- for contact in json['admin_contacts'] -%> name: <%= contact['name'] %> email: Not Disclosed - Visit www.internet.ee for webbased WHOIS @@ -57,4 +57,4 @@ changed: <%= json['dnssec_changed'].to_s.tr('T',' ').sub('+', ' +') %> <%- end -%> Estonia .ee Top Level Domain WHOIS server -More information at http://internet.ee \ No newline at end of file +More information at http://internet.ee From e30b810eaab11f32ca92c75bde049005dda79b66 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 3 Dec 2015 13:12:13 +0200 Subject: [PATCH 10/98] Story#109368800 registrar portal now allows contact to have dot in params[:id] --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index f5b81e8b5..c1cc98697 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -67,7 +67,7 @@ Rails.application.routes.draw do # end # end - resources :contacts do + resources :contacts, constraints: {:id => /[^\/]+(?=#{ ActionController::Renderers::RENDERERS.map{|e| "\\.#{e}\\z"}.join("|") })|[^\/]+/} do member do get 'delete' end From 1de2992ce23fc37218c36df497913271cc8c1334 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 3 Dec 2015 13:31:47 +0200 Subject: [PATCH 11/98] Story#109368800 update validation that contact code may have dot --- app/models/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 7ebfaf684..d3ad609f2 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -26,7 +26,7 @@ class Contact < ActiveRecord::Base validates :ident_country_code, presence: true, if: proc { |c| %w(org priv).include? c.ident_type }, on: :create validates :code, uniqueness: { message: :epp_id_taken }, - format: { with: /\A[\w\-\:]*\Z/i, message: :invalid }, + format: { with: /\A[\w\-\:\.]*\z/i, message: :invalid }, length: { maximum: 100, message: :too_long_contact_code } validate :ident_valid_format? validate :uniq_statuses? From a5adbca28bd099fa9947019cc99b9323a5975f1e Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 3 Dec 2015 13:51:16 +0200 Subject: [PATCH 12/98] Story#109368800 update validation that contact code may have underscore --- app/models/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index d3ad609f2..fcebe8632 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -26,7 +26,7 @@ class Contact < ActiveRecord::Base validates :ident_country_code, presence: true, if: proc { |c| %w(org priv).include? c.ident_type }, on: :create validates :code, uniqueness: { message: :epp_id_taken }, - format: { with: /\A[\w\-\:\.]*\z/i, message: :invalid }, + format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid }, length: { maximum: 100, message: :too_long_contact_code } validate :ident_valid_format? validate :uniq_statuses? From 8944ec5bf0034f44b635b5178a6f320b31f1b2d5 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 16:53:05 +0200 Subject: [PATCH 13/98] Story #109367018 - send mail about with old registrant name when pending update --- app/models/domain.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index cc35807d5..b05a4327a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -438,7 +438,6 @@ class Domain < ActiveRecord::Base end def pending_update! - old_registrant_id = registrant_id return true if pending_update? self.epp_pending_update = true # for epp @@ -450,8 +449,8 @@ class Domain < ActiveRecord::Base new_registrant_email = registrant.email new_registrant_name = registrant.name - DomainMailer.pending_update_request_for_old_registrant(id, old_registrant_id, deliver_emails).deliver - DomainMailer.pending_update_notification_for_new_registrant(id, old_registrant_id, deliver_emails).deliver + DomainMailer.pending_update_request_for_old_registrant(id, registrant_id_was, deliver_emails).deliver + DomainMailer.pending_update_notification_for_new_registrant(id, registrant_id_was, deliver_emails).deliver reload # revert back to original From 2921ccdaebced261a22e43eb129c9fb3c3016066 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 12:58:11 +0200 Subject: [PATCH 14/98] Story #109367694 - changed xml text for elements crID, clID and upID --- app/views/epp/contacts/info.xml.builder | 12 +++++------- app/views/epp/domains/info.xml.builder | 13 ++++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 18019208a..3790544e1 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -46,15 +46,13 @@ xml.epp_head do xml.tag!('contact:email', 'No access') end - xml.tag!('contact:clID', @contact.registrar.try(:name)) - if @contact.creator.try(:registrar).blank? && Rails.env.test? - xml.tag!('contact:crID', 'TEST-CREATOR') - else - xml.tag!('contact:crID', @contact.creator.try(:registrar)) - end + xml.tag!('contact:clID', @contact.registrar.try(:code)) + + xml.tag!('contact:crID', @contact.creator.registrar.try(:code)) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) + if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.try(:registrar)) + xml.tag!('contact:upID', @contact.updator.registrar.code) xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 9e1779921..fd6bfeeb6 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -36,19 +36,18 @@ xml.epp_head do ## TODO Find out what this domain:host is all about - xml.tag!('domain:clID', @domain.registrar_name) - - xml.tag!('domain:crID', @domain.creator.try(:registrar)) if @domain.creator + xml.tag!('domain:clID', @domain.registrar.code) + xml.tag!('domain:crID', @domain.creator.registrar.code) if @domain.creator xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) - xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) if @domain.updated_at != @domain.created_at + if @domain.updated_at != @domain.created_at + xml.tag!('domain:upID', @domain.updator.registrar.code) + xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) + end xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601)) - # TODO Make domain stampable - #xml.tag!('domain:upID', @domain.updated_by) - # TODO Make domain transferrable #xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at From 50700d54f26abf81111c9c9c6cb3aa490c0b0daa Mon Sep 17 00:00:00 2001 From: teadur Date: Thu, 3 Dec 2015 18:07:04 +0200 Subject: [PATCH 15/98] Update contact.md --- doc/epp/contact.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/epp/contact.md b/doc/epp/contact.md index 5e45e491b..5db5ba3b4 100644 --- a/doc/epp/contact.md +++ b/doc/epp/contact.md @@ -34,7 +34,7 @@ Contact Mapping protocol short version: Attribute: "type" "org" # Business registry code "priv" # National idendtification number - "birthday" # Birthday date in format in DD-MM-YYYY + "birthday" # Birthday date in format in YYYY-MM-DD Attribute: "cc" "EE" # Country code in ISO_3166-1 aplha 2 0-1 Base64 encoded document @@ -70,7 +70,7 @@ Contact Mapping protocol short version: Attribute: "type" "org" # Business registry code "priv" # National idendtification number - "birthday" # Birthday date in format in DD-MM-YYYY + "birthday" # Birthday date in format in YYYY-MM-DD Attribute: "cc" "EE" # Country code in ISO_3166-1 aplha 2 0-1 Base64 encoded document. From e15ab3421d4b814eec6e4ece051e8d22cacff3b8 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:29:02 +0200 Subject: [PATCH 16/98] Story #109367694 - refactor user log string to user for paper trail creator_str --- app/controllers/application_controller.rb | 3 +-- app/models/user.rb | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 318923e3d..de54dafc5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -67,8 +67,7 @@ class ApplicationController < ActionController::Base end def user_log_str(user) - return 'public' if user.nil? - "#{user.id}-#{user.class}: #{user.username}" + user.nil? ? 'public' : user.string end def comma_support_for(parent_key, key) diff --git a/app/models/user.rb b/app/models/user.rb index 0beb174f3..5d415230c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,4 +3,9 @@ class User < ActiveRecord::Base devise :trackable, :timeoutable attr_accessor :phone + + def string + "#{self.id}-#{self.class}: #{self.username}" + end + end From 13129214e5cc9af30ec4aafbc40cf6fbf0e3bce3 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:30:56 +0200 Subject: [PATCH 17/98] Story #109367694 - reset updator_str for pendingUpdate to update requestor requires prior commit e15ab3421d4b814eec6e4ece051e8d22cacff3b8 --- app/models/epp/domain.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 613c57115..1a577218a 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -498,6 +498,7 @@ class Epp::Domain < Domain old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) + ::PaperTrail.whodunnit = user.string # updator str should be the request originator not the approval user frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here From 1d76c095f24aa2b270f2973f20a64a0ccdb68521 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 3 Dec 2015 18:31:24 +0200 Subject: [PATCH 18/98] Story#109014746 skip contacts validation if we are doing renewal --- app/models/epp/domain.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index afdc8e085..85e40a038 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -2,6 +2,9 @@ class Epp::Domain < Domain include EppErrors + # TODO: remove this spagetti once data in production is correct. + attr_accessor :is_renewal + before_validation :manage_permissions def manage_permissions return unless update_prohibited? || delete_prohibited? @@ -11,6 +14,8 @@ class Epp::Domain < Domain after_validation :validate_contacts def validate_contacts + return true if is_renewal + ok = true active_admins = admin_domain_contacts.select { |x| !x.marked_for_destruction? } active_techs = tech_domain_contacts.select { |x| !x.marked_for_destruction? } @@ -565,6 +570,7 @@ class Epp::Domain < Domain ### RENEW ### def renew(cur_exp_date, period, unit = 'y') + @is_renewal = true validate_exp_dates(cur_exp_date) add_epp_error('2105', nil, nil, I18n.t('object_is_not_eligible_for_renewal')) unless renewable? From 251a9e1666d2e0d6023cee6338cc6cc9a0e0d766 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:40:13 +0200 Subject: [PATCH 19/98] Story #109367694 - make upID optional to avoid possible error for AdminUser objects have no registar method --- app/views/epp/contacts/info.xml.builder | 2 +- app/views/epp/domains/info.xml.builder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 3790544e1..965e2340a 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -52,7 +52,7 @@ xml.epp_head do xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.registrar.code) + xml.tag!('contact:upID', @contact.updator.registrar.code) if @contact.updator.try(:registrar).present? xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index fd6bfeeb6..181eabc67 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -42,7 +42,7 @@ xml.epp_head do xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) if @domain.updated_at != @domain.created_at - xml.tag!('domain:upID', @domain.updator.registrar.code) + xml.tag!('domain:upID', @domain.updator.registrar.code) if @domain.updator.try(:registrar).present? xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) end From 098c40efc159bc6ee6462891f20152f4614bc8e4 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 14:11:21 +0200 Subject: [PATCH 20/98] Story #109367694 - use creator or updator as string, when registrar can not be found --- app/views/epp/contacts/info.xml.builder | 10 ++++++++-- app/views/epp/domains/info.xml.builder | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 965e2340a..9410368bb 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -48,11 +48,17 @@ xml.epp_head do xml.tag!('contact:clID', @contact.registrar.try(:code)) - xml.tag!('contact:crID', @contact.creator.registrar.try(:code)) + # EPP requires a creator ID, which should be registrar code if we have one + crID = contact.creator.try(:registrar) + crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? + crID = contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only + xml.tag!('contact:crID', crID) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.registrar.code) if @contact.updator.try(:registrar).present? + upID = contact.updator.try(:registrar) + upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? + xml.tag!('contact:upID', upID) if upID.present? # optional upID xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 181eabc67..11ab2441f 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -38,11 +38,17 @@ xml.epp_head do xml.tag!('domain:clID', @domain.registrar.code) - xml.tag!('domain:crID', @domain.creator.registrar.code) if @domain.creator + # EPP requires a creator ID, which should be registrar code if we have one + crID = @domain.creator.try(:registrar) + crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? + crID = @domain.creator unless crID.present? # Fallback if we failed, maybe this is a string only + xml.tag!('domain:crID', crID) xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) if @domain.updated_at != @domain.created_at - xml.tag!('domain:upID', @domain.updator.registrar.code) if @domain.updator.try(:registrar).present? + upID = @domain.updator.try(:registrar) + upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? + xml.tag!('domain:upID', upID) if upID.present? # optional upID xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) end From 238440de5260efb010c83092e5f62825d7829ef3 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 14:30:04 +0200 Subject: [PATCH 21/98] Story #109367694 - restore missing punctuation --- app/views/epp/contacts/info.xml.builder | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 9410368bb..5b501fc75 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -49,14 +49,14 @@ xml.epp_head do xml.tag!('contact:clID', @contact.registrar.try(:code)) # EPP requires a creator ID, which should be registrar code if we have one - crID = contact.creator.try(:registrar) + crID = @contact.creator.try(:registrar) crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? - crID = contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only + crID = @contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only xml.tag!('contact:crID', crID) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at - upID = contact.updator.try(:registrar) + upID = @contact.updator.try(:registrar) upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? xml.tag!('contact:upID', upID) if upID.present? # optional upID xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) From da11d9e7cba10ea2ec2b20c86114971a22c3abc4 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 15:27:42 +0200 Subject: [PATCH 22/98] Story #109367694 - add support for imported data, name was used --- app/models/concerns/versions.rb | 34 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index 2cbdca838..b0ac97434 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -22,32 +22,30 @@ module Versions def creator return nil if creator_str.blank? - - if creator_str =~ /^\d+-AdminUser:/ - creator = AdminUser.find_by(id: creator_str) - elsif creator_str =~ /^\d+-ApiUser:/ - creator = ApiUser.find_by(id: creator_str) - elsif creator_str =~ /^\d+-api-/ # depricated - creator = ApiUser.find_by(id: creator_str) - end - + creator = user_from_id_class_name creator_str creator.present? ? creator : creator_str end def updator return nil if updator_str.blank? - - if updator_str =~ /^\d+-AdminUser:/ - updator = AdminUser.find_by(id: updator_str) - elsif updator_str =~ /^\d+-ApiUser:/ - updator = ApiUser.find_by(id: updator_str) - elsif updator_str =~ /^\d+-api-/ # depricated - updator = ApiUser.find_by(id: updator_str) - end - + updator = user_from_id_class_name updator_str updator.present? ? updator : updator_str end + def user_from_id_class_name(str) + user = ApiUser.find_by(id: $1) if str =~ /^(\d+)-(ApiUser:|api-)/ + unless user.present? + user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/ + unless user.present? + # on import we copied Registrar name, which may eql code + registrar = Registrar.find_by(name: str).first + # assume each registrar has only one user + user = registrar.api_users.first if registrar + end + end + user + end + # callbacks def touch_domain_version domain.try(:touch_with_version) From 5b47f21dbe4430cc6a7d89cee117be024ef52659 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 15:38:48 +0200 Subject: [PATCH 23/98] Story 109367694 - refactor method name --- app/controllers/application_controller.rb | 2 +- app/models/epp/domain.rb | 2 +- app/models/user.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index de54dafc5..5d051377d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -67,7 +67,7 @@ class ApplicationController < ActionController::Base end def user_log_str(user) - user.nil? ? 'public' : user.string + user.nil? ? 'public' : user.id_role_username end def comma_support_for(parent_key, key) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 1a577218a..c41adc245 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -498,7 +498,7 @@ class Epp::Domain < Domain old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) - ::PaperTrail.whodunnit = user.string # updator str should be the request originator not the approval user + ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here diff --git a/app/models/user.rb b/app/models/user.rb index 5d415230c..b69e0250c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < ActiveRecord::Base attr_accessor :phone - def string + def id_role_username "#{self.id}-#{self.class}: #{self.username}" end From 1f0e8f86e91b5e7e7661ae8e4ad3fd2814dc08d2 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 15:40:33 +0200 Subject: [PATCH 24/98] Story 109367694 - refactor method name also --- app/models/concerns/versions.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index b0ac97434..ae2dabf6a 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -22,17 +22,17 @@ module Versions def creator return nil if creator_str.blank? - creator = user_from_id_class_name creator_str + creator = user_from_id_role_username creator_str creator.present? ? creator : creator_str end def updator return nil if updator_str.blank? - updator = user_from_id_class_name updator_str + updator = user_from_id_role_username updator_str updator.present? ? updator : updator_str end - def user_from_id_class_name(str) + def user_from_id_role_username(str) user = ApiUser.find_by(id: $1) if str =~ /^(\d+)-(ApiUser:|api-)/ unless user.present? user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/ From 380b86b9bdcee618a9433743d81213be8162291c Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 17:57:19 +0200 Subject: [PATCH 25/98] Story #109367694 - misplaced first --- app/models/concerns/versions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index ae2dabf6a..768cf021e 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -38,7 +38,7 @@ module Versions user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/ unless user.present? # on import we copied Registrar name, which may eql code - registrar = Registrar.find_by(name: str).first + registrar = Registrar.find_by(name: str) # assume each registrar has only one user user = registrar.api_users.first if registrar end From 9fbeeb70a2b582e2c64962a1386d7c4f7652920c Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Thu, 3 Dec 2015 17:41:28 +0200 Subject: [PATCH 26/98] whois fix updated time --- app/models/whois_record.rb | 2 +- app/views/for_models/whois.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index ac5f17c7b..21db2bdc0 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -50,7 +50,7 @@ class WhoisRecord < ActiveRecord::Base h[:registrant] = domain.registrant.name h[:registrant_email] = domain.registrant.email @disclosed << [:email, domain.registrant.email] - h[:changed] = domain.registrant.updated_at.try(:to_s, :iso8601) + h[:registrant_changed] = domain.registrant.updated_at.try(:to_s, :iso8601) h[:admin_contacts] = [] domain.admin_contacts.each do |ac| diff --git a/app/views/for_models/whois.erb b/app/views/for_models/whois.erb index f1eba3ecf..030f10d51 100644 --- a/app/views/for_models/whois.erb +++ b/app/views/for_models/whois.erb @@ -14,7 +14,7 @@ delete: <%= json['delete'].to_s.tr('T',' ').sub('+', ' +') %> Registrant: name: <%= json['registrant'] %> email: Not Disclosed - Visit www.internet.ee for webbased WHOIS -changed: <%= json['changed'].to_s.tr('T',' ').sub('+', ' +') %> +changed: <%= json['registrant_changed'].to_s.tr('T',' ').sub('+', ' +') %> <%- if json['admin_contacts'].present? -%> Administrative contact: From cec3693f826c50dfdfc2d8f03b0993d9e8059375 Mon Sep 17 00:00:00 2001 From: Stas Date: Sun, 6 Dec 2015 23:22:39 +0200 Subject: [PATCH 27/98] 109163582-filter_for_contacts --- .../registrar/contacts_controller.rb | 54 +++++-- app/views/registrar/contacts/index.haml | 133 +++++++++++++++--- 2 files changed, 158 insertions(+), 29 deletions(-) diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index f4ce84d8c..e01051007 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -3,18 +3,38 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller def index authorize! :view, Depp::Contact - limit, offset = pagination_details - res = depp_current_user.repp_request('contacts', { details: true, limit: limit, offset: offset }) - if res.code == '200' - @response = res.parsed_body.with_indifferent_access - @contacts = @response ? @response[:contacts] : [] - - @paginatable_array = Kaminari.paginate_array( - [], total_count: @response[:total_number_of_records] - ).page(params[:page]).per(limit) + params[:q] ||= {} + params[:q].delete_if { |_k, v| v.blank? } + if params[:q].length == 1 && params[:q][:name_matches].present? + @contacts = Contact.find_by(name: params[:q][:name_matches]) + if @contact + redirect_to info_registrar_domains_path(contact_name: @contact.name) and return + end end - flash.now[:epp_results] = [{ 'code' => res.code, 'msg' => res.message }] + + if params[:statuses_contains] + contacts = current_user.registrar.contacts.includes(:registrar).where( + "statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}" + ) + else + contacts = current_user.registrar.contacts.includes(:registrar) + end + + normalize_search_parameters do + @q = contacts.search(params[:q]) + @contacts = @q.result.page(params[:page]) + if @contacts.count == 0 && params[:q][:name_matches] !~ /^%.+%$/ + # if we do not get any results, add wildcards to the name field and search again + n_cache = params[:q][:name_matches] + params[:q][:name_matches] = "%#{params[:q][:name_matches]}%" + @q = contacts.search(params[:q]) + @contacts = @q.result.page(params[:page]) + params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form + end + end + + @contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 end def new @@ -75,4 +95,18 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller def init_epp_contact Depp::Contact.user = depp_current_user end + + def normalize_search_parameters + ca_cache = params[:q][:valid_to_lteq] + begin + end_time = params[:q][:valid_to_lteq].try(:to_date) + params[:q][:valid_to_lteq] = end_time.try(:end_of_day) + rescue + logger.warn('Invalid date') + end + + yield + + params[:q][:valid_to_lteq] = ca_cache + end end diff --git a/app/views/registrar/contacts/index.haml b/app/views/registrar/contacts/index.haml index 401df706d..452affe78 100644 --- a/app/views/registrar/contacts/index.haml +++ b/app/views/registrar/contacts/index.haml @@ -2,23 +2,118 @@ = link_to(t(:new), new_registrar_contact_path, class: 'btn btn-primary') = render 'shared/title', name: t(:contacts) -- if @response - .table-responsive - %table.table.table-hover.table-condensed - %thead - %tr - %th{class: 'col-xs-3'}= t(:name) - %th{class: 'col-xs-3'}= t(:id) - %th{class: 'col-xs-3'}= t(:ident) - %th{class: 'col-xs-3'}= t(:actions) - %tbody - - @contacts.each do |c| - %tr - %td= link_to(c[:name], registrar_contact_path(id: c[:code])) - %td= c[:code] - %td= ident_for(c) - %td - = link_to(t(:edit), edit_registrar_contact_path(c[:code]), class: 'btn btn-primary btn-xs') - = link_to(t(:delete), delete_registrar_contact_path(c[:code]), class: 'btn btn-default btn-xs') +.row + .col-md-12 + = search_form_for [:registrar, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| + .row + .col-md-3 + .form-group + = f.label :name + = f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) + .col-md-3 + .form-group + = f.label t(:id) + = f.search_field :code_eq, class: 'form-control', placeholder: t(:id) + .col-md-3 + .form-group + = f.label t(:ident) + = f.search_field :ident_matches, class: 'form-control', placeholder: t(:ident) + .col-md-3 + .form-group + = label_tag t(:ident_type) + = select_tag '[q][ident_type_eq]', options_for_select(Contact::IDENT_TYPES, params[:q][:ident_type_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } + .row + .col-md-3 + .form-group + = f.label t(:email) + = f.search_field :email_matches, class: 'form-control', placeholder: t(:email) + .col-md-3 + .form-group + = label_tag t(:country) + = select_tag '[q][country_code_eq]', SortedCountry.all_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } + .col-md-3 + .form-group + = f.label t(:is_registrant) + %div + = f.check_box :registrant_domains_id_not_null + .col-md-3 + .form-group + = label_tag t(:contact_type) + = select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } + .row + .col-md-3 + .form-group + = f.label t(:registrar) + = f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize', placeholder: t(:choose) + .col-md-3 + .form-group + = f.label t(:created_at_from) + = f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control datepicker', placeholder: t(:created_at_from) + .col-md-3 + .form-group + = f.label t(:created_at_until) + = f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control datepicker', placeholder: t(:created_at_until) + .col-md-3 + .form-group + = f.label t(:updated_at) + = f.search_field :updated_at_gteq, value: params[:q][:updated_at_gteq], class: 'form-control datepicker', placeholder: t(:updated_at) + .row + .col-md-6 + .form-group + = label_tag t(:status) + = select_tag :statuses_contains, options_for_select(Contact::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } + .col-md-3 + .form-group + = label_tag t(:results_per_page) + = text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) + .col-md-3{style: 'padding-top: 25px;'} + %button.btn.btn-primary +   + %span.glyphicon.glyphicon-search +   + %button.btn.btn-default.js-reset-form + = t(:clear_fields) - = paginate @paginatable_array +%hr +.row + .col-md-12 + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-2'} + = sort_link(@q, 'name', t(:name)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'code', t(:id)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'ident', t(:ident)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'email', t(:created_at)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'registrar_name', t(:registrar)) + %th{class: 'col-xs-2'}= t(:actions) + %tbody + - @contacts.each do |contact| + %tr + %td= link_to(contact, registrar_contact_path(contact)) + %td= contact.code + %td= ident_for(contact) + %td= l(contact.created_at, format: :short) + %td + - if contact.registrar + = contact.registrar + %td + = link_to(t(:edit), edit_registrar_contact_path(contact), class: 'btn btn-primary btn-xs') + = link_to(t(:delete), delete_registrar_contact_path(contact), class: 'btn btn-default btn-xs') + +.row + .col-md-6 + = paginate @contacts + .col-md-6.text-right + .pagination + = t(:result_count, count: @contacts.total_count) + +:coffee + $(".js-reset-form").on "click", (e) -> + e.preventDefault(); + window.location = "#{registrar_contacts_path}" From ec79e0a298f2ee058658241cef08b01c006a3a49 Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 7 Dec 2015 13:22:13 +0200 Subject: [PATCH 28/98] 108868838-admin_contacts_added --- .../mailers/domain_mailer/expiration_reminder.html.erb | 6 +++--- .../mailers/domain_mailer/expiration_reminder.text.erb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/mailers/domain_mailer/expiration_reminder.html.erb b/app/views/mailers/domain_mailer/expiration_reminder.html.erb index 63c08b1d2..be3ee7cb4 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.html.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.html.erb @@ -8,7 +8,7 @@ Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @do Domeeni <%= @domain.name %> kohta on registris järgmised andmed:

Registreerija: <%= @domain.registrant_name %>
-Halduskontakt: [% haldus_est_html %]
+Halduskontakt: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %>
Tehniline kontakt: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %>
Registripidaja: <%= @domain.registrar.name %>
Nimeserverid: <%= @domain.nameservers.join(', ') %>
@@ -34,7 +34,7 @@ To renew the domain registration, please contact your registrar <%= @domain.regi The following data for the <%= @domain.name %> domain have been entered into the registry:

Registrant: <%= @domain.registrant_name %>
-Administrative contact: [% haldus_eng_html %]
+Administrative contact: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %>
Technical contact: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %>
Registrar: <%= @domain.registrar.name %>
Name servers: <%= @domain.nameservers.join(', ') %>
@@ -60,7 +60,7 @@ Phone: +372 727 1000
Относительно домена <%= @domain.name %> в реестр внесены следующие данные:

Регистрант: <%= @domain.registrant_name %>
-Административный контакт: [% haldus_rus_html %]
+Административный контакт: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %>
Технический контакт: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %>
Регистратор: <%= @domain.registrar.name %>
Серверы доменных имен: <%= @domain.nameservers.join(', ') %>
diff --git a/app/views/mailers/domain_mailer/expiration_reminder.text.erb b/app/views/mailers/domain_mailer/expiration_reminder.text.erb index aa4d1754d..0da98ecae 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.text.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.text.erb @@ -8,7 +8,7 @@ Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @do Domeeni <%= @domain.name %> kohta on registris järgmised andmed: Registreerija: <%= @domain.registrant_name %> -Halduskontakt: [% haldus_est_html %] +Halduskontakt: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %> Tehniline kontakt: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %> Registripidaja: <%= @domain.registrar.name %> Nimeserverid: <%= @domain.nameservers.join(', ') %> @@ -34,7 +34,7 @@ To renew the domain registration, please contact your registrar <%= @domain.regi The following data for the <%= @domain.name %> domain have been entered into the registry: Registrant: <%= @domain.registrant_name %> -Administrative contact: [% haldus_eng_html %] +Administrative contact: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %> Technical contact: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %> Registrar: <%= @domain.registrar.name %> Name servers: <%= @domain.nameservers.join(', ') %> @@ -60,7 +60,7 @@ Phone: +372 727 1000 Относительно домена <%= @domain.name %> в реестр внесены следующие данные: Регистрант: <%= @domain.registrant_name %> -Административный контакт: [% haldus_rus_html %] +Административный контакт: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %> Технический контакт: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %> Регистратор: <%= @domain.registrar.name %> Серверы доменных имен: <%= @domain.nameservers.join(', ') %> From 83c029e1961a22122f2f699f2d3796d8a2aa76be Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 7 Dec 2015 18:07:21 +0200 Subject: [PATCH 29/98] 108868838-template_fixes --- .../domain_mailer/expiration_reminder.html.erb | 18 +++++++++--------- .../domain_mailer/expiration_reminder.text.erb | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/views/mailers/domain_mailer/expiration_reminder.html.erb b/app/views/mailers/domain_mailer/expiration_reminder.html.erb index be3ee7cb4..e917490b8 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.html.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.html.erb @@ -8,11 +8,11 @@ Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @do Domeeni <%= @domain.name %> kohta on registris järgmised andmed:

Registreerija: <%= @domain.registrant_name %>
-Halduskontakt: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %>
-Tehniline kontakt: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %>
+Halduskontakt: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %>
+Tehniline kontakt: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %>
Registripidaja: <%= @domain.registrar.name %>
Nimeserverid: <%= @domain.nameservers.join(', ') %>
-Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. http://eedirekt.internet.ee/registrant.
+Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. <%= ENV['registrant_url'] %>.


Parimate soovidega

@@ -34,11 +34,11 @@ To renew the domain registration, please contact your registrar <%= @domain.regi The following data for the <%= @domain.name %> domain have been entered into the registry:

Registrant: <%= @domain.registrant_name %>
-Administrative contact: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %>
-Technical contact: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %>
+Administrative contact: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %>
+Technical contact: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %>
Registrar: <%= @domain.registrar.name %>
Name servers: <%= @domain.nameservers.join(', ') %>
-You can find an overview of all your domains at the registrant's portal. http://eedirekt.internet.ee/registrant.
+You can find an overview of all your domains at the registrant's portal. <%= ENV['registrant_url'] %>.


Sincerely

@@ -60,11 +60,11 @@ Phone: +372 727 1000
Относительно домена <%= @domain.name %> в реестр внесены следующие данные:

Регистрант: <%= @domain.registrant_name %>
-Административный контакт: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %>
-Технический контакт: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %>
+Административный контакт: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %>
+Технический контакт: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %>
Регистратор: <%= @domain.registrar.name %>
Серверы доменных имен: <%= @domain.nameservers.join(', ') %>
-Обзор всех связанных с Вами доменов можете получить на портале регистранта. http://eedirekt.internet.ee/registrant.
+Обзор всех связанных с Вами доменов можете получить на портале регистранта. <%= ENV['registrant_url'] %>.


С наилучшими пожеланиями

diff --git a/app/views/mailers/domain_mailer/expiration_reminder.text.erb b/app/views/mailers/domain_mailer/expiration_reminder.text.erb index 0da98ecae..11e911156 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.text.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.text.erb @@ -8,11 +8,11 @@ Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @do Domeeni <%= @domain.name %> kohta on registris järgmised andmed: Registreerija: <%= @domain.registrant_name %> -Halduskontakt: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %> -Tehniline kontakt: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %> +Halduskontakt: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %> +Tehniline kontakt: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %> Registripidaja: <%= @domain.registrar.name %> Nimeserverid: <%= @domain.nameservers.join(', ') %> -Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. http://eedirekt.internet.ee/registrant. +Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. <%= ENV['registrant_url'] %>. Parimate soovidega @@ -34,11 +34,11 @@ To renew the domain registration, please contact your registrar <%= @domain.regi The following data for the <%= @domain.name %> domain have been entered into the registry: Registrant: <%= @domain.registrant_name %> -Administrative contact: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %> -Technical contact: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %> +Administrative contact: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %> +Technical contact: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %> Registrar: <%= @domain.registrar.name %> Name servers: <%= @domain.nameservers.join(', ') %> -You can find an overview of all your domains at the registrant's portal. http://eedirekt.internet.ee/registrant. +You can find an overview of all your domains at the registrant's portal. <%= ENV['registrant_url'] %>. Sincerely @@ -60,11 +60,11 @@ Phone: +372 727 1000 Относительно домена <%= @domain.name %> в реестр внесены следующие данные: Регистрант: <%= @domain.registrant_name %> -Административный контакт: <%= @domain.admin_contacts.map { |c| c.contact.phone }.join ', ' %> -Технический контакт: <%= @domain.tech_domain_contacts.map { |c| c.contact.phone }.join ', ' %> +Административный контакт: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %> +Технический контакт: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %> Регистратор: <%= @domain.registrar.name %> Серверы доменных имен: <%= @domain.nameservers.join(', ') %> -Обзор всех связанных с Вами доменов можете получить на портале регистранта. http://eedirekt.internet.ee/registrant. +Обзор всех связанных с Вами доменов можете получить на портале регистранта. <%= ENV['registrant_url'] %>. С наилучшими пожеланиями From 34474c2240f1fe64be7e4df75bb74494fb1a8666 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 8 Dec 2015 11:10:25 +0200 Subject: [PATCH 30/98] Story#109362984 - converter to update punycodes in domain history --- lib/tasks/convert.rake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/tasks/convert.rake b/lib/tasks/convert.rake index 6345c9097..ba0e547dc 100644 --- a/lib/tasks/convert.rake +++ b/lib/tasks/convert.rake @@ -15,5 +15,22 @@ namespace :convert do end puts "-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds. #{count} domains changed." end + + desc 'Convert punycodes in history to unicode' + task history_punycode: :environment do + DomainVersion.find_each do |d| + if obj = d.object + obj["name"] = SimpleIDN.to_unicode(obj["name"]) + obj["name_puny"] = SimpleIDN.to_ascii(obj["name_puny"]) + d.object = obj + end + if (obj_c = d.object_changes).present? + obj_c["name"].map!{|e| e ? SimpleIDN.to_unicode(e) : e } if obj_c["name"] + obj_c["name_puny"].map!{|e| e ? SimpleIDN.to_ascii(e) : e } if obj_c["name_puny"] + d.object_changes = obj_c + end + d.save! + end + end end From 887631f1ab74abab65e86ca5232fa05d9d2e1642 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 5 Dec 2015 22:47:15 +0200 Subject: [PATCH 31/98] update_related_whois_records --- app/models/contact.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/contact.rb b/app/models/contact.rb index fcebe8632..3fee7dd36 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -61,6 +61,8 @@ class Contact < ActiveRecord::Base manage_ok end + after_save :update_related_whois_records + # for overwrite when doing children loop attr_writer :domains_present @@ -468,4 +470,9 @@ class Contact < ActiveRecord::Base PENDING_DELETE ]).present? end + + def update_related_whois_records + related_domain_descriptions.each do |x, y| WhoisRecord.find_by(name: x).save + end + end From 5a23bac1a59e5429bc51a78a467276f7beed2a29 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 5 Dec 2015 22:55:31 +0200 Subject: [PATCH 32/98] fix syntax error --- app/models/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 3fee7dd36..54f289266 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -472,7 +472,7 @@ class Contact < ActiveRecord::Base end def update_related_whois_records - related_domain_descriptions.each do |x, y| WhoisRecord.find_by(name: x).save + related_domain_descriptions.each do |x, y| WhoisRecord.find_by(name: x).save end end end From 5747e3b82367c61f778fb4a5d71aee4eb0be3dcb Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Mon, 7 Dec 2015 18:10:19 +0200 Subject: [PATCH 33/98] send force_delete emails --- app/models/domain.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index a08397d81..ef714716b 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -647,7 +647,7 @@ class Domain < ActiveRecord::Base registrar.messages.create!( body: I18n.t('force_delete_set_on_domain', domain: name) ) - DomainMailer.force_delete(id, deliver_emails).deliver + DomainMailer.force_delete(id, true).deliver return true end false From 5c104b2bcf121b2a03385b5a2f59a6f66cfd772c Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Mon, 7 Dec 2015 18:08:04 +0200 Subject: [PATCH 34/98] url fies --- .../mailers/domain_mailer/force_delete.html.erb | 10 +++++----- .../mailers/domain_mailer/force_delete.text.erb | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/views/mailers/domain_mailer/force_delete.html.erb b/app/views/mailers/domain_mailer/force_delete.html.erb index cfb5fb914..82bdee156 100644 --- a/app/views/mailers/domain_mailer/force_delete.html.erb +++ b/app/views/mailers/domain_mailer/force_delete.html.erb @@ -16,7 +16,7 @@ Registrikood: <%= @domain.registrant.try(:ident) %>

EIS-le on saanud teatavaks, et juriidiline isik registrikoodiga <%= @domain.registrant.try(:ident) %> on äriregistrist kustutatud.

-

Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registreerijaks, siis algatas EIS <%= l(Time.zone.now, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/et/domeenid/) punktile 6.4 domeeni <%= @domain.name %> suhtes 30 päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks.

+

Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registreerijaks, siis algatas EIS <%= l(Time.zone.now, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.4 domeeni <%= @domain.name %> suhtes 30 päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks.

Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @domain.registrar %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleks esitada Registripidajale esimesel võimalusel.

@@ -35,13 +35,13 @@ Registry code: <%= @domain.registrant.try(:ident) %>

EIF has learned that the legal person with registry code <%= @domain.registrant.try(:ident) %> has been deleted from the Business Registry.

-

As a terminated legal person cannot be the registrant of a domain, the EIF started the deletion process of <%= @domain.name %> domain on <%= l(Time.zone.now, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the 30-day delete procedure. The domain will remain available on the Internet during the delete procedure.

+

As a terminated legal person cannot be the registrant of a domain, the EIF started the deletion process of <%= @domain.name %> domain on <%= l(Time.zone.now, format: :date) %> according to the Domain Regulation (http://www.internet.ee/domains/), using the 30-day delete procedure. The domain will remain available on the Internet during the delete procedure.

According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @domain.registrar %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible.

If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours after <%= l(@domain.force_delete_at, format: :short) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis.

-

Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/en/registrars/



+

Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/registrars/



@@ -54,13 +54,13 @@ Registry code: <%= @domain.registrant.try(:ident) %>

EIS стало известно, что юридическое лицо с регистрационным кодом <%= @domain.registrant.try(:ident) %> удалено из коммерческого реестра.

-

Поскольку прекратившее деятельность юридическое лицо не может являться регистрантом домена, то согласно пункту 6.4 Правил домена (http://www.internet.ee/ru/11364/11400/) EIS <%= l(Time.zone.now, format: :date) %> инициировало удаление домена <%= @domain.name %> с применением 30-дневной процедуры удаления. На протяжении процесса удаления домен остается доступным в Интернете.

+

Поскольку прекратившее деятельность юридическое лицо не может являться регистрантом домена, то согласно пункту 6.4 Правил домена (http://www.internet.ee/domeny/) EIS <%= l(Time.zone.now, format: :date) %> инициировало удаление домена <%= @domain.name %> с применением 30-дневной процедуры удаления. На протяжении процесса удаления домен остается доступным в Интернете.

Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @domain.registrar %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления.

Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :short) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел".

-

Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/



+

Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/registratory/



diff --git a/app/views/mailers/domain_mailer/force_delete.text.erb b/app/views/mailers/domain_mailer/force_delete.text.erb index fdd075647..527288686 100644 --- a/app/views/mailers/domain_mailer/force_delete.text.erb +++ b/app/views/mailers/domain_mailer/force_delete.text.erb @@ -7,13 +7,13 @@ Registrikood: <%= @domain.registrant.try(:ident) %> EIS-le on saanud teatavaks, et juriidiline isik registrikoodiga <%= @domain.registrant.try(:ident) %> on äriregistrist kustutatud. -Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registreerijaks, siis algatas EIS <%= l(Time.zone.now, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/et/domeenid/) punktile 6.4 domeeni <%= @domain.name %> suhtes 30 päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks. +Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registreerijaks, siis algatas EIS <%= l(Time.zone.now, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.4 domeeni <%= @domain.name %> suhtes 30 päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks. Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @domain.registrar %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleks esitada Registripidajale esimesel võimalusel. Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :short) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist "kes ees, see mees" põhimõttel uuesti registreerida. -Lisaküsimuste korral võtke palun ühendust oma registripidajaga <%= @domain.registrar %>, kelle kontaktandmed leiate lingilt http://www.internet.ee/et/registripidajad/ +Lisaküsimuste korral võtke palun ühendust oma registripidajaga <%= @domain.registrar %>, kelle kontaktandmed leiate lingilt http://www.internet.ee/registripidajad/ @@ -26,13 +26,13 @@ Registry code: <%= @domain.registrant.try(:ident) %> EIF has learned that the legal person with registry code <%= @domain.registrant.try(:ident) %> has been deleted from the Business Registry. -As a terminated legal person cannot be the registrant of a domain, the EIF started the deletion process of <%= @domain.name %> domain on <%= l(Time.zone.now, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the 30-day delete procedure. The domain will remain available on the Internet during the delete procedure. +As a terminated legal person cannot be the registrant of a domain, the EIF started the deletion process of <%= @domain.name %> domain on <%= l(Time.zone.now, format: :date) %> according to the Domain Regulation (http://www.internet.ee/domains/), using the 30-day delete procedure. The domain will remain available on the Internet during the delete procedure. According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @domain.registrar %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible. If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours after <%= l(@domain.force_delete_at, format: :short) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis. -Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/en/registrars/ +Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/registrars/ @@ -45,13 +45,13 @@ Should you have additional questions, please contact your registrar <%= @domain. EIS стало известно, что юридическое лицо с регистрационным кодом <%= @domain.registrant.try(:ident) %> удалено из коммерческого реестра. -Поскольку прекратившее деятельность юридическое лицо не может являться регистрантом домена, то согласно пункту 6.4 Правил домена (http://www.internet.ee/ru/11364/11400/) EIS <%= l(Time.zone.now, format: :date) %> инициировало удаление домена <%= @domain.name %> с применением 30-дневной процедуры удаления. На протяжении процесса удаления домен остается доступным в Интернете. +Поскольку прекратившее деятельность юридическое лицо не может являться регистрантом домена, то согласно пункту 6.4 Правил домена (http://www.internet.ee/domeny) EIS <%= l(Time.zone.now, format: :date) %> инициировало удаление домена <%= @domain.name %> с применением 30-дневной процедуры удаления. На протяжении процесса удаления домен остается доступным в Интернете. Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @domain.registrar %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления. Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :short) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел". -Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/ +Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/registratory From 1113da818b3c87277553944886faf22962523a28 Mon Sep 17 00:00:00 2001 From: teadur Date: Tue, 8 Dec 2015 13:42:53 +0200 Subject: [PATCH 35/98] Revert "Whois update related contacts" --- app/models/contact.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 54f289266..fcebe8632 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -61,8 +61,6 @@ class Contact < ActiveRecord::Base manage_ok end - after_save :update_related_whois_records - # for overwrite when doing children loop attr_writer :domains_present @@ -470,9 +468,4 @@ class Contact < ActiveRecord::Base PENDING_DELETE ]).present? end - - def update_related_whois_records - related_domain_descriptions.each do |x, y| WhoisRecord.find_by(name: x).save end - end - end From 0d6f06123bee8ee2ea4ac03e132be52640ed6e27 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Tue, 8 Dec 2015 13:46:29 +0200 Subject: [PATCH 36/98] cleaner syntax --- app/models/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 54f289266..dace4d968 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -472,7 +472,7 @@ class Contact < ActiveRecord::Base end def update_related_whois_records - related_domain_descriptions.each do |x, y| WhoisRecord.find_by(name: x).save end + related_domain_descriptions.each{ |x, y| WhoisRecord.find_by(name: x).save} end end From f1b5ede74bf3ec0b289ec6b23160179f59f0cde1 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Tue, 8 Dec 2015 13:52:56 +0200 Subject: [PATCH 37/98] after save --- app/models/contact.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/contact.rb b/app/models/contact.rb index 6fbc74325..dace4d968 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -61,6 +61,8 @@ class Contact < ActiveRecord::Base manage_ok end + after_save :update_related_whois_records + # for overwrite when doing children loop attr_writer :domains_present From 05c6f23bfa8dd409c0d8630a990652c2d545a59f Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 8 Dec 2015 16:29:28 +0200 Subject: [PATCH 38/98] 108868838-contacts_change --- .../domain_mailer/expiration_reminder.html.erb | 12 ++++++------ .../domain_mailer/expiration_reminder.text.erb | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/mailers/domain_mailer/expiration_reminder.html.erb b/app/views/mailers/domain_mailer/expiration_reminder.html.erb index e917490b8..59f02c510 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.html.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.html.erb @@ -8,8 +8,8 @@ Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @do Domeeni <%= @domain.name %> kohta on registris järgmised andmed:

Registreerija: <%= @domain.registrant_name %>
-Halduskontakt: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %>
-Tehniline kontakt: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %>
+Halduskontakt: <%= @domain.admin_contacts.map(&:name).join ', ' %>
+Tehniline kontakt: <%= @domain.tech_contacts.map(&:name).join ', ' %>
Registripidaja: <%= @domain.registrar.name %>
Nimeserverid: <%= @domain.nameservers.join(', ') %>
Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. <%= ENV['registrant_url'] %>.
@@ -34,8 +34,8 @@ To renew the domain registration, please contact your registrar <%= @domain.regi The following data for the <%= @domain.name %> domain have been entered into the registry:

Registrant: <%= @domain.registrant_name %>
-Administrative contact: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %>
-Technical contact: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %>
+Administrative contact: <%= @domain.admin_contacts.map(&:name).join ', ' %>
+Technical contact: <%= @domain.tech_contacts.map(&:name).join ', ' %>
Registrar: <%= @domain.registrar.name %>
Name servers: <%= @domain.nameservers.join(', ') %>
You can find an overview of all your domains at the registrant's portal. <%= ENV['registrant_url'] %>.
@@ -60,8 +60,8 @@ Phone: +372 727 1000
Относительно домена <%= @domain.name %> в реестр внесены следующие данные:

Регистрант: <%= @domain.registrant_name %>
-Административный контакт: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %>
-Технический контакт: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %>
+Административный контакт: <%= @domain.admin_contacts.map(&:name).join ', ' %>
+Технический контакт: <%= @domain.tech_contacts.map(&:name).join ', ' %>
Регистратор: <%= @domain.registrar.name %>
Серверы доменных имен: <%= @domain.nameservers.join(', ') %>
Обзор всех связанных с Вами доменов можете получить на портале регистранта. <%= ENV['registrant_url'] %>.
diff --git a/app/views/mailers/domain_mailer/expiration_reminder.text.erb b/app/views/mailers/domain_mailer/expiration_reminder.text.erb index 11e911156..988ae5e10 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.text.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.text.erb @@ -8,8 +8,8 @@ Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @do Domeeni <%= @domain.name %> kohta on registris järgmised andmed: Registreerija: <%= @domain.registrant_name %> -Halduskontakt: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %> -Tehniline kontakt: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %> +Halduskontakt: <%= @domain.admin_contacts.map(&:name).join ', ' %> +Tehniline kontakt: <%= @domain.tech_contacts.map(&:name).join ', ' %> Registripidaja: <%= @domain.registrar.name %> Nimeserverid: <%= @domain.nameservers.join(', ') %> Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. <%= ENV['registrant_url'] %>. @@ -34,8 +34,8 @@ To renew the domain registration, please contact your registrar <%= @domain.regi The following data for the <%= @domain.name %> domain have been entered into the registry: Registrant: <%= @domain.registrant_name %> -Administrative contact: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %> -Technical contact: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %> +Administrative contact: <%= @domain.admin_contacts.map(&:name).join ', ' %> +Technical contact: <%= @domain.tech_contacts.map(&:name).join ', ' %> Registrar: <%= @domain.registrar.name %> Name servers: <%= @domain.nameservers.join(', ') %> You can find an overview of all your domains at the registrant's portal. <%= ENV['registrant_url'] %>. @@ -60,8 +60,8 @@ Phone: +372 727 1000 Относительно домена <%= @domain.name %> в реестр внесены следующие данные: Регистрант: <%= @domain.registrant_name %> -Административный контакт: <%= @domain.admin_contacts.map { |c| c.contact.name }.join ', ' %> -Технический контакт: <%= @domain.tech_domain_contacts.map { |c| c.contact.name }.join ', ' %> +Административный контакт: <%= @domain.admin_contacts.map(&:name).join ', ' %> +Технический контакт: <%= @domain.tech_contacts.map(&:name).join ', ' %> Регистратор: <%= @domain.registrar.name %> Серверы доменных имен: <%= @domain.nameservers.join(', ') %> Обзор всех связанных с Вами доменов можете получить на портале регистранта. <%= ENV['registrant_url'] %>. From 1651961147483eaf0b2801926d11700ad43af70b Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 9 Dec 2015 16:07:57 +0200 Subject: [PATCH 39/98] 109163582-import_files --- .../registrar/contacts_controller.rb | 36 +++++++++++++++++-- app/models/contact.rb | 15 ++++++++ .../registrar/contacts/download_list.haml | 24 +++++++++++++ app/views/registrar/contacts/index.haml | 12 +++++++ config/routes.rb | 1 + 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 app/views/registrar/contacts/download_list.haml diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index e01051007..b4ab97dc4 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -25,18 +25,50 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller @q = contacts.search(params[:q]) @contacts = @q.result.page(params[:page]) if @contacts.count == 0 && params[:q][:name_matches] !~ /^%.+%$/ - # if we do not get any results, add wildcards to the name field and search again n_cache = params[:q][:name_matches] params[:q][:name_matches] = "%#{params[:q][:name_matches]}%" @q = contacts.search(params[:q]) @contacts = @q.result.page(params[:page]) - params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form + params[:q][:name_matches] = n_cache end end @contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 end + def download_list + authorize! :view, Depp::Contact + + params[:q] ||= {} + if params[:statuses_contains] + contacts = current_user.registrar.contacts.includes(:registrar).where( + "statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}" + ) + else + contacts = current_user.registrar.contacts.includes(:registrar) + end + + normalize_search_parameters do + @q = contacts.search(params[:q]) + @contacts = @q.result.page(params[:page]) + if @contacts.count == 0 && params[:q][:name_matches] !~ /^%.+%$/ + n_cache = params[:q][:name_matches] + params[:q][:name_matches] = "%#{params[:q][:name_matches]}%" + @q = contacts.search(params[:q]) + @contacts = @q.result.page(params[:page]) + params[:q][:name_matches] = n_cache + end + end + + respond_to do |format| + format.csv { render text: @contacts.to_csv } + format.pdf do + pdf = @contacts.pdf(render_to_string('registrar/contacts/download_list', layout: false)) + send_data pdf, filename: 'contacts.pdf' + end + end + end + def new authorize! :create, Depp::Contact @contact = Depp::Contact.new diff --git a/app/models/contact.rb b/app/models/contact.rb index f5a177eef..d0d0ba967 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -201,6 +201,21 @@ class Contact < ActiveRecord::Base ['DeleteProhibited', SERVER_DELETE_PROHIBITED] ] end + + def to_csv + CSV.generate do |csv| + csv << column_names + all.each do |contact| + csv << contact.attributes.values_at(*column_names) + end + end + end + + def pdf(html) + kit = PDFKit.new(html) + kit.to_pdf + end + end def roid diff --git a/app/views/registrar/contacts/download_list.haml b/app/views/registrar/contacts/download_list.haml new file mode 100644 index 000000000..2c1d67d81 --- /dev/null +++ b/app/views/registrar/contacts/download_list.haml @@ -0,0 +1,24 @@ +.row + .col-md-12 + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-2'} + =t(:name) + %th{class: 'col-xs-2'} + =t(:id) + %th{class: 'col-xs-2'} + =t(:ident) + %th{class: 'col-xs-2'} + =t(:created_at) + %th{class: 'col-xs-2'} + =t(:registrar) + %tbody + - @contacts.each do |contact| + %tr + %td= contact + %td= contact.code + %td= ident_for(contact) + %td= l(contact.created_at, format: :short) + %td= contact.registrar \ No newline at end of file diff --git a/app/views/registrar/contacts/index.haml b/app/views/registrar/contacts/index.haml index 452affe78..7ffb7bc4e 100644 --- a/app/views/registrar/contacts/index.haml +++ b/app/views/registrar/contacts/index.haml @@ -73,6 +73,18 @@   %button.btn.btn-default.js-reset-form = t(:clear_fields) + .row + .col-md-3 + .btn-group{:role => "group"} + %button.btn.btn-default.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + Download + %span.caret + %ul.dropdown-menu + %li= link_to 'PDF', download_list_registrar_contacts_path(params[:q], format: "pdf") + %li= link_to 'CSV', download_list_registrar_contacts_path(params[:q], format: "csv") + .col-md-3 + .col-md-3 + .col-md-3 %hr .row diff --git a/config/routes.rb b/config/routes.rb index f5b81e8b5..2a03355f3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,6 +74,7 @@ Rails.application.routes.draw do collection do get 'check' + get 'download_list' end end From 14673f1ffc62709689570f7dc00a0218facba203 Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 10 Dec 2015 14:27:30 +0200 Subject: [PATCH 40/98] 109163582-search_filters+changes --- .../registrar/contacts_controller.rb | 69 ++++++++----------- .../registrar/contacts/download_list.haml | 52 +++++++------- app/views/registrar/contacts/index.haml | 10 +-- 3 files changed, 64 insertions(+), 67 deletions(-) diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index b4ab97dc4..878e29cd2 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -8,14 +8,11 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller params[:q].delete_if { |_k, v| v.blank? } if params[:q].length == 1 && params[:q][:name_matches].present? @contacts = Contact.find_by(name: params[:q][:name_matches]) - if @contact - redirect_to info_registrar_domains_path(contact_name: @contact.name) and return - end end if params[:statuses_contains] - contacts = current_user.registrar.contacts.includes(:registrar).where( - "statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}" + contacts = current_user.registrar.contacts.includes(:registrar).where( + "contacts.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}" ) else contacts = current_user.registrar.contacts.includes(:registrar) @@ -24,13 +21,6 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller normalize_search_parameters do @q = contacts.search(params[:q]) @contacts = @q.result.page(params[:page]) - if @contacts.count == 0 && params[:q][:name_matches] !~ /^%.+%$/ - n_cache = params[:q][:name_matches] - params[:q][:name_matches] = "%#{params[:q][:name_matches]}%" - @q = contacts.search(params[:q]) - @contacts = @q.result.page(params[:page]) - params[:q][:name_matches] = n_cache - end end @contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 @@ -39,34 +29,35 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller def download_list authorize! :view, Depp::Contact - params[:q] ||= {} - if params[:statuses_contains] - contacts = current_user.registrar.contacts.includes(:registrar).where( - "statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}" - ) - else - contacts = current_user.registrar.contacts.includes(:registrar) - end - - normalize_search_parameters do - @q = contacts.search(params[:q]) - @contacts = @q.result.page(params[:page]) - if @contacts.count == 0 && params[:q][:name_matches] !~ /^%.+%$/ - n_cache = params[:q][:name_matches] - params[:q][:name_matches] = "%#{params[:q][:name_matches]}%" - @q = contacts.search(params[:q]) - @contacts = @q.result.page(params[:page]) - params[:q][:name_matches] = n_cache - end - end - - respond_to do |format| - format.csv { render text: @contacts.to_csv } - format.pdf do - pdf = @contacts.pdf(render_to_string('registrar/contacts/download_list', layout: false)) - send_data pdf, filename: 'contacts.pdf' - end + params[:q] ||= {} + params[:q].delete_if { |_k, v| v.blank? } + if params[:q].length == 1 && params[:q][:name_matches].present? + @contacts = Contact.find_by(name: params[:q][:name_matches]) end + + if params[:statuses_contains] + contacts = current_user.registrar.contacts.includes(:registrar).where( + "contacts.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}" + ) + else + contacts = current_user.registrar.contacts.includes(:registrar) + end + + normalize_search_parameters do + @q = contacts.search(params[:q]) + @contacts = @q.result.page(params[:page]) + end + + @contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 + + respond_to do |format| + format.csv { render text: @contacts.to_csv } + format.pdf do + pdf = @contacts.pdf(render_to_string('registrar/contacts/download_list', layout: false)) + send_data pdf, filename: 'contacts.pdf' + end + end + end def new diff --git a/app/views/registrar/contacts/download_list.haml b/app/views/registrar/contacts/download_list.haml index 2c1d67d81..b8944d254 100644 --- a/app/views/registrar/contacts/download_list.haml +++ b/app/views/registrar/contacts/download_list.haml @@ -1,24 +1,30 @@ -.row - .col-md-12 - .table-responsive - %table.table.table-hover.table-bordered.table-condensed - %thead - %tr - %th{class: 'col-xs-2'} - =t(:name) - %th{class: 'col-xs-2'} - =t(:id) - %th{class: 'col-xs-2'} - =t(:ident) - %th{class: 'col-xs-2'} - =t(:created_at) - %th{class: 'col-xs-2'} - =t(:registrar) - %tbody - - @contacts.each do |contact| +!!! +%html + %head + %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"} + %title Contacts + %body + .row + .col-md-12 + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead %tr - %td= contact - %td= contact.code - %td= ident_for(contact) - %td= l(contact.created_at, format: :short) - %td= contact.registrar \ No newline at end of file + %th{class: 'col-xs-2'} + =t(:name) + %th{class: 'col-xs-2'} + =t(:id) + %th{class: 'col-xs-2'} + =t(:ident) + %th{class: 'col-xs-2'} + =t(:created_at) + %th{class: 'col-xs-2'} + =t(:registrar) + %tbody + - @contacts.each do |contact| + %tr + %td= contact + %td= contact.code + %td= ident_for(contact) + %td= l(contact.created_at, format: :short) + %td= contact.registrar diff --git a/app/views/registrar/contacts/index.haml b/app/views/registrar/contacts/index.haml index 7ffb7bc4e..ae93a82fd 100644 --- a/app/views/registrar/contacts/index.haml +++ b/app/views/registrar/contacts/index.haml @@ -80,8 +80,8 @@ Download %span.caret %ul.dropdown-menu - %li= link_to 'PDF', download_list_registrar_contacts_path(params[:q], format: "pdf") - %li= link_to 'CSV', download_list_registrar_contacts_path(params[:q], format: "csv") + %li= link_to 'PDF', download_list_registrar_contacts_path(q: params[:q], format: "pdf") + %li= link_to 'CSV', download_list_registrar_contacts_path(q: params[:q], format: "csv") .col-md-3 .col-md-3 .col-md-3 @@ -107,7 +107,7 @@ %tbody - @contacts.each do |contact| %tr - %td= link_to(contact, registrar_contact_path(contact)) + %td= link_to(contact.name, registrar_contact_path(id: contact.code)) %td= contact.code %td= ident_for(contact) %td= l(contact.created_at, format: :short) @@ -115,8 +115,8 @@ - if contact.registrar = contact.registrar %td - = link_to(t(:edit), edit_registrar_contact_path(contact), class: 'btn btn-primary btn-xs') - = link_to(t(:delete), delete_registrar_contact_path(contact), class: 'btn btn-default btn-xs') + = link_to(t(:edit), edit_registrar_contact_path(contact.code), class: 'btn btn-primary btn-xs') + = link_to(t(:delete), delete_registrar_contact_path(contact.code), class: 'btn btn-default btn-xs') .row .col-md-6 From 06608b687bdbbdbd9f5db5ae3084ff67fe249a5e Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 11 Dec 2015 18:13:54 +0200 Subject: [PATCH 41/98] Story#109965360 - do not validate destroyed domain nameservers --- app/models/domain.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 780ff3b7a..7858b3d36 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -543,7 +543,7 @@ class Domain < ActiveRecord::Base ### VALIDATIONS ### def validate_nameserver_ips - nameservers.each do |ns| + nameservers.to_a.reject(&:marked_for_destruction?).each do |ns| next unless ns.hostname.end_with?(name) next if ns.ipv4.present? errors.add(:nameservers, :invalid) if errors[:nameservers].blank? From 6c38f3e5a58e6915ec7e4fc9f1f157f95bc4290d Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 12:58:11 +0200 Subject: [PATCH 42/98] Story #109367694 - changed xml text for elements crID, clID and upID --- app/views/epp/contacts/info.xml.builder | 12 +++++------- app/views/epp/domains/info.xml.builder | 13 ++++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 18019208a..3790544e1 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -46,15 +46,13 @@ xml.epp_head do xml.tag!('contact:email', 'No access') end - xml.tag!('contact:clID', @contact.registrar.try(:name)) - if @contact.creator.try(:registrar).blank? && Rails.env.test? - xml.tag!('contact:crID', 'TEST-CREATOR') - else - xml.tag!('contact:crID', @contact.creator.try(:registrar)) - end + xml.tag!('contact:clID', @contact.registrar.try(:code)) + + xml.tag!('contact:crID', @contact.creator.registrar.try(:code)) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) + if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.try(:registrar)) + xml.tag!('contact:upID', @contact.updator.registrar.code) xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 9e1779921..fd6bfeeb6 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -36,19 +36,18 @@ xml.epp_head do ## TODO Find out what this domain:host is all about - xml.tag!('domain:clID', @domain.registrar_name) - - xml.tag!('domain:crID', @domain.creator.try(:registrar)) if @domain.creator + xml.tag!('domain:clID', @domain.registrar.code) + xml.tag!('domain:crID', @domain.creator.registrar.code) if @domain.creator xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) - xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) if @domain.updated_at != @domain.created_at + if @domain.updated_at != @domain.created_at + xml.tag!('domain:upID', @domain.updator.registrar.code) + xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) + end xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601)) - # TODO Make domain stampable - #xml.tag!('domain:upID', @domain.updated_by) - # TODO Make domain transferrable #xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at From 04b807120689a1729f43dd61918a0dd40174236e Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:29:02 +0200 Subject: [PATCH 43/98] Story #109367694 - refactor user log string to user for paper trail creator_str --- app/controllers/application_controller.rb | 3 +-- app/models/user.rb | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 318923e3d..de54dafc5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -67,8 +67,7 @@ class ApplicationController < ActionController::Base end def user_log_str(user) - return 'public' if user.nil? - "#{user.id}-#{user.class}: #{user.username}" + user.nil? ? 'public' : user.string end def comma_support_for(parent_key, key) diff --git a/app/models/user.rb b/app/models/user.rb index 0beb174f3..5d415230c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,4 +3,9 @@ class User < ActiveRecord::Base devise :trackable, :timeoutable attr_accessor :phone + + def string + "#{self.id}-#{self.class}: #{self.username}" + end + end From 74c73b78cbe5bbc2691360d84475365290e27c5d Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:30:56 +0200 Subject: [PATCH 44/98] Story #109367694 - reset updator_str for pendingUpdate to update requestor requires prior commit e15ab3421d4b814eec6e4ece051e8d22cacff3b8 --- app/models/epp/domain.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 739c55bec..5339b8695 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -503,6 +503,7 @@ class Epp::Domain < Domain old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) + ::PaperTrail.whodunnit = user.string # updator str should be the request originator not the approval user frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here From 2e52c2d102630ec95a05d3557a2963a5ca736773 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:40:13 +0200 Subject: [PATCH 45/98] Story #109367694 - make upID optional to avoid possible error for AdminUser objects have no registar method --- app/views/epp/contacts/info.xml.builder | 2 +- app/views/epp/domains/info.xml.builder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 3790544e1..965e2340a 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -52,7 +52,7 @@ xml.epp_head do xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.registrar.code) + xml.tag!('contact:upID', @contact.updator.registrar.code) if @contact.updator.try(:registrar).present? xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index fd6bfeeb6..181eabc67 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -42,7 +42,7 @@ xml.epp_head do xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) if @domain.updated_at != @domain.created_at - xml.tag!('domain:upID', @domain.updator.registrar.code) + xml.tag!('domain:upID', @domain.updator.registrar.code) if @domain.updator.try(:registrar).present? xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) end From 66799c8681bd2fa08c9dc290841a3e2508475f3c Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 14:11:21 +0200 Subject: [PATCH 46/98] Story #109367694 - use creator or updator as string, when registrar can not be found --- app/views/epp/contacts/info.xml.builder | 10 ++++++++-- app/views/epp/domains/info.xml.builder | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 965e2340a..9410368bb 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -48,11 +48,17 @@ xml.epp_head do xml.tag!('contact:clID', @contact.registrar.try(:code)) - xml.tag!('contact:crID', @contact.creator.registrar.try(:code)) + # EPP requires a creator ID, which should be registrar code if we have one + crID = contact.creator.try(:registrar) + crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? + crID = contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only + xml.tag!('contact:crID', crID) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.registrar.code) if @contact.updator.try(:registrar).present? + upID = contact.updator.try(:registrar) + upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? + xml.tag!('contact:upID', upID) if upID.present? # optional upID xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 181eabc67..11ab2441f 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -38,11 +38,17 @@ xml.epp_head do xml.tag!('domain:clID', @domain.registrar.code) - xml.tag!('domain:crID', @domain.creator.registrar.code) if @domain.creator + # EPP requires a creator ID, which should be registrar code if we have one + crID = @domain.creator.try(:registrar) + crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? + crID = @domain.creator unless crID.present? # Fallback if we failed, maybe this is a string only + xml.tag!('domain:crID', crID) xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) if @domain.updated_at != @domain.created_at - xml.tag!('domain:upID', @domain.updator.registrar.code) if @domain.updator.try(:registrar).present? + upID = @domain.updator.try(:registrar) + upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? + xml.tag!('domain:upID', upID) if upID.present? # optional upID xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) end From f927e7c79f9469bf364b8b745138bdc8278c42a5 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 14:30:04 +0200 Subject: [PATCH 47/98] Story #109367694 - restore missing punctuation --- app/views/epp/contacts/info.xml.builder | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 9410368bb..5b501fc75 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -49,14 +49,14 @@ xml.epp_head do xml.tag!('contact:clID', @contact.registrar.try(:code)) # EPP requires a creator ID, which should be registrar code if we have one - crID = contact.creator.try(:registrar) + crID = @contact.creator.try(:registrar) crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? - crID = contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only + crID = @contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only xml.tag!('contact:crID', crID) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at - upID = contact.updator.try(:registrar) + upID = @contact.updator.try(:registrar) upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? xml.tag!('contact:upID', upID) if upID.present? # optional upID xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) From 5979cc4b8b1c2c94529b92daf7f9dbc90ea2c4cb Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 15:27:42 +0200 Subject: [PATCH 48/98] Story #109367694 - add support for imported data, name was used --- app/models/concerns/versions.rb | 34 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index 2cbdca838..b0ac97434 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -22,32 +22,30 @@ module Versions def creator return nil if creator_str.blank? - - if creator_str =~ /^\d+-AdminUser:/ - creator = AdminUser.find_by(id: creator_str) - elsif creator_str =~ /^\d+-ApiUser:/ - creator = ApiUser.find_by(id: creator_str) - elsif creator_str =~ /^\d+-api-/ # depricated - creator = ApiUser.find_by(id: creator_str) - end - + creator = user_from_id_class_name creator_str creator.present? ? creator : creator_str end def updator return nil if updator_str.blank? - - if updator_str =~ /^\d+-AdminUser:/ - updator = AdminUser.find_by(id: updator_str) - elsif updator_str =~ /^\d+-ApiUser:/ - updator = ApiUser.find_by(id: updator_str) - elsif updator_str =~ /^\d+-api-/ # depricated - updator = ApiUser.find_by(id: updator_str) - end - + updator = user_from_id_class_name updator_str updator.present? ? updator : updator_str end + def user_from_id_class_name(str) + user = ApiUser.find_by(id: $1) if str =~ /^(\d+)-(ApiUser:|api-)/ + unless user.present? + user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/ + unless user.present? + # on import we copied Registrar name, which may eql code + registrar = Registrar.find_by(name: str).first + # assume each registrar has only one user + user = registrar.api_users.first if registrar + end + end + user + end + # callbacks def touch_domain_version domain.try(:touch_with_version) From 054058416fffa592c22f4cd77258c86c41e2f5b7 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 15:38:48 +0200 Subject: [PATCH 49/98] Story 109367694 - refactor method name --- app/controllers/application_controller.rb | 2 +- app/models/epp/domain.rb | 2 +- app/models/user.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index de54dafc5..5d051377d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -67,7 +67,7 @@ class ApplicationController < ActionController::Base end def user_log_str(user) - user.nil? ? 'public' : user.string + user.nil? ? 'public' : user.id_role_username end def comma_support_for(parent_key, key) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 5339b8695..ec519faf5 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -503,7 +503,7 @@ class Epp::Domain < Domain old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) - ::PaperTrail.whodunnit = user.string # updator str should be the request originator not the approval user + ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here diff --git a/app/models/user.rb b/app/models/user.rb index 5d415230c..b69e0250c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < ActiveRecord::Base attr_accessor :phone - def string + def id_role_username "#{self.id}-#{self.class}: #{self.username}" end From e77a84a4333136d8ce081d0d53f33c29912d48de Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 15:40:33 +0200 Subject: [PATCH 50/98] Story 109367694 - refactor method name also --- app/models/concerns/versions.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index b0ac97434..ae2dabf6a 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -22,17 +22,17 @@ module Versions def creator return nil if creator_str.blank? - creator = user_from_id_class_name creator_str + creator = user_from_id_role_username creator_str creator.present? ? creator : creator_str end def updator return nil if updator_str.blank? - updator = user_from_id_class_name updator_str + updator = user_from_id_role_username updator_str updator.present? ? updator : updator_str end - def user_from_id_class_name(str) + def user_from_id_role_username(str) user = ApiUser.find_by(id: $1) if str =~ /^(\d+)-(ApiUser:|api-)/ unless user.present? user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/ From 782c06caddeb2427f4b76aeb7b092c7c5fc5abe0 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 17:57:19 +0200 Subject: [PATCH 51/98] Story #109367694 - misplaced first --- app/models/concerns/versions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index ae2dabf6a..768cf021e 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -38,7 +38,7 @@ module Versions user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/ unless user.present? # on import we copied Registrar name, which may eql code - registrar = Registrar.find_by(name: str).first + registrar = Registrar.find_by(name: str) # assume each registrar has only one user user = registrar.api_users.first if registrar end From 5aa0ae64239bcf1f6f4f131a9d6efa1dcd5bc549 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:41:44 +0200 Subject: [PATCH 52/98] Story #109367694 - add better support for cr_id --- app/models/concerns/user_events.rb | 12 ++++++++++++ app/models/version/contact_version.rb | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index 12ff18444..9d87b4d71 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -1,6 +1,18 @@ module UserEvents extend ActiveSupport::Concern + def cr_id + if versions.first.object.nil? + cr_registrar_id =versions.first.object_changes['registrar_id'].second + else + # untested, expected never to execute + cr_registrar_id = versions.first.object['registrar_id'] + end + if cr_registrar_id.present? + Registrar.find(cr_registrar_id).code + end + end + # TODO: remove old # module ClassMethods # def registrar_events(id) diff --git a/app/models/version/contact_version.rb b/app/models/version/contact_version.rb index 987dbc1fd..4b7e38364 100644 --- a/app/models/version/contact_version.rb +++ b/app/models/version/contact_version.rb @@ -3,7 +3,7 @@ class ContactVersion < PaperTrail::Version self.table_name = :log_contacts self.sequence_name = :log_contacts_id_seq - # include UserEvents + include UserEvents # scope :deleted, -> { where(event: 'destroy') } end From 026c50b3ecb28df42f33a1e2a56fb2f1ded6f201 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 09:51:27 +0200 Subject: [PATCH 53/98] Story #109367694 - remove dead code, unused since 30.1.15 --- app/models/concerns/user_events.rb | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index 9d87b4d71..322bda66f 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -13,23 +13,4 @@ module UserEvents end end - # TODO: remove old - # module ClassMethods - # def registrar_events(id) - # registrar = Registrar.find(id) - # return [] unless registrar - # @events = [] - # registrar.users.each { |user| @events << user_events(user.id) } - # registrar.epp_users.each { |user| @events << epp_user_events(user.id) } - # @events - # end - - # def user_events(id) - # where(whodunnit: id.to_s) - # end - - # def epp_user_events(id) - # where(whodunnit: "#{id}-EppUser") - # end - # end end From 6cf2474837b210cf52c152b39c37db551389594b Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 09:58:09 +0200 Subject: [PATCH 54/98] Story #109367694 - relocate whodunit to capture save of admin approves update --- app/models/epp/domain.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index ec519faf5..d23f91013 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -503,10 +503,11 @@ class Epp::Domain < Domain old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) - ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here + ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user + self.save return unless update(frame, user, false) clean_pendings! From 92a6285ef57be06b62886f2fdcd9de8fd40b9065 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 10:20:31 +0200 Subject: [PATCH 55/98] Story #109367694 - let cr_id try creator string before searching history, because it did that before. TODO: performance test and maybe reverse that order --- app/models/concerns/user_events.rb | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index 322bda66f..6cf8e9ac6 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -1,15 +1,26 @@ module UserEvents extend ActiveSupport::Concern + # EPP requires a server defined creator ID, which should be registrar code if we have one def cr_id - if versions.first.object.nil? - cr_registrar_id =versions.first.object_changes['registrar_id'].second + # try this, rebuild user for registrar before searching history? really? + registrar = self.creator.try(:registrar) + if registrar.present? # Did creator return a kind of User that has a registrar? + registrar.code else - # untested, expected never to execute - cr_registrar_id = versions.first.object['registrar_id'] - end - if cr_registrar_id.present? - Registrar.find(cr_registrar_id).code + if versions.first.object.nil? + cr_registrar_id =versions.first.object_changes['registrar_id'].second + else + # untested, expected never to execute + cr_registrar_id = versions.first.object['registrar_id'] + end + + if cr_registrar_id.present? + Registrar.find(cr_registrar_id).code + else + # cr_id optional for domain, but required for contact; but we want something here anyway + self.creator_str # Fallback if we failed, maybe we can find a string here + end end end From b4f834e33a9aea202e8b667538c1455e249976b4 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 11:27:18 +0200 Subject: [PATCH 56/98] Story #109367694 - use cr_id in EPP info response --- app/views/epp/contacts/info.xml.builder | 6 +----- app/views/epp/domains/info.xml.builder | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 5b501fc75..39aa91b39 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -48,11 +48,7 @@ xml.epp_head do xml.tag!('contact:clID', @contact.registrar.try(:code)) - # EPP requires a creator ID, which should be registrar code if we have one - crID = @contact.creator.try(:registrar) - crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? - crID = @contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only - xml.tag!('contact:crID', crID) + xml.tag!('contact:crID', @contact.cr_id) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 11ab2441f..ec5947b13 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -38,11 +38,7 @@ xml.epp_head do xml.tag!('domain:clID', @domain.registrar.code) - # EPP requires a creator ID, which should be registrar code if we have one - crID = @domain.creator.try(:registrar) - crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? - crID = @domain.creator unless crID.present? # Fallback if we failed, maybe this is a string only - xml.tag!('domain:crID', crID) + xml.tag!('domain:crID', @domain.cr_id) xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) if @domain.updated_at != @domain.created_at From 1cefe4ed5fa710371974bb90ed93ef7aca9c1c66 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 11:28:26 +0200 Subject: [PATCH 57/98] Story #109367694 - refactor: move UserEvents include up, wrap method in included block, say self --- app/models/concerns/user_events.rb | 37 +++++++++++++++------------ app/models/contact.rb | 1 + app/models/domain.rb | 1 + app/models/version/contact_version.rb | 4 +-- app/models/version/domain_version.rb | 2 -- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index 6cf8e9ac6..25a225e8b 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -1,25 +1,28 @@ module UserEvents extend ActiveSupport::Concern - # EPP requires a server defined creator ID, which should be registrar code if we have one - def cr_id - # try this, rebuild user for registrar before searching history? really? - registrar = self.creator.try(:registrar) - if registrar.present? # Did creator return a kind of User that has a registrar? - registrar.code - else - if versions.first.object.nil? - cr_registrar_id =versions.first.object_changes['registrar_id'].second + included do + # EPP requires a server defined creator ID, which should be registrar code if we have one + def cr_id + # try this, rebuild user for registrar before searching history? really? + registrar = self.creator.try(:registrar) + if registrar.present? # Did creator return a kind of User that has a registrar? + registrar.code else - # untested, expected never to execute - cr_registrar_id = versions.first.object['registrar_id'] - end + if self.versions.first.try(:object).nil? + changes = self.versions.first.try(:object_changes) + cr_registrar_id = changes['registrar_id'].second if changes.present? + else + # untested, expected never to execute + cr_registrar_id = self.versions.first.object['registrar_id'] + end - if cr_registrar_id.present? - Registrar.find(cr_registrar_id).code - else - # cr_id optional for domain, but required for contact; but we want something here anyway - self.creator_str # Fallback if we failed, maybe we can find a string here + if cr_registrar_id.present? + Registrar.find(cr_registrar_id).code + else + # cr_id optional for domain, but required for contact; but we want something here anyway + self.creator_str # Fallback if we failed, maybe we can find a string here + end end end end diff --git a/app/models/contact.rb b/app/models/contact.rb index 1d6f069e5..d17ec2354 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -1,6 +1,7 @@ class Contact < ActiveRecord::Base include Versions # version/contact_version.rb include EppErrors + include UserEvents belongs_to :registrar has_many :domain_contacts diff --git a/app/models/domain.rb b/app/models/domain.rb index 780ff3b7a..22595cd3a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -1,5 +1,6 @@ # rubocop: disable Metrics/ClassLength class Domain < ActiveRecord::Base + include UserEvents include Versions # version/domain_version.rb include Statuses has_paper_trail class_name: "DomainVersion", meta: { children: :children_log } diff --git a/app/models/version/contact_version.rb b/app/models/version/contact_version.rb index 4b7e38364..781813302 100644 --- a/app/models/version/contact_version.rb +++ b/app/models/version/contact_version.rb @@ -2,8 +2,6 @@ class ContactVersion < PaperTrail::Version include VersionSession self.table_name = :log_contacts self.sequence_name = :log_contacts_id_seq - - include UserEvents - + # scope :deleted, -> { where(event: 'destroy') } end diff --git a/app/models/version/domain_version.rb b/app/models/version/domain_version.rb index 5bc25f1e1..2986d7811 100644 --- a/app/models/version/domain_version.rb +++ b/app/models/version/domain_version.rb @@ -4,7 +4,5 @@ class DomainVersion < PaperTrail::Version self.table_name = :log_domains self.sequence_name = :log_domains_id_seq - include UserEvents - scope :deleted, -> { where(event: 'destroy') } end From ac04a94b6a4054cd428406166ddd3e8e0bbb4ebe Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 12:58:11 +0200 Subject: [PATCH 58/98] Story #109367694 - changed xml text for elements crID, clID and upID --- app/views/epp/contacts/info.xml.builder | 12 +++++------- app/views/epp/domains/info.xml.builder | 13 ++++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 18019208a..3790544e1 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -46,15 +46,13 @@ xml.epp_head do xml.tag!('contact:email', 'No access') end - xml.tag!('contact:clID', @contact.registrar.try(:name)) - if @contact.creator.try(:registrar).blank? && Rails.env.test? - xml.tag!('contact:crID', 'TEST-CREATOR') - else - xml.tag!('contact:crID', @contact.creator.try(:registrar)) - end + xml.tag!('contact:clID', @contact.registrar.try(:code)) + + xml.tag!('contact:crID', @contact.creator.registrar.try(:code)) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) + if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.try(:registrar)) + xml.tag!('contact:upID', @contact.updator.registrar.code) xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 9e1779921..fd6bfeeb6 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -36,19 +36,18 @@ xml.epp_head do ## TODO Find out what this domain:host is all about - xml.tag!('domain:clID', @domain.registrar_name) - - xml.tag!('domain:crID', @domain.creator.try(:registrar)) if @domain.creator + xml.tag!('domain:clID', @domain.registrar.code) + xml.tag!('domain:crID', @domain.creator.registrar.code) if @domain.creator xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) - xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) if @domain.updated_at != @domain.created_at + if @domain.updated_at != @domain.created_at + xml.tag!('domain:upID', @domain.updator.registrar.code) + xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) + end xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601)) - # TODO Make domain stampable - #xml.tag!('domain:upID', @domain.updated_by) - # TODO Make domain transferrable #xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at From 18c643ee8d75f5e2adb529a82387836ed489d5e5 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:29:02 +0200 Subject: [PATCH 59/98] Story #109367694 - refactor user log string to user for paper trail creator_str --- app/controllers/application_controller.rb | 3 +-- app/models/user.rb | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 318923e3d..de54dafc5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -67,8 +67,7 @@ class ApplicationController < ActionController::Base end def user_log_str(user) - return 'public' if user.nil? - "#{user.id}-#{user.class}: #{user.username}" + user.nil? ? 'public' : user.string end def comma_support_for(parent_key, key) diff --git a/app/models/user.rb b/app/models/user.rb index 0beb174f3..5d415230c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,4 +3,9 @@ class User < ActiveRecord::Base devise :trackable, :timeoutable attr_accessor :phone + + def string + "#{self.id}-#{self.class}: #{self.username}" + end + end From c74de1b2bd22a4f7b5a9fdfa4ae47787e534143b Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:30:56 +0200 Subject: [PATCH 60/98] Story #109367694 - reset updator_str for pendingUpdate to update requestor requires prior commit e15ab3421d4b814eec6e4ece051e8d22cacff3b8 --- app/models/epp/domain.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 739c55bec..5339b8695 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -503,6 +503,7 @@ class Epp::Domain < Domain old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) + ::PaperTrail.whodunnit = user.string # updator str should be the request originator not the approval user frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here From 01ed0cedb9f1973463b9125b00f306ef1bd5fca0 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:40:13 +0200 Subject: [PATCH 61/98] Story #109367694 - make upID optional to avoid possible error for AdminUser objects have no registar method --- app/views/epp/contacts/info.xml.builder | 2 +- app/views/epp/domains/info.xml.builder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 3790544e1..965e2340a 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -52,7 +52,7 @@ xml.epp_head do xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.registrar.code) + xml.tag!('contact:upID', @contact.updator.registrar.code) if @contact.updator.try(:registrar).present? xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index fd6bfeeb6..181eabc67 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -42,7 +42,7 @@ xml.epp_head do xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) if @domain.updated_at != @domain.created_at - xml.tag!('domain:upID', @domain.updator.registrar.code) + xml.tag!('domain:upID', @domain.updator.registrar.code) if @domain.updator.try(:registrar).present? xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) end From 3749c1e1b8b555dc93824cfade6178838a92bd6f Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 14:11:21 +0200 Subject: [PATCH 62/98] Story #109367694 - use creator or updator as string, when registrar can not be found --- app/views/epp/contacts/info.xml.builder | 10 ++++++++-- app/views/epp/domains/info.xml.builder | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 965e2340a..9410368bb 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -48,11 +48,17 @@ xml.epp_head do xml.tag!('contact:clID', @contact.registrar.try(:code)) - xml.tag!('contact:crID', @contact.creator.registrar.try(:code)) + # EPP requires a creator ID, which should be registrar code if we have one + crID = contact.creator.try(:registrar) + crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? + crID = contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only + xml.tag!('contact:crID', crID) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.registrar.code) if @contact.updator.try(:registrar).present? + upID = contact.updator.try(:registrar) + upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? + xml.tag!('contact:upID', upID) if upID.present? # optional upID xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 181eabc67..11ab2441f 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -38,11 +38,17 @@ xml.epp_head do xml.tag!('domain:clID', @domain.registrar.code) - xml.tag!('domain:crID', @domain.creator.registrar.code) if @domain.creator + # EPP requires a creator ID, which should be registrar code if we have one + crID = @domain.creator.try(:registrar) + crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? + crID = @domain.creator unless crID.present? # Fallback if we failed, maybe this is a string only + xml.tag!('domain:crID', crID) xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) if @domain.updated_at != @domain.created_at - xml.tag!('domain:upID', @domain.updator.registrar.code) if @domain.updator.try(:registrar).present? + upID = @domain.updator.try(:registrar) + upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? + xml.tag!('domain:upID', upID) if upID.present? # optional upID xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) end From 9332de407978c5f8a4c52b10303c984d6cc2ad11 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 14:30:04 +0200 Subject: [PATCH 63/98] Story #109367694 - restore missing punctuation --- app/views/epp/contacts/info.xml.builder | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 9410368bb..5b501fc75 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -49,14 +49,14 @@ xml.epp_head do xml.tag!('contact:clID', @contact.registrar.try(:code)) # EPP requires a creator ID, which should be registrar code if we have one - crID = contact.creator.try(:registrar) + crID = @contact.creator.try(:registrar) crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? - crID = contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only + crID = @contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only xml.tag!('contact:crID', crID) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at - upID = contact.updator.try(:registrar) + upID = @contact.updator.try(:registrar) upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? xml.tag!('contact:upID', upID) if upID.present? # optional upID xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) From 3f906b5ac6a42d2a31b0c6654df9ca1010292ef7 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 15:27:42 +0200 Subject: [PATCH 64/98] Story #109367694 - add support for imported data, name was used --- app/models/concerns/versions.rb | 34 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index 2cbdca838..b0ac97434 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -22,32 +22,30 @@ module Versions def creator return nil if creator_str.blank? - - if creator_str =~ /^\d+-AdminUser:/ - creator = AdminUser.find_by(id: creator_str) - elsif creator_str =~ /^\d+-ApiUser:/ - creator = ApiUser.find_by(id: creator_str) - elsif creator_str =~ /^\d+-api-/ # depricated - creator = ApiUser.find_by(id: creator_str) - end - + creator = user_from_id_class_name creator_str creator.present? ? creator : creator_str end def updator return nil if updator_str.blank? - - if updator_str =~ /^\d+-AdminUser:/ - updator = AdminUser.find_by(id: updator_str) - elsif updator_str =~ /^\d+-ApiUser:/ - updator = ApiUser.find_by(id: updator_str) - elsif updator_str =~ /^\d+-api-/ # depricated - updator = ApiUser.find_by(id: updator_str) - end - + updator = user_from_id_class_name updator_str updator.present? ? updator : updator_str end + def user_from_id_class_name(str) + user = ApiUser.find_by(id: $1) if str =~ /^(\d+)-(ApiUser:|api-)/ + unless user.present? + user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/ + unless user.present? + # on import we copied Registrar name, which may eql code + registrar = Registrar.find_by(name: str).first + # assume each registrar has only one user + user = registrar.api_users.first if registrar + end + end + user + end + # callbacks def touch_domain_version domain.try(:touch_with_version) From e5a0149d1eece940c0b6bb329e2bfbc1136fe3db Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 15:38:48 +0200 Subject: [PATCH 65/98] Story 109367694 - refactor method name --- app/controllers/application_controller.rb | 2 +- app/models/epp/domain.rb | 2 +- app/models/user.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index de54dafc5..5d051377d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -67,7 +67,7 @@ class ApplicationController < ActionController::Base end def user_log_str(user) - user.nil? ? 'public' : user.string + user.nil? ? 'public' : user.id_role_username end def comma_support_for(parent_key, key) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 5339b8695..ec519faf5 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -503,7 +503,7 @@ class Epp::Domain < Domain old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) - ::PaperTrail.whodunnit = user.string # updator str should be the request originator not the approval user + ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here diff --git a/app/models/user.rb b/app/models/user.rb index 5d415230c..b69e0250c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < ActiveRecord::Base attr_accessor :phone - def string + def id_role_username "#{self.id}-#{self.class}: #{self.username}" end From 4bc31bb285b75f1f7ac96b0e84d6630730f3ff29 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 15:40:33 +0200 Subject: [PATCH 66/98] Story 109367694 - refactor method name also --- app/models/concerns/versions.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index b0ac97434..ae2dabf6a 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -22,17 +22,17 @@ module Versions def creator return nil if creator_str.blank? - creator = user_from_id_class_name creator_str + creator = user_from_id_role_username creator_str creator.present? ? creator : creator_str end def updator return nil if updator_str.blank? - updator = user_from_id_class_name updator_str + updator = user_from_id_role_username updator_str updator.present? ? updator : updator_str end - def user_from_id_class_name(str) + def user_from_id_role_username(str) user = ApiUser.find_by(id: $1) if str =~ /^(\d+)-(ApiUser:|api-)/ unless user.present? user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/ From a2a4db0732b0a0b754c71ff2d87e7eb8e9bab844 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Fri, 4 Dec 2015 17:57:19 +0200 Subject: [PATCH 67/98] Story #109367694 - misplaced first --- app/models/concerns/versions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index ae2dabf6a..768cf021e 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -38,7 +38,7 @@ module Versions user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/ unless user.present? # on import we copied Registrar name, which may eql code - registrar = Registrar.find_by(name: str).first + registrar = Registrar.find_by(name: str) # assume each registrar has only one user user = registrar.api_users.first if registrar end From ceaa70fcfc802f443575eaacd58a8660be8af7dd Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:41:44 +0200 Subject: [PATCH 68/98] Story #109367694 - add better support for cr_id --- app/models/concerns/user_events.rb | 12 ++++++++++++ app/models/version/contact_version.rb | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index 12ff18444..9d87b4d71 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -1,6 +1,18 @@ module UserEvents extend ActiveSupport::Concern + def cr_id + if versions.first.object.nil? + cr_registrar_id =versions.first.object_changes['registrar_id'].second + else + # untested, expected never to execute + cr_registrar_id = versions.first.object['registrar_id'] + end + if cr_registrar_id.present? + Registrar.find(cr_registrar_id).code + end + end + # TODO: remove old # module ClassMethods # def registrar_events(id) diff --git a/app/models/version/contact_version.rb b/app/models/version/contact_version.rb index 987dbc1fd..4b7e38364 100644 --- a/app/models/version/contact_version.rb +++ b/app/models/version/contact_version.rb @@ -3,7 +3,7 @@ class ContactVersion < PaperTrail::Version self.table_name = :log_contacts self.sequence_name = :log_contacts_id_seq - # include UserEvents + include UserEvents # scope :deleted, -> { where(event: 'destroy') } end From b9f6380e4e2a059f51a23a96a2f903ecb25eb759 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 09:51:27 +0200 Subject: [PATCH 69/98] Story #109367694 - remove dead code, unused since 30.1.15 --- app/models/concerns/user_events.rb | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index 9d87b4d71..322bda66f 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -13,23 +13,4 @@ module UserEvents end end - # TODO: remove old - # module ClassMethods - # def registrar_events(id) - # registrar = Registrar.find(id) - # return [] unless registrar - # @events = [] - # registrar.users.each { |user| @events << user_events(user.id) } - # registrar.epp_users.each { |user| @events << epp_user_events(user.id) } - # @events - # end - - # def user_events(id) - # where(whodunnit: id.to_s) - # end - - # def epp_user_events(id) - # where(whodunnit: "#{id}-EppUser") - # end - # end end From 27482495d8a21daac3e375eb1c9fd27290e8e38d Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 09:58:09 +0200 Subject: [PATCH 70/98] Story #109367694 - relocate whodunit to capture save of admin approves update --- app/models/epp/domain.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index ec519faf5..d23f91013 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -503,10 +503,11 @@ class Epp::Domain < Domain old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) - ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here + ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user + self.save return unless update(frame, user, false) clean_pendings! From d63129059816f2a46cd51596d84b607fdeb7e5da Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 10:20:31 +0200 Subject: [PATCH 71/98] Story #109367694 - let cr_id try creator string before searching history, because it did that before. TODO: performance test and maybe reverse that order --- app/models/concerns/user_events.rb | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index 322bda66f..6cf8e9ac6 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -1,15 +1,26 @@ module UserEvents extend ActiveSupport::Concern + # EPP requires a server defined creator ID, which should be registrar code if we have one def cr_id - if versions.first.object.nil? - cr_registrar_id =versions.first.object_changes['registrar_id'].second + # try this, rebuild user for registrar before searching history? really? + registrar = self.creator.try(:registrar) + if registrar.present? # Did creator return a kind of User that has a registrar? + registrar.code else - # untested, expected never to execute - cr_registrar_id = versions.first.object['registrar_id'] - end - if cr_registrar_id.present? - Registrar.find(cr_registrar_id).code + if versions.first.object.nil? + cr_registrar_id =versions.first.object_changes['registrar_id'].second + else + # untested, expected never to execute + cr_registrar_id = versions.first.object['registrar_id'] + end + + if cr_registrar_id.present? + Registrar.find(cr_registrar_id).code + else + # cr_id optional for domain, but required for contact; but we want something here anyway + self.creator_str # Fallback if we failed, maybe we can find a string here + end end end From b7e560aacc013d7d2a7b2d9aa39e0d79e9158c27 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 11:27:18 +0200 Subject: [PATCH 72/98] Story #109367694 - use cr_id in EPP info response --- app/views/epp/contacts/info.xml.builder | 6 +----- app/views/epp/domains/info.xml.builder | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 5b501fc75..39aa91b39 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -48,11 +48,7 @@ xml.epp_head do xml.tag!('contact:clID', @contact.registrar.try(:code)) - # EPP requires a creator ID, which should be registrar code if we have one - crID = @contact.creator.try(:registrar) - crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? - crID = @contact.creator unless crID.present? # Fallback if we failed, maybe this is a string only - xml.tag!('contact:crID', crID) + xml.tag!('contact:crID', @contact.cr_id) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 11ab2441f..ec5947b13 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -38,11 +38,7 @@ xml.epp_head do xml.tag!('domain:clID', @domain.registrar.code) - # EPP requires a creator ID, which should be registrar code if we have one - crID = @domain.creator.try(:registrar) - crID = crID.code if crID.present? # Did creator return a kind of User that has a registrar? - crID = @domain.creator unless crID.present? # Fallback if we failed, maybe this is a string only - xml.tag!('domain:crID', crID) + xml.tag!('domain:crID', @domain.cr_id) xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) if @domain.updated_at != @domain.created_at From 7b2767eb085010535bcf1a1965189f9c20b78aca Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 11:28:26 +0200 Subject: [PATCH 73/98] Story #109367694 - refactor: move UserEvents include up, wrap method in included block, say self --- app/models/concerns/user_events.rb | 37 +++++++++++++++------------ app/models/contact.rb | 1 + app/models/domain.rb | 1 + app/models/version/contact_version.rb | 4 +-- app/models/version/domain_version.rb | 2 -- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index 6cf8e9ac6..25a225e8b 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -1,25 +1,28 @@ module UserEvents extend ActiveSupport::Concern - # EPP requires a server defined creator ID, which should be registrar code if we have one - def cr_id - # try this, rebuild user for registrar before searching history? really? - registrar = self.creator.try(:registrar) - if registrar.present? # Did creator return a kind of User that has a registrar? - registrar.code - else - if versions.first.object.nil? - cr_registrar_id =versions.first.object_changes['registrar_id'].second + included do + # EPP requires a server defined creator ID, which should be registrar code if we have one + def cr_id + # try this, rebuild user for registrar before searching history? really? + registrar = self.creator.try(:registrar) + if registrar.present? # Did creator return a kind of User that has a registrar? + registrar.code else - # untested, expected never to execute - cr_registrar_id = versions.first.object['registrar_id'] - end + if self.versions.first.try(:object).nil? + changes = self.versions.first.try(:object_changes) + cr_registrar_id = changes['registrar_id'].second if changes.present? + else + # untested, expected never to execute + cr_registrar_id = self.versions.first.object['registrar_id'] + end - if cr_registrar_id.present? - Registrar.find(cr_registrar_id).code - else - # cr_id optional for domain, but required for contact; but we want something here anyway - self.creator_str # Fallback if we failed, maybe we can find a string here + if cr_registrar_id.present? + Registrar.find(cr_registrar_id).code + else + # cr_id optional for domain, but required for contact; but we want something here anyway + self.creator_str # Fallback if we failed, maybe we can find a string here + end end end end diff --git a/app/models/contact.rb b/app/models/contact.rb index 1d6f069e5..d17ec2354 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -1,6 +1,7 @@ class Contact < ActiveRecord::Base include Versions # version/contact_version.rb include EppErrors + include UserEvents belongs_to :registrar has_many :domain_contacts diff --git a/app/models/domain.rb b/app/models/domain.rb index 780ff3b7a..22595cd3a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -1,5 +1,6 @@ # rubocop: disable Metrics/ClassLength class Domain < ActiveRecord::Base + include UserEvents include Versions # version/domain_version.rb include Statuses has_paper_trail class_name: "DomainVersion", meta: { children: :children_log } diff --git a/app/models/version/contact_version.rb b/app/models/version/contact_version.rb index 4b7e38364..781813302 100644 --- a/app/models/version/contact_version.rb +++ b/app/models/version/contact_version.rb @@ -2,8 +2,6 @@ class ContactVersion < PaperTrail::Version include VersionSession self.table_name = :log_contacts self.sequence_name = :log_contacts_id_seq - - include UserEvents - + # scope :deleted, -> { where(event: 'destroy') } end diff --git a/app/models/version/domain_version.rb b/app/models/version/domain_version.rb index 5bc25f1e1..2986d7811 100644 --- a/app/models/version/domain_version.rb +++ b/app/models/version/domain_version.rb @@ -4,7 +4,5 @@ class DomainVersion < PaperTrail::Version self.table_name = :log_domains self.sequence_name = :log_domains_id_seq - include UserEvents - scope :deleted, -> { where(event: 'destroy') } end From 6fe813e6850cf15c989d778e8b40d551a4d27d68 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 12:00:05 +0200 Subject: [PATCH 74/98] Story #109367694 - fix merge error --- app/models/epp/domain.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index d3699b118..40b374003 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -503,13 +503,12 @@ class Epp::Domain < Domain old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) - ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here - ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user self.save + ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user return unless update(frame, user, false) clean_pendings! self.deliver_emails = true # turn on email delivery From c83fa049c7a61fcbdde4e6535573dc1fd6d3dced Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 14 Dec 2015 18:09:38 +0200 Subject: [PATCH 75/98] 109818648-domains_destroy_change --- app/models/domain.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 780ff3b7a..6d20574ce 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -307,7 +307,7 @@ class Domain < ActiveRecord::Base c = 0 Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x| - Whois::Record.where('domain_id = ?', x.id).try(':destroy') + Whois::Record.where(domain_id: x.id).destroy_all destroy_with_message x STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by deleteCandidate ##{x.id} (#{x.name})\n" unless Rails.env.test? @@ -315,7 +315,7 @@ class Domain < ActiveRecord::Base end Domain.where('force_delete_at <= ?', Time.zone.now).each do |x| - Whois::Record.where('domain_id = ?', x.id).try(':destroy') + Whois::Record.where(domain_id: x.id).destroy_all destroy_with_message x STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by force delete time ##{x.id} (#{x.name})\n" unless Rails.env.test? c += 1 From 6842fbccd64ff2fbbe7d6dd499604add402d0f42 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 16 Dec 2015 11:37:02 +0200 Subject: [PATCH 76/98] 109818648-whois_view_change --- app/models/whois_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index 21db2bdc0..121677c4d 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -44,7 +44,7 @@ class WhoisRecord < ActiveRecord::Base h[:changed] = domain.updated_at.try(:to_s, :iso8601) h[:expire] = domain.valid_to.try(:to_date).try(:to_s) h[:outzone] = domain.outzone_at.try(:to_date).try(:to_s) - h[:delete] = domain.delete_at.try(:to_date).try(:to_s) + h[:delete] = [domain.delete_at, domain.force_delete_at].compact.min.try(:to_date).try(:to_s) h[:registrant] = domain.registrant.name From 369c0507ebae8f4ebf3e266e1b823c68b0e8d171 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 16:53:05 +0200 Subject: [PATCH 77/98] Story #109367018 - send mail about with old registrant name when pending update --- app/models/domain.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 988cd43e3..842293842 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -440,7 +440,6 @@ class Domain < ActiveRecord::Base end def pending_update! - old_registrant_id = registrant_id return true if pending_update? self.epp_pending_update = true # for epp @@ -452,8 +451,8 @@ class Domain < ActiveRecord::Base new_registrant_email = registrant.email new_registrant_name = registrant.name - DomainMailer.pending_update_request_for_old_registrant(id, old_registrant_id, deliver_emails).deliver - DomainMailer.pending_update_notification_for_new_registrant(id, old_registrant_id, deliver_emails).deliver + DomainMailer.pending_update_request_for_old_registrant(id, registrant_id_was, deliver_emails).deliver + DomainMailer.pending_update_notification_for_new_registrant(id, registrant_id_was, deliver_emails).deliver reload # revert back to original From 2c916001ad2cf1707078e69be85c8704458287b5 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Tue, 15 Dec 2015 09:24:41 +0200 Subject: [PATCH 78/98] Story #109367018 - poll_pending_update_rejected_by_registrant typo --- config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 16e643b16..b441f8fd3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -904,7 +904,7 @@ en: edit_zone: 'Edit zone' there_are_count_domains_in_this_zone: 'There are %{count} domains in this zone' poll_pending_update_confirmed_by_registrant: 'Registrant confirmed domain update' - poll_pending_update_rejected_by_registranti: 'Registrant rejected domain update' + poll_pending_update_rejected_by_registrant: 'Registrant rejected domain update' poll_pending_delete_rejected_by_registrant: 'Registrant rejected domain deletion' poll_pending_delete_confirmed_by_registrant: 'Registrant confirmed domain deletion' manage: Manage From 51a579891401964bf37f90d10f97deccda689566 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 16 Dec 2015 16:14:05 +0200 Subject: [PATCH 79/98] Story #109367018 - add new model to handle domain values are changing, and need to be captured now, not later New model will provide data to DomainMailer customized as needed for the invocation reason as passed via symbol to send_mail(). The mail templetes then required modification to use the new data model. This should handle all the data errors in the update process, including pendingUpdate, confirmed, rejected or expired. --- app/jobs/domain_update_confirm_job.rb | 24 +-- app/mailers/domain_mailer.rb | 128 +++---------- app/models/domain.rb | 11 +- app/models/domain_mail_model.rb | 176 ++++++++++++++++++ app/models/epp/domain.rb | 5 +- ...d_notification_for_new_registrant.html.erb | 8 +- ...d_notification_for_new_registrant.text.erb | 8 +- ...e_notification_for_new_registrant.html.erb | 42 ++--- ...e_notification_for_new_registrant.text.erb | 42 ++--- ...d_notification_for_new_registrant.html.erb | 8 +- ...d_notification_for_new_registrant.text.erb | 8 +- ...update_request_for_old_registrant.html.erb | 36 ++-- ...update_request_for_old_registrant.text.erb | 36 ++-- ...d_notification_for_new_registrant.html.erb | 36 ++-- ...d_notification_for_new_registrant.text.erb | 36 ++-- ...d_notification_for_old_registrant.html.erb | 8 +- ...d_notification_for_old_registrant.text.erb | 8 +- 17 files changed, 366 insertions(+), 254 deletions(-) create mode 100644 app/models/domain_mail_model.rb diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 28294ef25..4f2c1e9ad 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -4,18 +4,18 @@ class DomainUpdateConfirmJob < Que::Job ActiveRecord::Base.transaction do domain = Epp::Domain.find(domain_id) case action - when RegistrantVerification::CONFIRMED - domain.poll_message!(:poll_pending_update_confirmed_by_registrant) - domain.apply_pending_update! do |e| - e.instance_variable_set("@changed_attributes", e.changed_attributes.merge("statuses"=>[])) - end - domain.clean_pendings! - when RegistrantVerification::REJECTED - DomainMailer.pending_update_rejected_notification_for_new_registrant(domain_id).deliver - domain.poll_message!(:poll_pending_update_rejected_by_registrant) - domain.clean_pendings! - domain.instance_variable_set("@changed_attributes", domain.changed_attributes.merge("statuses"=>[])) - domain.save + when RegistrantVerification::CONFIRMED + domain.poll_message!(:poll_pending_update_confirmed_by_registrant) + domain.apply_pending_update! do |e| + e.instance_variable_set("@changed_attributes", e.changed_attributes.merge("statuses"=>[])) + end + domain.clean_pendings! + when RegistrantVerification::REJECTED + domain.send_mail :pending_update_rejected_notification_for_new_registrant + domain.poll_message!(:poll_pending_update_rejected_by_registrant) + domain.clean_pendings! + domain.instance_variable_set("@changed_attributes", domain.changed_attributes.merge("statuses"=>[])) + domain.save end destroy # it's best to destroy the job in the same transaction end diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 3788dd510..4963cb02a 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -1,109 +1,41 @@ class DomainMailer < ApplicationMailer include Que::Mailer - def pending_update_request_for_old_registrant(domain_id, old_registrant_id, should_deliver) - @domain = Domain.find_by(id: domain_id) - @old_registrant = Registrant.find(old_registrant_id) - return unless @domain - return if delivery_off?(@domain, should_deliver) - - if @domain.registrant_verification_token.blank? - logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}" - return - end - - if @domain.registrant_verification_asked_at.blank? - logger.warn "EMAIL NOT DELIVERED: registrant_verification_asked_at is missing for #{@domain.name}" - return - end - - confirm_path = "#{ENV['registrant_url']}/registrant/domain_update_confirms" - @verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}" - - return if whitelist_blocked?(@old_registrant.email) - mail(to: format(@old_registrant.email), - subject: "#{I18n.t(:pending_update_request_for_old_registrant_subject, - name: @domain.name)} [#{@domain.name}]") + def pending_update_request_for_old_registrant(params) + compose_from(params) end - def pending_update_notification_for_new_registrant(domain_id, old_registrant_id, should_deliver) - @domain = Domain.find_by(id: domain_id) - @old_registrant = Registrant.find(old_registrant_id) - return unless @domain - return if delivery_off?(@domain, should_deliver) + def pending_update_notification_for_new_registrant(params) + compose_from(params) + end - if @domain.registrant_verification_token.blank? - logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}" + def registrant_updated_notification_for_new_registrant(params) + compose_from(params) + end + + def registrant_updated_notification_for_old_registrant(params) + compose_from(params) + end + + def pending_update_rejected_notification_for_new_registrant(params) + compose_from(params) + end + + def pending_update_expired_notification_for_new_registrant(params) + compose_from(params) + end + + # app/models/DomainMailModel provides the data for mail that can be composed_from + # which ensures that values of objects are captured when they are valid, not later when this method is executed + def compose_from(params) + @params = params + return if delivery_off?(params, params[:deliver_emails]) + return if whitelist_blocked?(params[:recipient]) + params[:errors].map do |error| + logger.warn error return end - - if @domain.registrant_verification_asked_at.blank? - logger.warn "EMAIL NOT DELIVERED: registrant_verification_asked_at is missing for #{@domain.name}" - return - end - - @new_registrant = @domain.registrant # NB! new registrant at this point - - return if whitelist_blocked?(@new_registrant.email) - mail(to: format(@new_registrant.email), - subject: "#{I18n.t(:pending_update_notification_for_new_registrant_subject, - name: @domain.name)} [#{@domain.name}]") - end - - def registrant_updated_notification_for_new_registrant(domain_id, should_deliver) - @domain = Domain.find_by(id: domain_id) - return unless @domain - return if delivery_off?(@domain, should_deliver) - - return if whitelist_blocked?(@domain.registrant_email) - mail(to: format(@domain.registrant_email), - subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject, - name: @domain.name)} [#{@domain.name}]") - end - - def registrant_updated_notification_for_old_registrant(domain_id, should_deliver) - domain = Domain.find_by(id: domain_id) - return unless domain - return if delivery_off?(@domain, should_deliver) - - @old_registrant_email = domain.registrant_email # Nb! before applying pending updates - - return if whitelist_blocked?(@old_registrant_email) - mail(to: format(@old_registrant_email), - subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject, - name: @domain.name)} [#{@domain.name}]") - end - - def pending_update_rejected_notification_for_new_registrant(domain_id) - @domain = Domain.find_by(id: domain_id) - return unless @domain - # no delivery off control, driggered by que, no epp request - - @new_registrant_email = @domain.pending_json['new_registrant_email'] - @new_registrant_name = @domain.pending_json['new_registrant_name'] - - return if whitelist_blocked?(@new_registrant_email) - mail(to: format(@new_registrant_email), - subject: "#{I18n.t(:pending_update_rejected_notification_for_new_registrant_subject, - name: @domain.name)} [#{@domain.name}]") - end - - def pending_update_expired_notification_for_new_registrant(domain_id) - @domain = Domain.find_by(id: domain_id) - return unless @domain - # no delivery off control, driggered by cron, no epp request - - @new_registrant_email = @domain.pending_json['new_registrant_email'] - @new_registrant_name = @domain.pending_json['new_registrant_name'] - - return if whitelist_blocked?(@new_registrant_email) - if @new_registrant_email.blank? - logger.info "EMAIL NOT DELIVERED: no registrant email [pending_update_expired_notification_for_new_registrant]" - return - end - mail(to: format(@new_registrant_email), - subject: "#{I18n.t(:pending_update_expired_notification_for_new_registrant_subject, - name: @domain.name)} [#{@domain.name}]") + mail(to: params[:recipient], subject: params[:subject]) end def pending_deleted(domain_id, old_registrant_id, should_deliver) diff --git a/app/models/domain.rb b/app/models/domain.rb index 842293842..d74eaf9a3 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -239,7 +239,7 @@ class Domain < ActiveRecord::Base end count += 1 if domain.pending_update? - DomainMailer.pending_update_expired_notification_for_new_registrant(domain.id).deliver + send_mail :pending_update_expired_notification_for_new_registrant end if domain.pending_delete? || domain.pending_delete_confirmation? DomainMailer.pending_delete_expired_notification(domain.id, true).deliver @@ -451,8 +451,8 @@ class Domain < ActiveRecord::Base new_registrant_email = registrant.email new_registrant_name = registrant.name - DomainMailer.pending_update_request_for_old_registrant(id, registrant_id_was, deliver_emails).deliver - DomainMailer.pending_update_notification_for_new_registrant(id, registrant_id_was, deliver_emails).deliver + send_mail :pending_update_request_for_old_registrant + send_mail :pending_update_notification_for_new_registrant reload # revert back to original @@ -818,5 +818,10 @@ class Domain < ActiveRecord::Base status_notes[status] = notes[i] end end + + def send_mail(action) + DomainMailer.send(action, DomainMailModel.new(self).send(action)).deliver + end + end # rubocop: enable Metrics/ClassLength diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb new file mode 100644 index 000000000..045ba4b3e --- /dev/null +++ b/app/models/domain_mail_model.rb @@ -0,0 +1,176 @@ +class DomainMailModel + # Capture current values used in app/views/mailers/domain_mailer/* and app/mailers/domain_mailer will send later + + def initialize(domain) + @domain = domain + @params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id} + end + + def pending_update_request_for_old_registrant + registrant_old + subject(:pending_update_request_for_old_registrant_subject) + confirm_update + domain_info + compose + end + + def pending_update_notification_for_new_registrant + # NB! new registrant at this point + registrant + subject(:pending_update_notification_for_new_registrant_subject) + domain_info + compose + end + + def registrant_updated_notification_for_new_registrant + registrant + subject(:registrant_updated_notification_for_new_registrant_subject) + domain_info + compose + end + + def registrant_updated_notification_for_old_registrant + registrant_old + subject(:registrant_updated_notification_for_old_registrant_subject) + registrant_name + compose + end + + def pending_update_rejected_notification_for_new_registrant + registrant_pending + subject(:pending_update_rejected_notification_for_new_registrant_subject) + @params[:deliver_emails] = true # trigger from que + @params[:registrar_name] = @domain.registrar.name + compose + end + + def pending_update_expired_notification_for_new_registrant + registrant_pending + subject(:pending_update_expired_notification_for_new_registrant_subject) + compose + end + + def pending_deleted + registrant + subject(:domain_pending_deleted_subject) + confirm_delete + compose + end + + def pending_delete_rejected_notification + registrant + subject(:pending_delete_rejected_notification_subject) + compose + end + + def pending_delete_expired_notification + registrant + subject(:pending_delete_expired_notification_subject) + compose + end + + def delete_confirmation + registrant + subject(:delete_confirmation_subject) + compose + end + + def force_delete + admins + subject(:force_delete_subject) + compose + end + + private + + def registrant_old + @params[:recipient] = format Registrant.find(@domain.registrant_id_was).email + end + + def registrant + @params[:recipient] = format @domain.registrant.email + end + + def registrant_name + @params[:registrant_name] = @domain.registrant.name + end + + def registrant_pending + @params[:new_registrant_emai] = @domain.pending_json['new_registrant_email'] + @params[:new_registrant_name] = @domain.pending_json['new_registrant_name'] + end + + # registrant and domain admin contacts + def admins + emails = ([@domain.registrant.email] + @domain.admin_contacts.map { |x| format(x.email) }) + @params[:recipient] = emails.uniq.map { |x| format(x) } + end + + # puny internet domain name, TODO: username + def format(email) + user, host = email.split('@') + host = SimpleIDN.to_ascii(host) + "#{user}@#{host}" + end + + def subject(subject) + @params[:name] = @domain.name + @params[:subject] = I18n.t(subject, name: @domain.name) + end + + def confirm_update + verification_url('domain_update_confirms') + end + + def confirm_delete + verification_url('domain_delete_confirms') + end + + def compose + @params + end + + #private + + def verification_url(path) + token = verification_token or return + @params[:verification_url] = "#{ENV['registrant_url']}/registrant/#{path}/#{@domain.id}?token=#{token}" + end + + def verification_token + return warn_missing(:registrant_verification_token) if @domain.registrant_verification_token.blank? + return warn_missing(:registrant_verification_asked_at) if @domain.registrant_verification_asked_at.blank? + @domain.registrant_verification_token + end + + def domain_info + [:name, :registrar_name, + :registrant_name, :registrant_ident, :registrant_email, + :registrant_street,:registrant_city, :registrant_country + ].each do |attr| + @params.store attr, @domain.send(attr) + end + @params.store :registrant_priv, @domain.registrant.priv? + @params.store old_registrant_name, Registrant.find(@domain.registrant_id_was).name + @params + end + + def warn_no_email(item) + #reason = "#{item.to_s} for #{@domain.name}" + warn_not_delivered item #reason + nil + end + + def warn_missing(item) + warn_not_delivered "#{item.to_s} is missing for #{@domain.name}" + end + + def warn_not_delivered(reason) + message = "EMAIL NOT DELIVERED: #{reason}" + @params[:errors] << message +# Rails.logger.warn message + nil + end + +end + diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 40b374003..189b5aa1c 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -500,7 +500,6 @@ class Epp::Domain < Domain # rubocop: enable Metrics/CyclomaticComplexity def apply_pending_update! - old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) frame = Nokogiri::XML(pending_json['frame']) @@ -512,8 +511,8 @@ class Epp::Domain < Domain return unless update(frame, user, false) clean_pendings! self.deliver_emails = true # turn on email delivery - DomainMailer.registrant_updated_notification_for_new_registrant(id, deliver_emails).deliver - old_registrant_email.deliver + send_mail :registrant_updated_notification_for_old_registrant + send_mail :registrant_updated_notification_for_new_registrant true end diff --git a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb index a8bf8723d..cfa539736 100644 --- a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb @@ -1,8 +1,8 @@ Tere,

-Domeeni <%= @domain.name %> registreerija <%= @domain.registrant_name %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @domain.name %> registreerija vahetus on sellest tulenevalt tühistatud. +Domeeni <%= @params[:name] %> registreerija <%= @params[:registrant_name] %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @params[:name] %> registreerija vahetus on sellest tulenevalt tühistatud.

-Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad

Lugupidamisega
Eesti Interneti SA @@ -11,9 +11,9 @@ Eesti Interneti SA

Hi,

-Domain registrant change has been expired for the domain <%= @domain.name %>. +Domain registrant change has been expired for the domain <%= @params[:name] %>.

-Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions.

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb index 020a9da65..626583562 100644 --- a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb @@ -1,8 +1,8 @@ Tere, -Domeeni <%= @domain.name %> registreerija <%= @domain.registrant_name %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @domain.name %> registreerija vahetus on sellest tulenevalt tühistatud. +Domeeni <%= @params[:name] %> registreerija <%= @params[:registrant_name] %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @params[:name] %> registreerija vahetus on sellest tulenevalt tühistatud. -Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad Lugupidamisega Eesti Interneti SA @@ -11,9 +11,9 @@ Eesti Interneti SA Hi, -Domain registrant change has been expired for the domain <%= @domain.name %>. +Domain registrant change has been expired for the domain <%= @params[:name] %>. -Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions. Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb index df31c9139..9f33535ea 100644 --- a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb @@ -1,25 +1,25 @@ Tere,

-Registripidaja <%= @domain.registrar_name %> vahendusel on algatatud <%= @domain.name %> domeeni omanikuvahetuse protseduur. +Registripidaja <%= @params[:registrar_name] %> vahendusel on algatatud <%= @params[:name] %> domeeni omanikuvahetuse protseduur.

-Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %> +Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %>

Uued registreerija andmed:
-Nimi: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> - Isikukood: <%= @domain.registrant_ident %>
+Nimi: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> + Isikukood: <%= @params[:registrant_ident] %>
<% else %> - Äriregistrikood: <%= @domain.registrant_ident %>
+ Äriregistrikood: <%= @params[:registrant_ident] %>
<% end %> -Tänav: <%= @domain.registrant_street %>
-Linn: <%= @domain.registrant_city %>
-Riik: <%= @domain.registrant_country %> +Tänav: <%= @params[:registrant_street] %>
+Linn: <%= @params[:registrant_city] %>
+Riik: <%= @params[:registrant_country] %>

-Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @old_registrant.name %> omanikuvahetuse tähtaegselt kinnitab. +Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @params[:old_registrant_name] %> omanikuvahetuse tähtaegselt kinnitab.

-Juhul kui <%= @old_registrant.name %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. +Juhul kui <%= @params[:old_registrant_name] %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse.

-Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad

Lugupidamisega
Eesti Interneti SA @@ -28,20 +28,20 @@ Eesti Interneti SA

Hi,

-Registrant change process for the domain <%= @domain.name %> has been started. +Registrant change process for the domain <%= @params[:name] %> has been started.

New registrant:
-Name: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %>
+Name: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %>
<% else %> -Business Registry code: <%= @domain.registrant_ident %>
+Business Registry code: <%= @params[:registrant_ident] %>
<% end %> -Street: <%= @domain.registrant_street %>
-City: <%= @domain.registrant_city %>
-Country: <%= @domain.registrant_country %> +Street: <%= @params[:registrant_street] %>
+City: <%= @params[:registrant_city] %>
+Country: <%= @params[:registrant_country] %>

-Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions.

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb index 80265c05f..1aa2d998d 100644 --- a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb @@ -1,25 +1,25 @@ Tere, -Registripidaja <%= @domain.registrar_name %> vahendusel on algatatud <%= @domain.name %> domeeni omanikuvahetuse protseduur. +Registripidaja <%= @params[:registrar_name] %> vahendusel on algatatud <%= @params[:name] %> domeeni omanikuvahetuse protseduur. -Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %> +Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %> Uued registreerija andmed: -Nimi: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Isikukood: <%= @domain.registrant_ident %> +Nimi: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %> <% else %> -Äriregistrikood: <%= @domain.registrant_ident %> +Äriregistrikood: <%= @params[:registrant_ident] %> <% end %> -Tänav: <%= @domain.registrant_street %> -Linn: <%= @domain.registrant_city %> -Riik: <%= @domain.registrant_country %> +Tänav: <%= @params[:registrant_street] %> +Linn: <%= @params[:registrant_city] %> +Riik: <%= @params[:registrant_country] %> -Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @old_registrant.name %> omanikuvahetuse tähtaegselt kinnitab. +Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @params[:old_registrant_name] %> omanikuvahetuse tähtaegselt kinnitab. -Juhul kui <%= @old_registrant.name %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. +Juhul kui <%= @params[:old_registrant_name] %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. -Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad Lugupidamisega Eesti Interneti SA @@ -28,20 +28,20 @@ Eesti Interneti SA Hi, -Registrant change process for the domain <%= @domain.name %> has been started. +Registrant change process for the domain <%= @params[:name] %> has been started. New registrant: -Name: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %> +Name: <%= @params[:registrant_name] %> +<% if @params[:registrant.priv?] %> +Personal code: <%= @params[:registrant_ident] %> <% else %> -Business Registry code: <%= @domain.registrant_ident %> +Business Registry code: <%= @params[:registrant_ident] %> <% end %> -Street: <%= @domain.registrant_street %> -City: <%= @domain.registrant_city %> -Country: <%= @domain.registrant_country %> +Street: <%= @params[:registrant_street] %> +City: <%= @params[:registrant_city] %> +Country: <%= @params[:registrant_country] %> -Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions. Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb index 94672f176..830b28b5b 100644 --- a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb @@ -1,8 +1,8 @@ Tere,

-Domeeni <%= @domain.name %> registreerija <%= @new_registrant_name %> on domeeni registreerija vahetamise taotluse tagasi lükanud. +Domeeni <%= @params[:name] %> registreerija <%= @params[:new_registrant_name] %> on domeeni registreerija vahetamise taotluse tagasi lükanud.

-Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad

Lugupidamisega,
Eesti Interneti SA @@ -11,9 +11,9 @@ Eesti Interneti SA

Hi,

-Registrant change was declined for the domain <%= @domain.name %>. +Registrant change was declined for the domain <%= @params[:name] %>.

-Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions.

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb index afdf06325..13cd089f2 100644 --- a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb @@ -1,8 +1,8 @@ Tere, -Domeeni <%= @domain.name %> registreerija <%= @new_registrant_name %> on domeeni registreerija vahetamise taotluse tagasi lükanud. +Domeeni <%= @params[:name] %> registreerija <%= @params[:new_registrant_name] %> on domeeni registreerija vahetamise taotluse tagasi lükanud. -Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad Lugupidamisega Eesti Interneti SA @@ -11,9 +11,9 @@ Eesti Interneti SA Hi, -Registrant change was declined for the domain <%= @domain.name %>. +Registrant change was declined for the domain <%= @params[:name] %>. -Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions. Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb index c62cb5561..5da14d96d 100644 --- a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb @@ -1,23 +1,23 @@ Tere,

-Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %> +Registrisse laekus taotlus domeeni <%= @params[:name] %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %>

Uued registreerija andmed:
-Nimi: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> -Isikukood: <%= @domain.registrant_ident %>
+Nimi: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %>
<% else %> -Äriregistrikood: <%= @domain.registrant_ident %>
+Äriregistrikood: <%= @params[:registrant_ident] %>
<% end %> -Tänav: <%= @domain.registrant_street %>
-Linn: <%= @domain.registrant_city %>
-Riik: <%= @domain.registrant_country %> +Tänav: <%= @params[:registrant_street] %>
+Linn: <%= @params[:registrant_city] %>
+Riik: <%= @params[:registrant_country] %>

Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka.

Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
-<%= link_to @verification_url, @verification_url %> +<%= link_to @params[:verification_url], @params[:verification_url] %>

Lugupidamisega
Eesti Interneti SA @@ -26,23 +26,23 @@ Eesti Interneti SA

Hi,

-Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @domain.registrar_name %> +Application for changing registrant of your domain <%= @params[:name] %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @params[:registrar_name] %>

New registrant:
-Name: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %>
+Name: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %>
<% else %> -Business Registry code: <%= @domain.registrant_ident %>
+Business Registry code: <%= @params[:registrant_ident] %>
<% end %> -Street: <%= @domain.registrant_street %>
-City: <%= @domain.registrant_city %>
-Country: <%= @domain.registrant_country %> +Street: <%= @params[:registrant_street] %>
+City: <%= @params[:registrant_city] %>
+Country: <%= @params[:registrant_country] %>

The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before.

To confirm the update please visit this website, once again review the data and press approve:
-<%= link_to @verification_url, @verification_url %> +<%= link_to @params[:verification_url], @params[:verification_url] %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb index 04a85bf5e..27e394b87 100644 --- a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb @@ -1,21 +1,21 @@ Tere, -Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %> +Registrisse laekus taotlus domeeni <%= @params[:name] %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %> Uued registreerija andmed: -Nimi: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Isikukood: <%= @domain.registrant_ident %> +Nimi: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %> <% else %> -Äriregistrikood: <%= @domain.registrant_ident %> +Äriregistrikood: <%= @params[:registrant_ident] %> <% end %> -Tänav: <%= @domain.registrant_street %> -Linn: <%= @domain.registrant_city %> -Riik: <%= @domain.registrant_country %> +Tänav: <%= @params[:registrant_street] %> +Linn: <%= @params[:registrant_city] %> +Riik: <%= @params[:registrant_country] %> Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka. Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan: -<%= @verification_url %> +<%= @params[:verification_url] %> Lugupidamisega Eesti Interneti SA @@ -24,22 +24,22 @@ Eesti Interneti SA Hi, -Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @domain.registrar_name %> +Application for changing registrant of your domain <%= @params[:name] %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @params[:registrar_name] %> New registrant: -Name: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %> +Name: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %> <% else %> -Business Registry code: <%= @domain.registrant_ident %> +Business Registry code: <%= @params[:registrant_ident] %> <% end %> -Street: <%= @domain.registrant_street %> -City: <%= @domain.registrant_city %> -Country: <%= @domain.registrant_country %> +Street: <%= @params[:registrant_street] %> +City: <%= @params[:registrant_city] %> +Country: <%= @params[:registrant_country] %> The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before. To confirm the update please visit this website, once again review the data and press approve: -<%= @verification_url %> +<%= @params[:verification_url] %> Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb index eb8352b8e..74021a489 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb @@ -1,18 +1,18 @@ Tere,

-Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

Uued registreerija andmed:
-Nimi: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> -Isikukood: <%= @domain.registrant_ident %>
+Nimi: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %>
<% else %> -Äriregistrikood: <%= @domain.registrant_ident %>
+Äriregistrikood: <%= @params[:registrant_ident] %>
<% end %> -Epost: <%= @domain.registrant_email %>
-Tänav: <%= @domain.registrant_street %>
-Linn: <%= @domain.registrant_city %>
-Riik: <%= @domain.registrant_country %> +Epost: <%= @params[:registrant_email] %>
+Tänav: <%= @params[:registrant_street] %>
+Linn: <%= @params[:registrant_city] %>
+Riik: <%= @params[:registrant_country] %>

Lugupidamisega
Eesti Interneti SA @@ -21,19 +21,19 @@ Eesti Interneti SA

Hi,

-Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.

New registrant:
-Name: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %>
+Name: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %>
<% else %> -Business Registry code: <%= @domain.registrant_ident %>
+Business Registry code: <%= @params[:registrant_ident] %>
<% end %> -E-mail: <%= @domain.registrant_email %>
-Street: <%= @domain.registrant_street %>
-City: <%= @domain.registrant_city %>
-Country: <%= @domain.registrant_country %> +E-mail: <%= @params[:registrant_email] %>
+Street: <%= @params[:registrant_street] %>
+City: <%= @params[:registrant_city] %>
+Country: <%= @params[:registrant_country] %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb index 503c111f6..279afa2b5 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb @@ -1,18 +1,18 @@ Tere, -Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. Uued registreerija andmed: -Nimi: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Isikukood: <%= @domain.registrant_ident %> +Nimi: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %> <% else %> -Äriregistrikood: <%= @domain.registrant_ident %> +Äriregistrikood: <%= @params[:registrant_ident] %> <% end %> -Epost: <%= @domain.registrant_email %> -Tänav: <%= @domain.registrant_street %> -Linn: <%= @domain.registrant_city %> -Riik: <%= @domain.registrant_country %> +Epost: <%= @params[:registrant_email] %> +Tänav: <%= @params[:registrant_street] %> +Linn: <%= @params[:registrant_city] %> +Riik: <%= @params[:registrant_country] %> Lugupidamisega Eesti Interneti SA @@ -21,19 +21,19 @@ Eesti Interneti SA Hi, -Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated. New registrant: -Name: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %> +Name: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %> <% else %> -Business Registry code: <%= @domain.registrant_ident %> +Business Registry code: <%= @params[:registrant_ident] %> <% end %> -E-mail: <%= @domain.registrant_email %> -Street: <%= @domain.registrant_street %> -City: <%= @domain.registrant_city %> -Country: <%= @domain.registrant_country %> +E-mail: <%= @params[:registrant_email] %> +Street: <%= @params[:registrant_street] %> +City: <%= @params[:registrant_city] %> +Country: <%= @params[:registrant_country] %> Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb index bdfda76dc..1ad338816 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb @@ -1,9 +1,9 @@ Tere,

-Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

Uued registreerija:
-Nimi: <%= @domain.registrant_name %> +Nimi: <%= @params[:registrant_name] %>

Lugupidamisega
Eesti Interneti SA @@ -12,10 +12,10 @@ Eesti Interneti SA

Hi,

-Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.

New registrant:
-Name: <%= @domain.registrant_name %> +Name: <%= @params[:registrant_name] %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb index 08fb37fe0..beae5cfd8 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb @@ -1,9 +1,9 @@ Tere, -Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. Uued registreerija: -Nimi: <%= @domain.registrant_name %> +Nimi: <%= @params[:registrant_name] %> Lugupidamisega Eesti Interneti SA @@ -12,10 +12,10 @@ Eesti Interneti SA Hi, -Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated. New registrant: -Name: <%= @domain.registrant_name %> +Name: <%= @params[:registrant_name] %> Best Regards, Estonian Internet Foundation From 504c4454c5fd05fc772c63c0a4a727da76db55c7 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 16 Dec 2015 17:53:08 +0200 Subject: [PATCH 80/98] Story #109367018 - minor bug fixes, missing punctuation, wrong symbol --- app/models/domain_mail_model.rb | 7 +++---- ...pending_update_notification_for_new_registrant.text.erb | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index 045ba4b3e..01d01a6dc 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -47,6 +47,7 @@ class DomainMailModel def pending_update_expired_notification_for_new_registrant registrant_pending subject(:pending_update_expired_notification_for_new_registrant_subject) + domain_info compose end @@ -96,7 +97,7 @@ class DomainMailModel end def registrant_pending - @params[:new_registrant_emai] = @domain.pending_json['new_registrant_email'] + @params[:recipient] = @domain.pending_json['new_registrant_email'] @params[:new_registrant_name] = @domain.pending_json['new_registrant_name'] end @@ -130,8 +131,6 @@ class DomainMailModel @params end - #private - def verification_url(path) token = verification_token or return @params[:verification_url] = "#{ENV['registrant_url']}/registrant/#{path}/#{@domain.id}?token=#{token}" @@ -151,7 +150,7 @@ class DomainMailModel @params.store attr, @domain.send(attr) end @params.store :registrant_priv, @domain.registrant.priv? - @params.store old_registrant_name, Registrant.find(@domain.registrant_id_was).name + @params.store :old_registrant_name, Registrant.find(@domain.registrant_id_was).name @params end diff --git a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb index 1aa2d998d..d7f2d7f9c 100644 --- a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb @@ -32,7 +32,7 @@ Registrant change process for the domain <%= @params[:name] %> has been started. New registrant: Name: <%= @params[:registrant_name] %> -<% if @params[:registrant.priv?] %> +<% if @params[:registrant_priv] %> Personal code: <%= @params[:registrant_ident] %> <% else %> Business Registry code: <%= @params[:registrant_ident] %> From 496bb8738d059cbdd3fc697f772f92f3862cb9c3 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 16 Dec 2015 18:15:14 +0200 Subject: [PATCH 81/98] Story #109367018 - warn if email missing, and format pending email --- app/models/domain_mail_model.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index 01d01a6dc..45c550f2d 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -97,7 +97,7 @@ class DomainMailModel end def registrant_pending - @params[:recipient] = @domain.pending_json['new_registrant_email'] + @params[:recipient] = format @domain.pending_json['new_registrant_email'] @params[:new_registrant_name] = @domain.pending_json['new_registrant_name'] end @@ -109,6 +109,7 @@ class DomainMailModel # puny internet domain name, TODO: username def format(email) + return warn_no_email if email.nil? user, host = email.split('@') host = SimpleIDN.to_ascii(host) "#{user}@#{host}" @@ -154,9 +155,8 @@ class DomainMailModel @params end - def warn_no_email(item) - #reason = "#{item.to_s} for #{@domain.name}" - warn_not_delivered item #reason + def warn_no_email(item = 'email') + warn_missing item nil end From 515226042c82ae453aa13b579a9aa86982afe591 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 16 Dec 2015 18:25:48 +0200 Subject: [PATCH 82/98] Story #109367018 - seems that pending_update_rejected_notification_for_new_registrant should name old registrant rejected change --- app/models/domain_mail_model.rb | 1 + ...ing_update_rejected_notification_for_new_registrant.html.erb | 2 +- ...ing_update_rejected_notification_for_new_registrant.text.erb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index 45c550f2d..fcb8ed6ca 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -99,6 +99,7 @@ class DomainMailModel def registrant_pending @params[:recipient] = format @domain.pending_json['new_registrant_email'] @params[:new_registrant_name] = @domain.pending_json['new_registrant_name'] + @params[:old_registrant_name] = @domain.registrant.name end # registrant and domain admin contacts diff --git a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb index 830b28b5b..1f9acf666 100644 --- a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb @@ -1,6 +1,6 @@ Tere,

-Domeeni <%= @params[:name] %> registreerija <%= @params[:new_registrant_name] %> on domeeni registreerija vahetamise taotluse tagasi lükanud. +Domeeni <%= @params[:name] %> registreerija <%= @params[:old_registrant_name] %> on domeeni registreerija vahetamise taotluse tagasi lükanud.

Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad

diff --git a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb index 13cd089f2..38a83e1b3 100644 --- a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb @@ -1,6 +1,6 @@ Tere, -Domeeni <%= @params[:name] %> registreerija <%= @params[:new_registrant_name] %> on domeeni registreerija vahetamise taotluse tagasi lükanud. +Domeeni <%= @params[:name] %> registreerija <%= @params[:old_registrant_name] %> on domeeni registreerija vahetamise taotluse tagasi lükanud. Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad From 783b792acf6f6ec684aa9f846f534eebf607a911 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 16 Dec 2015 20:20:32 +0200 Subject: [PATCH 83/98] Story #109367018 - ensure that updated notice goes to old registrant, but names new registrant --- app/models/domain_mail_model.rb | 11 +++-------- app/models/epp/domain.rb | 7 +++++-- ...t_updated_notification_for_old_registrant.html.erb | 4 ++-- ...t_updated_notification_for_old_registrant.text.erb | 4 ++-- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index fcb8ed6ca..96a7e2350 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -15,8 +15,7 @@ class DomainMailModel end def pending_update_notification_for_new_registrant - # NB! new registrant at this point - registrant + registrant # new registrant at this point subject(:pending_update_notification_for_new_registrant_subject) domain_info compose @@ -30,16 +29,16 @@ class DomainMailModel end def registrant_updated_notification_for_old_registrant + registrant_pending registrant_old subject(:registrant_updated_notification_for_old_registrant_subject) - registrant_name compose end def pending_update_rejected_notification_for_new_registrant registrant_pending subject(:pending_update_rejected_notification_for_new_registrant_subject) - @params[:deliver_emails] = true # trigger from que + @params[:deliver_emails] = true # triggered from que @params[:registrar_name] = @domain.registrar.name compose end @@ -92,10 +91,6 @@ class DomainMailModel @params[:recipient] = format @domain.registrant.email end - def registrant_name - @params[:registrant_name] = @domain.registrant.name - end - def registrant_pending @params[:recipient] = format @domain.pending_json['new_registrant_email'] @params[:new_registrant_name] = @domain.pending_json['new_registrant_name'] diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 189b5aa1c..c95e98e7e 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -503,6 +503,10 @@ class Epp::Domain < Domain preclean_pendings user = ApiUser.find(pending_json['current_user_id']) frame = Nokogiri::XML(pending_json['frame']) + + self.deliver_emails = true # turn on email delivery + send_mail :registrant_updated_notification_for_old_registrant + statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here self.save @@ -510,8 +514,7 @@ class Epp::Domain < Domain ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user return unless update(frame, user, false) clean_pendings! - self.deliver_emails = true # turn on email delivery - send_mail :registrant_updated_notification_for_old_registrant + send_mail :registrant_updated_notification_for_new_registrant true end diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb index 1ad338816..f4312da44 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb @@ -3,7 +3,7 @@ Tere, Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

Uued registreerija:
-Nimi: <%= @params[:registrant_name] %> +Nimi: <%= @params[:new_registrant_name] %>

Lugupidamisega
Eesti Interneti SA @@ -15,7 +15,7 @@ Hi, Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.

New registrant:
-Name: <%= @params[:registrant_name] %> +Name: <%= @params[:new_registrant_name] %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb index beae5cfd8..f17ba0bce 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb @@ -3,7 +3,7 @@ Tere, Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. Uued registreerija: -Nimi: <%= @params[:registrant_name] %> +Nimi: <%= @params[:new_registrant_name] %> Lugupidamisega Eesti Interneti SA @@ -15,7 +15,7 @@ Hi, Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated. New registrant: -Name: <%= @params[:registrant_name] %> +Name: <%= @params[:new_registrant_name] %> Best Regards, Estonian Internet Foundation From ba659cd444d7f612208fc735765e586ae31fdf4b Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 11:09:46 +0200 Subject: [PATCH 84/98] Story #109367018 - restore [domain] to subject line --- app/models/domain_mail_model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index 96a7e2350..36154bc64 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -113,7 +113,7 @@ class DomainMailModel def subject(subject) @params[:name] = @domain.name - @params[:subject] = I18n.t(subject, name: @domain.name) + @params[:subject] = "#{I18n.t(subject, name: @domain.name)}, [#{@domain.name}]" end def confirm_update From 702206b9c00c14a70e4cacc388080f14cc0d1e34 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 11:51:36 +0200 Subject: [PATCH 85/98] Story #109367018 - ensure that country is passed only as name --- app/models/domain_mail_model.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index 36154bc64..b0d81e410 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -142,10 +142,11 @@ class DomainMailModel def domain_info [:name, :registrar_name, :registrant_name, :registrant_ident, :registrant_email, - :registrant_street,:registrant_city, :registrant_country + :registrant_street,:registrant_city ].each do |attr| @params.store attr, @domain.send(attr) end + @params.store :registrant_country, @domain.registrant_country.name @params.store :registrant_priv, @domain.registrant.priv? @params.store :old_registrant_name, Registrant.find(@domain.registrant_id_was).name @params From 375d8a7b9659141c11d8fc8aa9413137dd43467b Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 17 Dec 2015 14:00:01 +0200 Subject: [PATCH 86/98] 109818648-model_changed --- app/models/domain.rb | 4 ++-- app/models/whois_record.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 6d20574ce..07ba09dc4 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -307,7 +307,7 @@ class Domain < ActiveRecord::Base c = 0 Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x| - Whois::Record.where(domain_id: x.id).destroy_all + WhoisRecord.where(domain_id: x.id).destroy_all destroy_with_message x STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by deleteCandidate ##{x.id} (#{x.name})\n" unless Rails.env.test? @@ -315,7 +315,7 @@ class Domain < ActiveRecord::Base end Domain.where('force_delete_at <= ?', Time.zone.now).each do |x| - Whois::Record.where(domain_id: x.id).destroy_all + WhoisRecord.where(domain_id: x.id).destroy_all destroy_with_message x STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by force delete time ##{x.id} (#{x.name})\n" unless Rails.env.test? c += 1 diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index 121677c4d..55cc997da 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -113,6 +113,6 @@ class WhoisRecord < ActiveRecord::Base end def destroy_whois_record - Whois::Record.where(name: name).delete_all() + Whois::Record.where(name: name).delete_all end end From 057ec6a757ed78d5c7d71f4174fa3d4adb185eb6 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 14:39:12 +0200 Subject: [PATCH 87/98] Story #109367018 - privatize the work method --- app/mailers/domain_mailer.rb | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 4963cb02a..66533e316 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -25,19 +25,6 @@ class DomainMailer < ApplicationMailer compose_from(params) end - # app/models/DomainMailModel provides the data for mail that can be composed_from - # which ensures that values of objects are captured when they are valid, not later when this method is executed - def compose_from(params) - @params = params - return if delivery_off?(params, params[:deliver_emails]) - return if whitelist_blocked?(params[:recipient]) - params[:errors].map do |error| - logger.warn error - return - end - mail(to: params[:recipient], subject: params[:subject]) - end - def pending_deleted(domain_id, old_registrant_id, should_deliver) @domain = Domain.find_by(id: domain_id) @old_registrant = Registrant.find(old_registrant_id) @@ -129,4 +116,18 @@ class DomainMailer < ApplicationMailer subject: "#{I18n.t(:force_delete_subject)}" ) end + + private + # app/models/DomainMailModel provides the data for mail that can be composed_from + # which ensures that values of objects are captured when they are valid, not later when this method is executed + def compose_from(params) + @params = params + return if delivery_off?(params, params[:deliver_emails]) + return if whitelist_blocked?(params[:recipient]) + params[:errors].map do |error| + logger.warn error + return + end + mail(to: params[:recipient], subject: params[:subject]) + end end From 79dfb426c7827e881ee0e05c02365b5d63fa00fe Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 15:28:33 +0200 Subject: [PATCH 88/98] Story #109367018 - add data for old registrant notice --- ...ed_notification_for_old_registrant.html.erb | 18 ++++++++++++++++++ ...ed_notification_for_old_registrant.text.erb | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb index f4312da44..2c0693fa7 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb @@ -4,6 +4,15 @@ Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning

Uued registreerija:
Nimi: <%= @params[:new_registrant_name] %> +<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %>
+<% else %> +Äriregistrikood: <%= @params[:registrant_ident] %>
+<% end %> +Epost: <%= @params[:registrant_email] %>
+Tänav: <%= @params[:registrant_street] %>
+Linn: <%= @params[:registrant_city] %>
+Riik: <%= @params[:registrant_country] %>

Lugupidamisega
Eesti Interneti SA @@ -16,6 +25,15 @@ Process for changing registrant of the domain <%= @params[:name] %> has been app

New registrant:
Name: <%= @params[:new_registrant_name] %> +<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %>
+<% else %> +Business Registry code: <%= @params[:registrant_ident] %>
+<% end %> +E-mail: <%= @params[:registrant_email] %>
+Street: <%= @params[:registrant_street] %>
+City: <%= @params[:registrant_city] %>
+Country: <%= @params[:registrant_country] %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb index f17ba0bce..37bfcade5 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb @@ -4,6 +4,15 @@ Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning Uued registreerija: Nimi: <%= @params[:new_registrant_name] %> +<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %> +<% else %> +Äriregistrikood: <%= @params[:registrant_ident] %> +<% end %> +Epost: <%= @params[:registrant_email] %> +Tänav: <%= @params[:registrant_street] %> +Linn: <%= @params[:registrant_city] %> +Riik: <%= @params[:registrant_country] %> Lugupidamisega Eesti Interneti SA @@ -16,6 +25,15 @@ Process for changing registrant of the domain <%= @params[:name] %> has been app New registrant: Name: <%= @params[:new_registrant_name] %> +<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %> +<% else %> +Business Registry code: <%= @params[:registrant_ident] %> +<% end %> +E-mail: <%= @params[:registrant_email] %> +Street: <%= @params[:registrant_street] %> +City: <%= @params[:registrant_city] %> +Country: <%= @params[:registrant_country] %> Best Regards, Estonian Internet Foundation From eec8bd90ad7efbf686c9bb35be9081bff348c11e Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 16:28:20 +0200 Subject: [PATCH 89/98] Story #109367018 - add data for template update --- app/models/domain_mail_model.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index b0d81e410..71cc2155d 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -32,6 +32,7 @@ class DomainMailModel registrant_pending registrant_old subject(:registrant_updated_notification_for_old_registrant_subject) + domain_info compose end From 98f8a2b4404156867bad6c629e642d5a22bcd3fe Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 18:08:10 +0200 Subject: [PATCH 90/98] Story #109367018 - add white space lines to email template --- ...egistrant_updated_notification_for_old_registrant.html.erb | 4 ++-- ...egistrant_updated_notification_for_old_registrant.text.erb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb index 2c0693fa7..390482155 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb @@ -3,7 +3,7 @@ Tere, Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

Uued registreerija:
-Nimi: <%= @params[:new_registrant_name] %> +Nimi: <%= @params[:new_registrant_name] %>
<% if @params[:registrant_priv] %> Isikukood: <%= @params[:registrant_ident] %>
<% else %> @@ -24,7 +24,7 @@ Hi, Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.

New registrant:
-Name: <%= @params[:new_registrant_name] %> +Name: <%= @params[:new_registrant_name] %>
<% if @params[:registrant_priv] %> Personal code: <%= @params[:registrant_ident] %>
<% else %> diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb index 37bfcade5..5065d2d9f 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb @@ -4,6 +4,7 @@ Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning Uued registreerija: Nimi: <%= @params[:new_registrant_name] %> + <% if @params[:registrant_priv] %> Isikukood: <%= @params[:registrant_ident] %> <% else %> @@ -25,6 +26,7 @@ Process for changing registrant of the domain <%= @params[:name] %> has been app New registrant: Name: <%= @params[:new_registrant_name] %> + <% if @params[:registrant_priv] %> Personal code: <%= @params[:registrant_ident] %> <% else %> From eb6c1d607ba1339ee77a3c26cd8a21a410d8770a Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 18:08:52 +0200 Subject: [PATCH 91/98] Story #109367018 - add domain info for new registrant --- app/models/domain_mail_model.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index 71cc2155d..4ba55e117 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -32,7 +32,13 @@ class DomainMailModel registrant_pending registrant_old subject(:registrant_updated_notification_for_old_registrant_subject) - domain_info + new_registrant = Registrant.find @domain.pending_json['new_registrant_id'] + @params[:registrant_name] = new_registrant.name + @params[:registrant_ident] = new_registrant.ident + @params[:registrant_priv] = new_registrant.priv? + @params[:registrant_email] = new_registrant.email + @params[:registrant_street] = new_registrant.street + @params[:registrant_city] = new_registrant.city compose end From 688071bf46bdf3615cb48440f5a7c74d335be0b6 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Thu, 17 Dec 2015 19:36:57 +0200 Subject: [PATCH 92/98] missing new registrant country name --- app/models/domain_mail_model.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index 4ba55e117..46309ad52 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -39,6 +39,7 @@ class DomainMailModel @params[:registrant_email] = new_registrant.email @params[:registrant_street] = new_registrant.street @params[:registrant_city] = new_registrant.city + @params[:registrant_country] = new_registrant.country.name compose end From 39c4fafdd61fb96945d56ac14c01611694613aa4 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Thu, 17 Dec 2015 19:42:42 +0200 Subject: [PATCH 93/98] standardise template --- .../registrant_updated_notification_for_old_registrant.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb index 390482155..a1820e7ad 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb @@ -2,7 +2,7 @@ Tere,

Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

-Uued registreerija:
+Uued registreerija andmed:
Nimi: <%= @params[:new_registrant_name] %>
<% if @params[:registrant_priv] %> Isikukood: <%= @params[:registrant_ident] %>
From a3b55543f2f7a2f806e9188da80066c0559efb93 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Thu, 17 Dec 2015 19:47:38 +0200 Subject: [PATCH 94/98] Uued to Uue --- .../pending_update_notification_for_new_registrant.html.erb | 2 +- .../pending_update_notification_for_new_registrant.text.erb | 2 +- .../registrant_updated_notification_for_new_registrant.html.erb | 2 +- .../registrant_updated_notification_for_new_registrant.text.erb | 2 +- .../registrant_updated_notification_for_old_registrant.html.erb | 2 +- .../registrant_updated_notification_for_old_registrant.text.erb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb index 9f33535ea..07de23117 100644 --- a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb @@ -4,7 +4,7 @@ Registripidaja <%= @params[:registrar_name] %> vahendusel on algatatud <%= @para

Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %>

-Uued registreerija andmed:
+Uue registreerija andmed:
Nimi: <%= @params[:registrant_name] %>
<% if @params[:registrant_priv] %> Isikukood: <%= @params[:registrant_ident] %>
diff --git a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb index d7f2d7f9c..24005a58a 100644 --- a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb @@ -4,7 +4,7 @@ Registripidaja <%= @params[:registrar_name] %> vahendusel on algatatud <%= @para Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %> -Uued registreerija andmed: +Uue registreerija andmed: Nimi: <%= @params[:registrant_name] %> <% if @params[:registrant_priv] %> Isikukood: <%= @params[:registrant_ident] %> diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb index 74021a489..c7d464f43 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb @@ -2,7 +2,7 @@ Tere,

Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

-Uued registreerija andmed:
+Uue registreerija andmed:
Nimi: <%= @params[:registrant_name] %>
<% if @params[:registrant_priv] %> Isikukood: <%= @params[:registrant_ident] %>
diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb index 279afa2b5..115655897 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb @@ -2,7 +2,7 @@ Tere, Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. -Uued registreerija andmed: +Uue registreerija andmed: Nimi: <%= @params[:registrant_name] %> <% if @params[:registrant_priv] %> Isikukood: <%= @params[:registrant_ident] %> diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb index a1820e7ad..b41e1f1eb 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb @@ -2,7 +2,7 @@ Tere,

Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

-Uued registreerija andmed:
+Uue registreerija andmed:
Nimi: <%= @params[:new_registrant_name] %>
<% if @params[:registrant_priv] %> Isikukood: <%= @params[:registrant_ident] %>
diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb index 5065d2d9f..c2efa5af9 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb @@ -2,7 +2,7 @@ Tere, Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. -Uued registreerija: +Uue registreerija andmed: Nimi: <%= @params[:new_registrant_name] %> <% if @params[:registrant_priv] %> From b63884eac1288d99f5bc864132fa47ae03520d21 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Thu, 17 Dec 2015 19:57:36 +0200 Subject: [PATCH 95/98] Missed one --- .../pending_update_request_for_old_registrant.html.erb | 2 +- .../pending_update_request_for_old_registrant.text.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb index 5da14d96d..dc26a9c1c 100644 --- a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb @@ -2,7 +2,7 @@ Tere,

Registrisse laekus taotlus domeeni <%= @params[:name] %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %>

-Uued registreerija andmed:
+Uue registreerija andmed:
Nimi: <%= @params[:registrant_name] %>
<% if @params[:registrant_priv] %> Isikukood: <%= @params[:registrant_ident] %>
diff --git a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb index 27e394b87..142004bb6 100644 --- a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb @@ -2,7 +2,7 @@ Tere, Registrisse laekus taotlus domeeni <%= @params[:name] %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %> -Uued registreerija andmed: +Uue registreerija andmed: Nimi: <%= @params[:registrant_name] %> <% if @params[:registrant_priv] %> Isikukood: <%= @params[:registrant_ident] %> From b514b5c94d941af140fa88c2baf81dbb4982bade Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 17 Dec 2015 20:48:05 +0200 Subject: [PATCH 96/98] Story#109367018 Set hardcoded to reindex whois record --- app/models/epp/domain.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index c95e98e7e..656d5f645 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -516,6 +516,7 @@ class Epp::Domain < Domain clean_pendings! send_mail :registrant_updated_notification_for_new_registrant + update_whois_record true end From 33d141e74b0820939d8898714470731830159de8 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 17 Dec 2015 21:01:17 +0200 Subject: [PATCH 97/98] Story#109367018 Set hardcoded to reindex whois record --- app/jobs/domain_update_confirm_job.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 4f2c1e9ad..8e9fd4708 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -10,6 +10,7 @@ class DomainUpdateConfirmJob < Que::Job e.instance_variable_set("@changed_attributes", e.changed_attributes.merge("statuses"=>[])) end domain.clean_pendings! + domain.update_whois_record when RegistrantVerification::REJECTED domain.send_mail :pending_update_rejected_notification_for_new_registrant domain.poll_message!(:poll_pending_update_rejected_by_registrant) From eff9a076ae2a6c571fd8c9c9d2d928df73f27fef Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 17 Dec 2015 21:17:11 +0200 Subject: [PATCH 98/98] Story#109367018 reset all domains data --- app/jobs/domain_update_confirm_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 8e9fd4708..42209d205 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -10,7 +10,7 @@ class DomainUpdateConfirmJob < Que::Job e.instance_variable_set("@changed_attributes", e.changed_attributes.merge("statuses"=>[])) end domain.clean_pendings! - domain.update_whois_record + WhoisRecord.find_by(domain_id: domain.id).save! when RegistrantVerification::REJECTED domain.send_mail :pending_update_rejected_notification_for_new_registrant domain.poll_message!(:poll_pending_update_rejected_by_registrant)