From c3d675cedca43d6cea1c5341949f5982c44a0bf2 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 2 Dec 2015 12:09:04 +0200 Subject: [PATCH 001/101] 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 4f8f08ecc9c2354a45747837fade46b5957521dd Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 2 Dec 2015 13:49:44 +0200 Subject: [PATCH 002/101] Story #109086524 - force is_admin to skip validation until validations can be fixed --- app/controllers/admin/pending_updates_controller.rb | 2 ++ app/models/epp/domain.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 4d08297d7..3a15fb3a5 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -6,6 +6,8 @@ class Admin::PendingUpdatesController < AdminController authorize! :update, :pending @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending + @epp_domain.is_admin = true + if @epp_domain.apply_pending_update! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 613c57115..4d86e7e15 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -4,6 +4,7 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions + return if is_admin # this bad hack for 109086524, refactor later return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false From 7c469923a7cce318410ad7f916193d7ab63ff7cb Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 2 Dec 2015 17:37:38 +0200 Subject: [PATCH 003/101] 109190528-condition_added --- app/views/epp/domains/info.xml.builder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 9e1779921..d3ffd22d5 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -38,7 +38,7 @@ xml.epp_head do xml.tag!('domain:clID', @domain.registrar_name) - xml.tag!('domain:crID', @domain.creator.try(:registrar)) if @domain.creator + xml.tag!('domain:crID', @domain.creator.try(:registrar) || @domain.creator) if @domain.creator xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) From 70252f9f87aabb11d4677b0065d3136ad72d43cc Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 12:58:11 +0200 Subject: [PATCH 004/101] 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 8944ec5bf0034f44b635b5178a6f320b31f1b2d5 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 16:53:05 +0200 Subject: [PATCH 005/101] 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 006/101] 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 e15ab3421d4b814eec6e4ece051e8d22cacff3b8 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:29:02 +0200 Subject: [PATCH 007/101] 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 008/101] 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 251a9e1666d2e0d6023cee6338cc6cc9a0e0d766 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 18:40:13 +0200 Subject: [PATCH 009/101] 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 010/101] 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 011/101] 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 012/101] 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 013/101] 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 014/101] 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 015/101] 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 cec3693f826c50dfdfc2d8f03b0993d9e8059375 Mon Sep 17 00:00:00 2001 From: Stas Date: Sun, 6 Dec 2015 23:22:39 +0200 Subject: [PATCH 016/101] 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 4980bc591db45ff80e07a245a44fe73c0c9d1e9e Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 7 Dec 2015 17:15:23 +0200 Subject: [PATCH 017/101] Story#109623634 - No after-validate contacts callback for transfer --- app/models/epp/domain.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 739c55bec..0ec24c60b 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -3,7 +3,7 @@ class Epp::Domain < Domain include EppErrors # TODO: remove this spagetti once data in production is correct. - attr_accessor :is_renewal + attr_accessor :is_renewal, :is_transfer before_validation :manage_permissions def manage_permissions @@ -14,7 +14,7 @@ class Epp::Domain < Domain after_validation :validate_contacts def validate_contacts - return true if is_renewal + return true if is_renewal || is_transfer ok = true active_admins = admin_domain_contacts.select { |x| !x.marked_for_destruction? } @@ -592,6 +592,8 @@ class Epp::Domain < Domain # rubocop: disable Metrics/CyclomaticComplexity def transfer(frame, action, current_user) + @is_transfer = true + case action when 'query' return domain_transfers.last if domain_transfers.any? From 668cbdac06d6fcdf549dd05191eb5fb2df27c515 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 7 Dec 2015 17:25:24 +0200 Subject: [PATCH 018/101] Story#109623634 - No after-validate contacts callback for transfer --- 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 0ec24c60b..7ab57781e 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -7,6 +7,7 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions + return true if is_transfer return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false From 1651961147483eaf0b2801926d11700ad43af70b Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 9 Dec 2015 16:07:57 +0200 Subject: [PATCH 019/101] 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 020/101] 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 bbd90127af0ee33fdd2c2e072fc8ff4a2b605b8a Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 11 Dec 2015 12:07:46 +0200 Subject: [PATCH 021/101] 109809872-template_changes --- app/views/admin/contacts/partials/_general.haml | 2 +- app/views/admin/domains/partials/_general.haml | 2 +- app/views/admin/keyrelays/show.haml | 2 +- app/views/registrar/domains/partials/_general.haml | 2 +- app/views/registrar/polls/show.haml | 2 +- config/locales/en.yml | 2 ++ 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/admin/contacts/partials/_general.haml b/app/views/admin/contacts/partials/_general.haml index 194c5feb5..64f17612e 100644 --- a/app/views/admin/contacts/partials/_general.haml +++ b/app/views/admin/contacts/partials/_general.haml @@ -6,7 +6,7 @@ %dt= t(:id) %dd= @contact.code - %dt= t(:password) + %dt= t(:authinfo_pw) %dd = text_field_tag :auth_info, @contact.auth_info, readonly: true, class: 'partially-hidden' diff --git a/app/views/admin/domains/partials/_general.haml b/app/views/admin/domains/partials/_general.haml index d433a1302..d1a17c1cc 100644 --- a/app/views/admin/domains/partials/_general.haml +++ b/app/views/admin/domains/partials/_general.haml @@ -12,7 +12,7 @@ %dt= t(:registrar) %dd= link_to(@domain.registrar, admin_registrar_path(@domain.registrar)) - %dt= t(:password) + %dt= t(:authinfo_pw) %dd = text_field_tag :password, @domain.auth_info, readonly: true, class: 'partially-hidden' diff --git a/app/views/admin/keyrelays/show.haml b/app/views/admin/keyrelays/show.haml index 067cd4439..08f8b6f33 100644 --- a/app/views/admin/keyrelays/show.haml +++ b/app/views/admin/keyrelays/show.haml @@ -28,7 +28,7 @@ %dt= t(:public_key) %dd= @keyrelay.key_data_public_key - %dt= t(:password) + %dt= t(:authinfo_pw) %dd= @keyrelay.auth_info_pw %dt= t(:expiry_relative) diff --git a/app/views/registrar/domains/partials/_general.haml b/app/views/registrar/domains/partials/_general.haml index cd16079dd..4eb5285e7 100644 --- a/app/views/registrar/domains/partials/_general.haml +++ b/app/views/registrar/domains/partials/_general.haml @@ -3,7 +3,7 @@ %h3.panel-title= t(:general) .panel-body %dl.dl-horizontal - %dt= t(:password) + %dt= t(:authinfo_pw) %dd= @data.css('pw').text.present? ? @data.css('pw').text : t('hidden') - if @data.css('pw').text.blank? diff --git a/app/views/registrar/polls/show.haml b/app/views/registrar/polls/show.haml index 90a5bb02a..e013bad7b 100644 --- a/app/views/registrar/polls/show.haml +++ b/app/views/registrar/polls/show.haml @@ -30,7 +30,7 @@ %dt= t(:domain_name) %dd= @data.css('name').text - %dt= t(:password) + %dt= t(:authinfo_pw) %dd= @data.css('pw').text - if @data.css('relative').text.present? diff --git a/config/locales/en.yml b/config/locales/en.yml index 16e643b16..83f9ce16a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -280,6 +280,7 @@ en: domain_details: 'Domain details' registered_at: 'Registered at' password: 'Password' + authinfo_pw: 'AuthInfo pw' valid_from: 'Valid from' general: 'General' contacts: 'Contacts' @@ -554,6 +555,7 @@ en: username: 'Username' password: 'Password' + authinfo_pw: 'AuthInfo pw' log_in: 'Log in' domains: 'Domains' register: 'Register' From 6c38f3e5a58e6915ec7e4fc9f1f157f95bc4290d Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 12:58:11 +0200 Subject: [PATCH 022/101] 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 023/101] 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 024/101] 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 025/101] 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 026/101] 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 027/101] 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 028/101] 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 029/101] 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 030/101] 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 031/101] 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 032/101] 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 033/101] 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 034/101] 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 035/101] 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 036/101] 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 037/101] 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 80fe0428b213b24fa7844ef69327effd6e52c4fc Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 2 Dec 2015 13:49:44 +0200 Subject: [PATCH 038/101] Story #109086524 - force is_admin to skip validation until validations can be fixed --- app/controllers/admin/pending_updates_controller.rb | 2 ++ app/models/epp/domain.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 4d08297d7..3a15fb3a5 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -6,6 +6,8 @@ class Admin::PendingUpdatesController < AdminController authorize! :update, :pending @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending + @epp_domain.is_admin = true + if @epp_domain.apply_pending_update! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 739c55bec..3471cf131 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -7,6 +7,7 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions + return if is_admin # this bad hack for 109086524, refactor later return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false From 05b2408b430c0123c995ab90c59f7311cfd03c63 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:06:52 +0200 Subject: [PATCH 039/101] Story #109086524 - Save update with the user id that requested update, when admin approves (I thought this change was already committed, but where?) --- app/models/epp/domain.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 3471cf131..5468f9678 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -507,7 +507,9 @@ class Epp::Domain < Domain frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here + save + PaperTrail.whodunnit = user return unless update(frame, user, false) clean_pendings! self.deliver_emails = true # turn on email delivery From 32d0200a9f1887f757db5d6784c7ae4486796217 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:09:43 +0200 Subject: [PATCH 040/101] Story #109086524 - change execution path, admin will now use same method as registrant to apply pending update This change now include creating registrar message --- .../admin/pending_updates_controller.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 3a15fb3a5..6e41a6c57 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -5,10 +5,7 @@ class Admin::PendingUpdatesController < AdminController def update authorize! :update, :pending - @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending - @epp_domain.is_admin = true - - if @epp_domain.apply_pending_update! + if registrant_verification.domain_registrant_change_confirm! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else redirect_to edit_admin_domain_path(@domain.id), alert: t(:failure) @@ -17,14 +14,21 @@ class Admin::PendingUpdatesController < AdminController def destroy authorize! :destroy, :pending - - if @domain.clean_pendings! + if registrant_verification.domain_registrant_change_reject! redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed) else redirect_to admin_domain_path(@domain.id), alert: t(:failure) end end + def registrant_verification + # steal token + token = @domain.registrant_verification_token + @registrant_verification = RegistrantVerification.new(domain_id: @domain.id, + domain_name: @domain.name, + verification_token: token) + end + private def find_domain From 176bd33ad585a1560a05b3edfbafbc2262c31836 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:13:27 +0200 Subject: [PATCH 041/101] Story #109086524 - remove excess method call --- app/jobs/domain_update_confirm_job.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 28294ef25..bc4beb541 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -9,7 +9,6 @@ class DomainUpdateConfirmJob < Que::Job 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) From 6c90d5825b395783e4f61416fa30cf530d90bce5 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 11:45:54 +0200 Subject: [PATCH 042/101] Story #109086524 - revert to allow merge, changes fixed on branch for story 109367694 --- app/models/epp/domain.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 5468f9678..739c55bec 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -7,7 +7,6 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions - return if is_admin # this bad hack for 109086524, refactor later return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false @@ -507,9 +506,7 @@ class Epp::Domain < Domain frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here - save - PaperTrail.whodunnit = user return unless update(frame, user, false) clean_pendings! self.deliver_emails = true # turn on email delivery From ac04a94b6a4054cd428406166ddd3e8e0bbb4ebe Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 12:58:11 +0200 Subject: [PATCH 043/101] 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 044/101] 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 045/101] 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 046/101] 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 047/101] 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 048/101] 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 049/101] 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 050/101] 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 051/101] 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 052/101] 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 053/101] 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 054/101] 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 055/101] 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 056/101] 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 057/101] 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 058/101] 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 059/101] 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 95454229ca0feb9783deaf8ee62bef7d49d744c2 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 17:43:24 +0200 Subject: [PATCH 060/101] Story #105745608 - handle missing price list with error 2104 --- app/controllers/epp/domains_controller.rb | 24 +++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index f8cb2b752..91ddeb93d 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -29,11 +29,6 @@ class Epp::DomainsController < EppController handle_errors(@domain) and return if @domain.errors.any? handle_errors and return unless balance_ok?('create') # loads pricelist in this method - if !@domain_pricelist.try(:price)#checking if pricelist is not found - @domain.add_epp_error('2306', nil, nil, 'No price list for domain') - handle_errors(@domain) and return if @domain.errors.any? - end - ActiveRecord::Base.transaction do if @domain.save # TODO: Maybe use validate: false here because we have already validated the domain? current_user.registrar.debit!({ @@ -107,10 +102,6 @@ class Epp::DomainsController < EppController period_unit = Epp::Domain.parse_period_unit_from_frame(params[:parsed_frame]) || 'y' balance_ok?('renew', period, period_unit) # loading pricelist - if !@domain_pricelist.try(:price)#checking if pricelist is not found - @domain.add_epp_error('2306', nil, nil, 'No price list for domain') - handle_errors(@domain) and return if @domain.errors.any? - end ActiveRecord::Base.transaction do success = @domain.renew( @@ -258,12 +249,19 @@ class Epp::DomainsController < EppController def balance_ok?(operation, period = nil, unit = nil) @domain_pricelist = @domain.pricelist(operation, period.try(:to_i), unit) - if current_user.registrar.balance < @domain_pricelist.price.amount + if @domain_pricelist.try(:price) # checking if price list is not found + if current_user.registrar.balance < @domain_pricelist.price.amount + epp_errors << { + code: '2104', + msg: I18n.t('billing_failure_credit_balance_low') + } + return false + end + else epp_errors << { - code: '2104', - msg: I18n.t('billing_failure_credit_balance_low') + code: '2104', + msg: I18n.t(:active_price_missing_for_this_operation) } - return false end true From c83fa049c7a61fcbdde4e6535573dc1fd6d3dced Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 14 Dec 2015 18:09:38 +0200 Subject: [PATCH 061/101] 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 062/101] 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 c54bc69936a45dc10756d3d0813452a8989e1ae5 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 16 Dec 2015 17:55:56 +0200 Subject: [PATCH 063/101] 108874730-depp_parsing changed --- app/models/depp/domain.rb | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/app/models/depp/domain.rb b/app/models/depp/domain.rb index fd0e71e9b..7b4630008 100644 --- a/app/models/depp/domain.rb +++ b/app/models/depp/domain.rb @@ -152,23 +152,17 @@ module Depp } end - data.css('dsData').each_with_index do |x, i| - ds = { - ds_key_tag: x.css('keyTag').first.try(:text), - ds_alg: x.css('alg').first.try(:text), - ds_digest_type: x.css('digestType').first.try(:text), - ds_digest: x.css('digest').first.try(:text) + data.css('keyData').each_with_index do |x, i| + ret[:dnskeys_attributes][i] = { + flags: x.css('flags').text, + protocol: x.css('protocol').text, + alg: x.css('alg').text, + public_key: x.css('pubKey').text, + ds_key_tag: x.css('keyTag').first.try(:text), + ds_alg: x.css('alg').first.try(:text), + ds_digest_type: x.css('digestType').first.try(:text), + ds_digest: x.css('digest').first.try(:text) } - - kd = x.css('keyData').first - ds.merge!({ - flags: kd.css('flags').first.try(:text), - protocol: kd.css('protocol').first.try(:text), - alg: kd.css('alg').first.try(:text), - public_key: kd.css('pubKey').first.try(:text) - }) if kd - - ret[:dnskeys_attributes][i] = ds end data.css('status').each_with_index do |x, i| From 369c0507ebae8f4ebf3e266e1b823c68b0e8d171 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 16:53:05 +0200 Subject: [PATCH 064/101] 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 065/101] 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 066/101] 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 067/101] 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 068/101] 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 069/101] 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 070/101] 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 071/101] 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 072/101] 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 073/101] 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 074/101] 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 075/101] 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 086b82e5407bffd71af1fce792befd5bb908551e Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 17 Dec 2015 16:20:50 +0200 Subject: [PATCH 076/101] 109809872-term_change --- app/views/registrar/contacts/partials/_general.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/registrar/contacts/partials/_general.haml b/app/views/registrar/contacts/partials/_general.haml index 37bd87555..462bf35a0 100644 --- a/app/views/registrar/contacts/partials/_general.haml +++ b/app/views/registrar/contacts/partials/_general.haml @@ -6,7 +6,7 @@ %dt= t(:id) %dd= @contact.id - %dt= t(:password) + %dt= t(:authinfo_pw) %dd = text_field_tag :password, @contact.password, readonly: true, class: 'partially-hidden' From eec8bd90ad7efbf686c9bb35be9081bff348c11e Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 16:28:20 +0200 Subject: [PATCH 077/101] 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 db870574c2b853729ab5caaba66f697510d52b5b Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 2 Dec 2015 13:49:44 +0200 Subject: [PATCH 078/101] Story #109086524 - force is_admin to skip validation until validations can be fixed --- app/controllers/admin/pending_updates_controller.rb | 2 ++ app/models/epp/domain.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 4d08297d7..3a15fb3a5 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -6,6 +6,8 @@ class Admin::PendingUpdatesController < AdminController authorize! :update, :pending @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending + @epp_domain.is_admin = true + if @epp_domain.apply_pending_update! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 40b374003..3e5b842b2 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -7,6 +7,7 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions + return if is_admin # this bad hack for 109086524, refactor later return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false From 226e82c71a6e15ca0cdb9375853a44695d93edd8 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:09:43 +0200 Subject: [PATCH 079/101] Story #109086524 - change execution path, admin will now use same method as registrant to apply pending update This change now include creating registrar message --- .../admin/pending_updates_controller.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 3a15fb3a5..6e41a6c57 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -5,10 +5,7 @@ class Admin::PendingUpdatesController < AdminController def update authorize! :update, :pending - @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending - @epp_domain.is_admin = true - - if @epp_domain.apply_pending_update! + if registrant_verification.domain_registrant_change_confirm! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else redirect_to edit_admin_domain_path(@domain.id), alert: t(:failure) @@ -17,14 +14,21 @@ class Admin::PendingUpdatesController < AdminController def destroy authorize! :destroy, :pending - - if @domain.clean_pendings! + if registrant_verification.domain_registrant_change_reject! redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed) else redirect_to admin_domain_path(@domain.id), alert: t(:failure) end end + def registrant_verification + # steal token + token = @domain.registrant_verification_token + @registrant_verification = RegistrantVerification.new(domain_id: @domain.id, + domain_name: @domain.name, + verification_token: token) + end + private def find_domain From 611151317c92ed0648c92a9fe9592e112a3ce5e1 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:13:27 +0200 Subject: [PATCH 080/101] Story #109086524 - remove excess method call --- app/jobs/domain_update_confirm_job.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 28294ef25..bc4beb541 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -9,7 +9,6 @@ class DomainUpdateConfirmJob < Que::Job 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) From 674fa9f76b8bee9ab3770ac981a34ad888f2f9f2 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 11:45:54 +0200 Subject: [PATCH 081/101] Story #109086524 - revert to allow merge, changes fixed on branch for story 109367694 --- app/models/epp/domain.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 3e5b842b2..40b374003 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -7,7 +7,6 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions - return if is_admin # this bad hack for 109086524, refactor later return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false From 250cda0923a5edece645cd5936bc325f0207c5eb Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 17:12:13 +0200 Subject: [PATCH 082/101] Story #109086524 - change code path for pendingDelete to send registrar method --- .../admin/pending_deletes_controller.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/pending_deletes_controller.rb b/app/controllers/admin/pending_deletes_controller.rb index a64a34714..2eda703bd 100644 --- a/app/controllers/admin/pending_deletes_controller.rb +++ b/app/controllers/admin/pending_deletes_controller.rb @@ -5,9 +5,7 @@ class Admin::PendingDeletesController < AdminController def update authorize! :update, :pending - @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending - @epp_domain.is_admin= true - if @epp_domain.apply_pending_delete! + if registrant_verification.domain_registrant_delete_confirm! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else redirect_to admin_edit_domain_path(@domain.id), alert: t(:failure) @@ -17,7 +15,7 @@ class Admin::PendingDeletesController < AdminController def destroy authorize! :destroy, :pending - if @domain.clean_pendings! + if registrant_verification.domain_registrant_delete_reject! redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed) else redirect_to admin_domain_path(@domain.id), alert: t(:failure) @@ -26,6 +24,14 @@ class Admin::PendingDeletesController < AdminController private + def registrant_verification + # steal token + token = @domain.registrant_verification_token + @registrant_verification = RegistrantVerification.new(domain_id: @domain.id, + domain_name: @domain.name, + verification_token: token) + end + def find_domain @domain = Domain.find(params[:domain_id]) end From 98f8a2b4404156867bad6c629e642d5a22bcd3fe Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 18:08:10 +0200 Subject: [PATCH 083/101] 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 084/101] 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 085/101] 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 086/101] 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 087/101] 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 da410aaa1f93590eb80ea9b1a179237d52ac44c1 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 19:55:09 +0200 Subject: [PATCH 088/101] Story #109367018 - remove validation that token domain and token are unique, prevents required action for delete reject --- app/models/registrant_verification.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/registrant_verification.rb b/app/models/registrant_verification.rb index d0c015ecb..a33751413 100644 --- a/app/models/registrant_verification.rb +++ b/app/models/registrant_verification.rb @@ -12,7 +12,6 @@ class RegistrantVerification < ActiveRecord::Base belongs_to :domain validates :verification_token, :domain_name, :domain, :action, :action_type, presence: true - validates :domain, uniqueness: { scope: [:domain_id, :verification_token] } def domain_registrant_change_confirm! self.action_type = DOMAIN_REGISTRANT_CHANGE From b63884eac1288d99f5bc864132fa47ae03520d21 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Thu, 17 Dec 2015 19:57:36 +0200 Subject: [PATCH 089/101] 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 090/101] 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 091/101] 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 092/101] 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) From e7eb45c3249f6b960f505fd31c2bc0f67f9e4df7 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 18 Dec 2015 10:54:36 +0200 Subject: [PATCH 093/101] Story#110391728 - Asking instance, not class to send email --- 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 7a4aae870..05ffafc4d 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? - send_mail :pending_update_expired_notification_for_new_registrant + domain.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 From 6ed9a290e18ef4110267c7873e5e4b00309a02cc Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 18 Dec 2015 11:11:50 +0200 Subject: [PATCH 094/101] Story#110391728 - do not update domain whois record if only relation left --- 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 96365d056..ecf399731 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -488,7 +488,7 @@ class Contact < ActiveRecord::Base end def update_related_whois_records - related_domain_descriptions.each{ |x, y| WhoisRecord.find_by(name: x).save} + related_domain_descriptions.each{ |x, y| WhoisRecord.find_by(name: x).try(:save) } end end From 9027f5007c14134067dad7ffe61a74498138851a Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 18 Dec 2015 14:00:41 +0200 Subject: [PATCH 095/101] Story#109623634 - after contact transferring new one should have state linked --- 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 7ab57781e..26f0c3153 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -622,6 +622,7 @@ class Epp::Domain < Domain oc.registrar_id = registrar_id oc.copy_from_id = c.id oc.prefix_code + oc.domains_present = true oc.save!(validate: false) oc end From a790693f3e615197713c13186802898ce67fca89 Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 18 Dec 2015 14:46:38 +0200 Subject: [PATCH 096/101] 110245112-find_by_overwrite --- app/models/whois_record.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index 55cc997da..528f84816 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -23,6 +23,10 @@ class WhoisRecord < ActiveRecord::Base end end + def self.find_by_name(name) + WhoisRecord.where("lower(name) = ?", name.downcase) + end + def generated_json @generated_json ||= generate_json end From e4c00e6bcee25144c726ea3fe3ce7fdbb1245da5 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 18 Dec 2015 15:48:00 +0200 Subject: [PATCH 097/101] Story#109623634 - after contact transferring it should be linked and ok --- app/models/contact.rb | 6 ++++++ app/models/epp/domain.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index fcebe8632..bcd359ca9 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -57,6 +57,11 @@ class Contact < ActiveRecord::Base before_save :manage_statuses def manage_statuses + if domain_transfer # very ugly but need better workflow + self.statuses = [OK, LINKED] + return + end + manage_linked manage_ok end @@ -78,6 +83,7 @@ class Contact < ActiveRecord::Base ] attr_accessor :deliver_emails + attr_accessor :domain_transfer # hack but solves problem faster # # STATUSES diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 26f0c3153..fac09705d 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -622,7 +622,7 @@ class Epp::Domain < Domain oc.registrar_id = registrar_id oc.copy_from_id = c.id oc.prefix_code - oc.domains_present = true + oc.domain_transfer = true oc.save!(validate: false) oc end From fd186901a483dd659e92f9a2dd60277146889082 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 18 Dec 2015 16:45:13 +0200 Subject: [PATCH 098/101] Story#109623634 - save old states. --- 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 bcd359ca9..2375090da 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -58,7 +58,7 @@ class Contact < ActiveRecord::Base before_save :manage_statuses def manage_statuses if domain_transfer # very ugly but need better workflow - self.statuses = [OK, LINKED] + self.statuses = statuses | [OK, LINKED] return end From 5e05aee1c8d0f1091b6ddcd8d76712080a7229f2 Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 18 Dec 2015 16:53:55 +0200 Subject: [PATCH 099/101] 110145900-date_conflict_fixed --- app/models/pricelist.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/pricelist.rb b/app/models/pricelist.rb index 42cca0126..17420dfa1 100644 --- a/app/models/pricelist.rb +++ b/app/models/pricelist.rb @@ -31,7 +31,7 @@ class Pricelist < ActiveRecord::Base def pricelist_for(zone, operation, period) lists = valid.where(category: zone, operation_category: operation, duration: period) return lists.first if lists.count == 1 - lists.where('valid_to IS NOT NULL').order(valid_from: :desc).first + lists.order(valid_from: :desc).first end end end From 52d1f79df045d63f96f4ed994336e5473c687af8 Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 18 Dec 2015 17:39:41 +0200 Subject: [PATCH 100/101] 110245542-callback_for_vat_percent --- app/models/invoice.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 8bc5137d5..aaddbd77b 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -18,6 +18,8 @@ class Invoice < ActiveRecord::Base :seller_iban, :buyer_name, :invoice_items, :vat_prc, presence: true before_create :set_invoice_number + before_create :check_vat + def set_invoice_number last_no = Invoice.order(number: :desc).where('number IS NOT NULL').limit(1).pluck(:number).first @@ -34,6 +36,12 @@ class Invoice < ActiveRecord::Base false end + def check_vat + if buyer.country_code = 'EE' && buyer.vat_no.present? + self.vat_prc = 0 + end + end + before_save -> { self.sum_cache = sum } class << self From 074d59031ce9505ccc3ae0bc7133c83e3cfe2eb2 Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 4 Jan 2016 12:33:46 +0200 Subject: [PATCH 101/101] 110946256-logic_fix --- app/models/invoice.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/invoice.rb b/app/models/invoice.rb index aaddbd77b..2f54e2287 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -17,8 +17,7 @@ class Invoice < ActiveRecord::Base validates :invoice_type, :due_date, :currency, :seller_name, :seller_iban, :buyer_name, :invoice_items, :vat_prc, presence: true - before_create :set_invoice_number - before_create :check_vat + before_create :set_invoice_number, :check_vat def set_invoice_number last_no = Invoice.order(number: :desc).where('number IS NOT NULL').limit(1).pluck(:number).first @@ -37,7 +36,7 @@ class Invoice < ActiveRecord::Base end def check_vat - if buyer.country_code = 'EE' && buyer.vat_no.present? + if buyer.country_code != 'EE' && buyer.vat_no.present? self.vat_prc = 0 end end