From c3d675cedca43d6cea1c5341949f5982c44a0bf2 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 2 Dec 2015 12:09:04 +0200 Subject: [PATCH 001/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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/182] 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 58bc4cc13b456b774418f06de7d68b40c85fd743 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 8 Dec 2015 10:40:52 +0200 Subject: [PATCH 019/182] Story#109623634 - contacts ident data can be changed if ident_cc is not set or birthday is in wrong format --- app/models/epp/contact.rb | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index ec5673b06..99f559041 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -160,20 +160,14 @@ class Epp::Contact < Contact self.ident_updated_at ||= Time.zone.now # not in use ident_frame = frame.css('ident').first - if ident_frame && ident_attr_valid?(ident_frame) && ident_country_code.blank? && ident_type.in?(%w(org priv).freeze) - at.merge!(ident_country_code: ident_frame.attr('cc')) + if ident_frame && ident_attr_valid?(ident_frame) + if ident_country_code.blank? && ident_type.in?(%w(org priv).freeze) + at.merge!(ident_country_code: ident_frame.attr('cc')) + end + if ident_type == "birthday" && ident !=~ /\d{4}-\d{2}-\d{2}/ + at.merge!(ident: ident_frame.text) + end end - - # Deprecated - # if ident_updated_at.present? - # throw :epp_error, { - # code: '2306', - # msg: I18n.t(:ident_update_error) - # } - # else - # at.merge!(self.class.ident_attrs(frame.css('ident').first)) - # self.ident_updated_at = Time.zone.now - # end end super(at) From 0fd682c6b94f4269939784ecad5281fc8ad1b0cc Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 9 Dec 2015 14:00:31 +0200 Subject: [PATCH 020/182] 107279984-credit_balance_views --- app/controllers/admin/registrars_controller.rb | 2 +- app/views/admin/account_activities/index.haml | 9 +++++++++ app/views/admin/registrars/index.haml | 7 +++++-- app/views/admin/registrars/show.haml | 3 +++ config/locales/en.yml | 1 + 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/registrars_controller.rb b/app/controllers/admin/registrars_controller.rb index c0d28908f..cf8c89505 100644 --- a/app/controllers/admin/registrars_controller.rb +++ b/app/controllers/admin/registrars_controller.rb @@ -6,7 +6,7 @@ class Admin::RegistrarsController < AdminController end def index - @q = Registrar.ordered.search(params[:q]) + @q = Registrar.joins(:accounts).ordered.search(params[:q]) @registrars = @q.result.page(params[:page]) end diff --git a/app/views/admin/account_activities/index.haml b/app/views/admin/account_activities/index.haml index 35e270dce..521ebf84c 100644 --- a/app/views/admin/account_activities/index.haml +++ b/app/views/admin/account_activities/index.haml @@ -55,6 +55,7 @@ %th{class: 'col-xs-2'} = sort_link(@q, 'sum') %tbody + -total = 0 - @account_activities.each do |x| %tr %td= link_to(x.account.registrar.try(:code), admin_registrar_path(x.account.registrar)) @@ -63,7 +64,15 @@ %td= l(x.created_at) - c = x.sum > 0.0 ? 'text-success' : 'text-danger' - s = x.sum > 0.0 ? "+#{x.sum} #{x.currency}" : "#{x.sum} #{x.currency}" + -total += x.sum %td{class: c}= s + - if @account_activities.count > 0 + %tr + %td + %td + %td + %td{class: 'text-right'}= t(:total) + %td{class: 'text-success'}= total > 0 ? "+#{total} EUR" : "#{total} EUR" .row .col-md-12 = paginate @account_activities diff --git a/app/views/admin/registrars/index.haml b/app/views/admin/registrars/index.haml index a2604dbec..8ba45d205 100644 --- a/app/views/admin/registrars/index.haml +++ b/app/views/admin/registrars/index.haml @@ -8,15 +8,18 @@ %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-6'} + %th{class: 'col-xs-4'} = sort_link(@q, 'name') - %th{class: 'col-xs-6'} + %th{class: 'col-xs-4'} = sort_link(@q, 'reg_no', t(:reg_no)) + %th{class: 'col-xs-4'} + = t(:credit_balance) %tbody - @registrars.each do |x| %tr %td= link_to(x, [:admin, x]) %td= x.reg_no + %td= "#{x.balance}" .row .col-md-12 = paginate @registrars diff --git a/app/views/admin/registrars/show.haml b/app/views/admin/registrars/show.haml index e3966583f..35938c0c6 100644 --- a/app/views/admin/registrars/show.haml +++ b/app/views/admin/registrars/show.haml @@ -32,6 +32,9 @@ %dt= t(:id) %dd= @registrar.code + %dt= t(:credit_balance) + %dd= @registrar.balance + .col-md-6 .panel.panel-default .panel-heading diff --git a/config/locales/en.yml b/config/locales/en.yml index 07f4ebc0a..07b8cde24 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -351,6 +351,7 @@ en: status: 'Status' eedirekt: 'EEDirekt' contact: 'Contact' + credit_balance: 'Credit balance' domain_transfer_requested: 'Domain transfer requested!' domain_transfer_approved: 'Domain transfer approved!' From 1651961147483eaf0b2801926d11700ad43af70b Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 9 Dec 2015 16:07:57 +0200 Subject: [PATCH 021/182] 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 022/182] 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 023/182] 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 06608b687bdbbdbd9f5db5ae3084ff67fe249a5e Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 11 Dec 2015 18:13:54 +0200 Subject: [PATCH 024/182] Story#109965360 - do not validate destroyed domain nameservers --- app/models/domain.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 780ff3b7a..7858b3d36 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -543,7 +543,7 @@ class Domain < ActiveRecord::Base ### VALIDATIONS ### def validate_nameserver_ips - nameservers.each do |ns| + nameservers.to_a.reject(&:marked_for_destruction?).each do |ns| next unless ns.hostname.end_with?(name) next if ns.ipv4.present? errors.add(:nameservers, :invalid) if errors[:nameservers].blank? From 6c38f3e5a58e6915ec7e4fc9f1f157f95bc4290d Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 3 Dec 2015 12:58:11 +0200 Subject: [PATCH 025/182] 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 026/182] 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 027/182] 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 028/182] 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 029/182] 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 030/182] 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 031/182] 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 032/182] 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 033/182] 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 034/182] 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 035/182] 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 036/182] 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 037/182] 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 038/182] 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 039/182] 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 040/182] 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 041/182] 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 042/182] 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 043/182] 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 044/182] 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 045/182] 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 046/182] 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 047/182] 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 048/182] 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 049/182] 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 050/182] 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 051/182] 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 052/182] 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 053/182] 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 054/182] 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 055/182] 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 056/182] 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 057/182] 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 058/182] 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 059/182] 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 060/182] 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 061/182] 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 062/182] 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 908a033b73e0327dac9c00fc12f8cbf093e1599b Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 14 Dec 2015 13:46:14 +0200 Subject: [PATCH 063/182] Story#109590460 - set business id validation --- app/models/contact.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index fcebe8632..1b96b9876 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -212,12 +212,16 @@ class Contact < ActiveRecord::Base end def ident_valid_format? - case ident_type - when 'priv' - case ident_country_code - when 'EE' - code = Isikukood.new(ident) - errors.add(:ident, :invalid_EE_identity_format) unless code.valid? + case ident_country_code + when 'EE'.freeze + case ident_type + when 'priv'.freeze + errors.add(:ident, :invalid_EE_identity_format) unless Isikukood.new(ident).valid? + when 'org'.freeze + last_char = ident.last + if ident.size != 8 || !%(1 8 9).freeze.include?(last_char) || ident !=~/\A[12][0-9]{6}[189]\z/ + errors.add(:ident, :invalid_EE_identity_format) + end end end end From 79b1125976f2cdaab260c92abfdc416d3efa4aa9 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 14 Dec 2015 13:47:01 +0200 Subject: [PATCH 064/182] Story#109590460 - update what contact ident attributes can be changed through EPP --- app/models/epp/contact.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 99f559041..91fbf23d1 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -162,10 +162,13 @@ class Epp::Contact < Contact if ident_frame && ident_attr_valid?(ident_frame) if ident_country_code.blank? && ident_type.in?(%w(org priv).freeze) - at.merge!(ident_country_code: ident_frame.attr('cc')) - end - if ident_type == "birthday" && ident !=~ /\d{4}-\d{2}-\d{2}/ + at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_type) + elsif ident_type == "birthday" && ident !=~ /\d{4}-\d{2}-\d{2}/ at.merge!(ident: ident_frame.text) + at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? + elsif ident_type.blank? && ident_type.blank? + at.merge!(ident_type: ident_type) + at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? end end end From 2b4de9a5c2260498caa586f18999c003e7ebc971 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 14 Dec 2015 14:07:45 +0200 Subject: [PATCH 065/182] Story#109590460 - typo --- 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 1b96b9876..6ac8de163 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -219,7 +219,7 @@ class Contact < ActiveRecord::Base errors.add(:ident, :invalid_EE_identity_format) unless Isikukood.new(ident).valid? when 'org'.freeze last_char = ident.last - if ident.size != 8 || !%(1 8 9).freeze.include?(last_char) || ident !=~/\A[12][0-9]{6}[189]\z/ + if ident.size != 8 || !%w(1 8 9).freeze.include?(last_char) || ident !=~/\A[12][0-9]{6}[189]\z/ errors.add(:ident, :invalid_EE_identity_format) end end From ffb8bc61dd195b93c2bc94878f0a58aaa0320d0c Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 14 Dec 2015 14:21:06 +0200 Subject: [PATCH 066/182] Story#109590460 - update country code validation --- app/models/contact.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 6ac8de163..c1d2f0c96 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -218,8 +218,8 @@ class Contact < ActiveRecord::Base when 'priv'.freeze errors.add(:ident, :invalid_EE_identity_format) unless Isikukood.new(ident).valid? when 'org'.freeze - last_char = ident.last - if ident.size != 8 || !%w(1 8 9).freeze.include?(last_char) || ident !=~/\A[12][0-9]{6}[189]\z/ + # !%w(1 7 8 9).freeze.include?(ident.first) || + if ident.size != 8 || ident !=~/\A[0-9]{8}\z/ errors.add(:ident, :invalid_EE_identity_format) end end From b5b0dc7f21c6d2e882193d8c009a5126c97394e9 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 14 Dec 2015 14:25:28 +0200 Subject: [PATCH 067/182] Story#109590460 - update country code validation --- 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 c1d2f0c96..1bf86b706 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -219,7 +219,7 @@ class Contact < ActiveRecord::Base errors.add(:ident, :invalid_EE_identity_format) unless Isikukood.new(ident).valid? when 'org'.freeze # !%w(1 7 8 9).freeze.include?(ident.first) || - if ident.size != 8 || ident !=~/\A[0-9]{8}\z/ + if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/) errors.add(:ident, :invalid_EE_identity_format) end end From 06b37d1ce4835eb1fc5e7d9d6e2853dd36d37b33 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 14 Dec 2015 16:07:09 +0200 Subject: [PATCH 068/182] Story#109590460 - forgot to update ident_type from XML --- app/models/epp/contact.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 91fbf23d1..01787d046 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -162,12 +162,12 @@ class Epp::Contact < Contact if ident_frame && ident_attr_valid?(ident_frame) if ident_country_code.blank? && ident_type.in?(%w(org priv).freeze) - at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_type) + at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_frame.attr('type')) elsif ident_type == "birthday" && ident !=~ /\d{4}-\d{2}-\d{2}/ at.merge!(ident: ident_frame.text) at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? elsif ident_type.blank? && ident_type.blank? - at.merge!(ident_type: ident_type) + at.merge!(ident_type: ident_frame.attr('type')) at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? end end From 38d3459e27c66900c330ffef77585d060a3f0fa7 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 14 Dec 2015 17:01:16 +0200 Subject: [PATCH 069/182] Story#109590460 - Update Ident updatable attributes --- app/models/epp/contact.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 01787d046..345f7ecee 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -161,14 +161,17 @@ class Epp::Contact < Contact ident_frame = frame.css('ident').first if ident_frame && ident_attr_valid?(ident_frame) - if ident_country_code.blank? && ident_type.in?(%w(org priv).freeze) + org_priv = %w(org priv).freeze + if ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.in?(ident_frame.attr('type')) at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_frame.attr('type')) - elsif ident_type == "birthday" && ident !=~ /\d{4}-\d{2}-\d{2}/ + elsif ident_type == "birthday" && ident !=~ /\d{4}-\d{2}-\d{2}/ && (Date.parse(ident) rescue false) at.merge!(ident: ident_frame.text) at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? - elsif ident_type.blank? && ident_type.blank? + elsif ident_type.blank? && ident_country_code.blank? at.merge!(ident_type: ident_frame.attr('type')) at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? + else + throw :epp_error, {code: '2306', msg: I18n.t(:ident_update_error)} end end end From 95454229ca0feb9783deaf8ee62bef7d49d744c2 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 17:43:24 +0200 Subject: [PATCH 070/182] 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 071/182] 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 2802fcd0af8e8b255f4705f03b8a507087f09320 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 15 Dec 2015 16:55:02 +0200 Subject: [PATCH 072/182] 110067564-job type and registrar id changes --- app/models/domain.rb | 2 +- app/models/registrant_verification.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 7858b3d36..53badd3fd 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -439,7 +439,7 @@ class Domain < ActiveRecord::Base end def pending_update! - old_registrant_id = registrant_id + old_registrant_id = registrant_id_was return true if pending_update? self.epp_pending_update = true # for epp diff --git a/app/models/registrant_verification.rb b/app/models/registrant_verification.rb index d0c015ecb..29bde4b70 100644 --- a/app/models/registrant_verification.rb +++ b/app/models/registrant_verification.rb @@ -23,7 +23,7 @@ class RegistrantVerification < ActiveRecord::Base def domain_registrant_change_reject! self.action_type = DOMAIN_REGISTRANT_CHANGE self.action = REJECTED - DomainUpdateConfirmJob.enqueue domain.id, REJECTED if save + DomainUpdateConfirmJob.run domain.id, REJECTED if save end def domain_registrant_delete_confirm! From 6842fbccd64ff2fbbe7d6dd499604add402d0f42 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 16 Dec 2015 11:37:02 +0200 Subject: [PATCH 073/182] 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 074/182] 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 075/182] 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 076/182] 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 077/182] 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 078/182] 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 079/182] 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 080/182] 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 081/182] 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 082/182] 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 9ac1e8c933b95cb7f638365d09512ab22137e678 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 11:27:06 +0200 Subject: [PATCH 083/182] Story #110211760 - ensure that upDate is not shown when domain has not changed since creation --- 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 39aa91b39..fe851a6d9 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -51,7 +51,7 @@ xml.epp_head do xml.tag!('contact:crID', @contact.cr_id) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) - if @contact.updated_at != @contact.created_at + if @contact.updated_at > @contact.created_at 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 diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index ec5947b13..ef283ab07 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -41,7 +41,7 @@ xml.epp_head do xml.tag!('domain:crID', @domain.cr_id) xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) - if @domain.updated_at != @domain.created_at + if @domain.updated_at > @domain.created_at 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 From 702206b9c00c14a70e4cacc388080f14cc0d1e34 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 11:51:36 +0200 Subject: [PATCH 084/182] 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 085/182] 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 086/182] 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 087/182] 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 088/182] 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 089/182] 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 090/182] 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 091/182] 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 092/182] 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 093/182] 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 094/182] 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 095/182] 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 096/182] 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 097/182] 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 098/182] 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 099/182] 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 100/182] 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 101/182] 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 102/182] 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 103/182] 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 104/182] 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 105/182] 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 106/182] 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 6909f3d0ef19be4a05cbd26476a4b0d838536404 Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 18 Dec 2015 13:30:51 +0200 Subject: [PATCH 107/182] 10729984-starting_balance --- app/controllers/admin/account_activities_controller.rb | 1 + app/views/admin/account_activities/index.haml | 7 +++++++ config/locales/en.yml | 1 + 3 files changed, 9 insertions(+) diff --git a/app/controllers/admin/account_activities_controller.rb b/app/controllers/admin/account_activities_controller.rb index 1c447d8a6..640acf2e7 100644 --- a/app/controllers/admin/account_activities_controller.rb +++ b/app/controllers/admin/account_activities_controller.rb @@ -14,6 +14,7 @@ class Admin::AccountActivitiesController < AdminController @q = AccountActivity.includes(:invoice, account: :registrar).search(params[:q]) @q.sorts = 'id desc' if @q.sorts.empty? + @b = AccountActivity.where.not(id: @q.result.map(&:id)) respond_to do |format| format.html { @account_activities = @q.result.page(params[:page]) } diff --git a/app/views/admin/account_activities/index.haml b/app/views/admin/account_activities/index.haml index 521ebf84c..6efefb814 100644 --- a/app/views/admin/account_activities/index.haml +++ b/app/views/admin/account_activities/index.haml @@ -36,6 +36,13 @@   %button.btn.btn-default.js-reset-form = t(:clear_fields) +.row + .col-md-3 + .col-md-3 + .col-md-2 + .col-md-4{class: 'text-right'} + = t(:starting_balance) + " #{@b.sum('sum').to_f} EUR" + %hr .row diff --git a/config/locales/en.yml b/config/locales/en.yml index 07b8cde24..fbfc09780 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -352,6 +352,7 @@ en: eedirekt: 'EEDirekt' contact: 'Contact' credit_balance: 'Credit balance' + starting_balance: 'Starting balance' domain_transfer_requested: 'Domain transfer requested!' domain_transfer_approved: 'Domain transfer approved!' From 9027f5007c14134067dad7ffe61a74498138851a Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 18 Dec 2015 14:00:41 +0200 Subject: [PATCH 108/182] 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 109/182] 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 110/182] 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 111/182] 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 112/182] 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 113/182] 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 114/182] 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 From f46c7f554397584b12b4d97fa07865891ddfdc7a Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 4 Jan 2016 16:35:02 +0200 Subject: [PATCH 115/182] 110152326-is_registrant_filter_modification --- app/controllers/admin/contacts_controller.rb | 10 ++++++++-- app/views/admin/contacts/index.haml | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/contacts_controller.rb b/app/controllers/admin/contacts_controller.rb index a1df165d2..50131066f 100644 --- a/app/controllers/admin/contacts_controller.rb +++ b/app/controllers/admin/contacts_controller.rb @@ -4,7 +4,13 @@ class Admin::ContactsController < AdminController def index params[:q] ||= {} - @q = Contact.includes(:registrar).search(params[:q]) + search_params = params[:q].deep_dup + + if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant') + search_params[:registrant_domains_id_not_null] = 1 + end + + @q = Contact.includes(:registrar).search(search_params) @contacts = @q.result.page(params[:page]) if params[:statuses_contains] @@ -16,7 +22,7 @@ class Admin::ContactsController < AdminController end normalize_search_parameters do - @q = contacts.search(params[:q]) + @q = contacts.search(search_params) @contacts = @q.result.page(params[:page]) end diff --git a/app/views/admin/contacts/index.haml b/app/views/admin/contacts/index.haml index b8e7850e6..c200dac02 100644 --- a/app/views/admin/contacts/index.haml +++ b/app/views/admin/contacts/index.haml @@ -37,7 +37,7 @@ .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' } + = select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact'], ['registrant', 'registrant']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } .row .col-md-3 .form-group From 6415bfae389d70dd986af7d3ffa45dab1ee32fa3 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 5 Jan 2016 14:08:51 +0200 Subject: [PATCH 116/182] Story#108091488 - Seems that now reserved domains will be in better table --- .../admin/reserved_domains_controller.rb | 8 +++---- app/models/reserved_domain.rb | 23 +++++++++++-------- ...6_name_and_password_for_reserved_domain.rb | 17 ++++++++++++++ db/seeds.rb | 2 +- 4 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20151202123506_name_and_password_for_reserved_domain.rb diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb index 57e4b8ed3..622f56eb2 100644 --- a/app/controllers/admin/reserved_domains_controller.rb +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -2,7 +2,7 @@ class Admin::ReservedDomainsController < AdminController load_and_authorize_resource def index - names = ReservedDomain.pluck(:names).each_with_object({}){|e_h,h| h.merge!(e_h)} + names = ReservedDomain.pluck(:name, :password).each_with_object({}){|domain, hash| hash[domain[0]] = domain[1]} names.names = nil if names.blank? @reserved_domains = names.to_yaml.gsub(/---.?\n/, '').gsub(/\.\.\..?\n/, '') end @@ -28,9 +28,8 @@ class Admin::ReservedDomainsController < AdminController #updating and adding names.each do |name, psw| - rec = ReservedDomain.by_domain(name).first - rec ||= ReservedDomain.new - rec.names = {name => psw} + rec = ReservedDomain.find_or_initialize_by(name: name) + rec.password = psw unless rec.save result = false @@ -39,7 +38,6 @@ class Admin::ReservedDomainsController < AdminController end end - if result flash[:notice] = I18n.t('record_updated') redirect_to :back diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 09d72ec17..057321e56 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -2,24 +2,27 @@ class ReservedDomain < ActiveRecord::Base include Versions # version/reserved_domain_version.rb before_save :fill_empty_passwords - def fill_empty_passwords - return unless names - names.each { |k, v| names[k] = SecureRandom.hex if v.blank? } - end - class << self def pw_for(domain_name) - name_in_unicode = SimpleIDN.to_ascii(domain_name) - by_domain(domain_name).select("names -> '#{domain_name}' AS pw").first.try(:pw) || - by_domain(name_in_unicode).select("names -> '#{name_in_unicode}' AS pw").first.try(:pw) + name_in_ascii = SimpleIDN.to_ascii(domain_name) + by_domain(domain_name).first.try(:password) || by_domain(name_in_ascii).first.try(:password) end def by_domain name - where("names ? '#{name}'") + where(name: name) end def any_of_domains names - where("names ?| ARRAY['#{names.join("','")}']") + where(name: names) end end + + + def fill_empty_passwords + self.password = SecureRandom.hex unless self.password + end + + def name= val + super SimpleIDN.to_unicode(val) + end end diff --git a/db/migrate/20151202123506_name_and_password_for_reserved_domain.rb b/db/migrate/20151202123506_name_and_password_for_reserved_domain.rb new file mode 100644 index 000000000..1176ee255 --- /dev/null +++ b/db/migrate/20151202123506_name_and_password_for_reserved_domain.rb @@ -0,0 +1,17 @@ +class NameAndPasswordForReservedDomain < ActiveRecord::Migration + def up + add_column :reserved_domains, :name, :string + add_column :reserved_domains, :password, :string + + ReservedDomain.find_each do |domain| + names = domain.names + domain.update_columns(name: names.keys.first, password: names.values.first) + end + + remove_column :reserved_domains, :names + end + + def down + + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 636ff4361..ac6da0598 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -73,7 +73,7 @@ admin3 = { [admin1, admin2, admin3].each do |at| admin = AdminUser.where(at) next if admin.present? - admin = AdminUser.new(at.merge({ password_confirmation: 'testtest' })) + admin = AdminUser.new(at.merge({ password_confirmation: 'testtest', password: 'testtest' })) admin.roles = ['admin'] admin.save end From f3d22e0145d2b1f46fc21286685ff1db8f7d75d6 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 5 Jan 2016 14:41:09 +0200 Subject: [PATCH 117/182] 110152326-registrar_portal_filter --- app/controllers/registrar/contacts_controller.rb | 13 ++++++++++--- app/views/admin/contacts/index.haml | 7 +------ app/views/registrar/contacts/index.haml | 9 ++------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index 878e29cd2..c0b814993 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -6,8 +6,15 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller 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]) + + search_params = params[:q].deep_dup + + if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant') + search_params[:registrant_domains_id_not_null] = 1 + end + + if search_params.length == 1 && search_params[:name_matches].present? + @contacts = Contact.find_by(name: search_params[:name_matches]) end if params[:statuses_contains] @@ -19,7 +26,7 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller end normalize_search_parameters do - @q = contacts.search(params[:q]) + @q = contacts.search(search_params) @contacts = @q.result.page(params[:page]) end diff --git a/app/views/admin/contacts/index.haml b/app/views/admin/contacts/index.haml index c200dac02..715b87eb6 100644 --- a/app/views/admin/contacts/index.haml +++ b/app/views/admin/contacts/index.haml @@ -29,12 +29,7 @@ .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 + .col-md-6 .form-group = label_tag t(:contact_type) = select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact'], ['registrant', 'registrant']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } diff --git a/app/views/registrar/contacts/index.haml b/app/views/registrar/contacts/index.haml index ae93a82fd..2226f7c6a 100644 --- a/app/views/registrar/contacts/index.haml +++ b/app/views/registrar/contacts/index.haml @@ -31,15 +31,10 @@ .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 + .col-md-6 .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' } + = select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact'], ['registrant', 'registrant']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } .row .col-md-3 .form-group From 399ea93a232e03f71349e09a85b3c4afc19a5e8f Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Tue, 5 Jan 2016 14:53:04 +0200 Subject: [PATCH 118/182] disclose refix --- 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 528f84816..08d1cdf14 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -52,7 +52,7 @@ class WhoisRecord < ActiveRecord::Base h[:registrant] = domain.registrant.name - h[:registrant_email] = domain.registrant.email + h[:email] = domain.registrant.email @disclosed << [:email, domain.registrant.email] h[:registrant_changed] = domain.registrant.updated_at.try(:to_s, :iso8601) From 6be09329d76ac410a1c66f0c5d6c272baa45c5c0 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 5 Jan 2016 15:03:29 +0200 Subject: [PATCH 119/182] Story#108091488 - add index to reserved domains --- ...6_name_and_password_for_reserved_domain.rb | 1 + db/schema-read-only.rb | 57 ++--- db/structure.sql | 219 ++++++++++++------ 3 files changed, 167 insertions(+), 110 deletions(-) diff --git a/db/migrate/20151202123506_name_and_password_for_reserved_domain.rb b/db/migrate/20151202123506_name_and_password_for_reserved_domain.rb index 1176ee255..3e4f16500 100644 --- a/db/migrate/20151202123506_name_and_password_for_reserved_domain.rb +++ b/db/migrate/20151202123506_name_and_password_for_reserved_domain.rb @@ -2,6 +2,7 @@ class NameAndPasswordForReservedDomain < ActiveRecord::Migration def up add_column :reserved_domains, :name, :string add_column :reserved_domains, :password, :string + add_index :reserved_domains, :name ReservedDomain.find_each do |domain| names = domain.names diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index b362619b0..6cb666e3b 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20151029152638) do +ActiveRecord::Schema.define(version: 20151202123506) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -240,19 +240,20 @@ ActiveRecord::Schema.define(version: 20151029152638) do end create_table "dnskeys", force: :cascade do |t| - t.integer "domain_id" - t.integer "flags" - t.integer "protocol" - t.integer "alg" - t.text "public_key" - t.integer "delegation_signer_id" - t.string "ds_key_tag" - t.integer "ds_alg" - t.integer "ds_digest_type" - t.string "ds_digest" - t.string "creator_str" - t.string "updator_str" - t.integer "legacy_domain_id" + t.integer "domain_id" + t.integer "flags" + t.integer "protocol" + t.integer "alg" + t.text "public_key" + t.integer "delegation_signer_id" + t.string "ds_key_tag" + t.integer "ds_alg" + t.integer "ds_digest_type" + t.string "ds_digest" + t.string "creator_str" + t.string "updator_str" + t.integer "legacy_domain_id" + t.datetime "updated_at" end add_index "dnskeys", ["delegation_signer_id"], name: "index_dnskeys_on_delegation_signer_id", using: :btree @@ -336,6 +337,7 @@ ActiveRecord::Schema.define(version: 20151029152638) do end add_index "domains", ["delete_at"], name: "index_domains_on_delete_at", using: :btree + add_index "domains", ["name"], name: "index_domains_on_name", unique: true, using: :btree add_index "domains", ["outzone_at"], name: "index_domains_on_outzone_at", using: :btree add_index "domains", ["registrant_id"], name: "index_domains_on_registrant_id", using: :btree add_index "domains", ["registrant_verification_asked_at"], name: "index_domains_on_registrant_verification_asked_at", using: :btree @@ -442,9 +444,7 @@ ActiveRecord::Schema.define(version: 20151029152638) do t.integer "documentable_id" t.string "documentable_type" t.datetime "created_at" - t.datetime "updated_at" t.string "creator_str" - t.string "updator_str" t.string "path" end @@ -739,21 +739,6 @@ ActiveRecord::Schema.define(version: 20151029152638) do add_index "log_keyrelays", ["item_type", "item_id"], name: "index_log_keyrelays_on_item_type_and_item_id", using: :btree add_index "log_keyrelays", ["whodunnit"], name: "index_log_keyrelays_on_whodunnit", using: :btree - create_table "log_legal_documents", force: :cascade do |t| - t.string "item_type", null: false - t.integer "item_id", null: false - t.string "event", null: false - t.string "whodunnit" - t.json "object" - t.json "object_changes" - t.datetime "created_at" - t.string "session" - t.json "children" - end - - add_index "log_legal_documents", ["item_type", "item_id"], name: "index_log_legal_documents_on_item_type_and_item_id", using: :btree - add_index "log_legal_documents", ["whodunnit"], name: "index_log_legal_documents_on_whodunnit", using: :btree - create_table "log_messages", force: :cascade do |t| t.string "item_type", null: false t.integer "item_id", null: false @@ -910,10 +895,10 @@ ActiveRecord::Schema.define(version: 20151029152638) do create_table "nameservers", force: :cascade do |t| t.string "hostname" - t.string "ipv4" + t.string "ipv4", array: true t.datetime "created_at" t.datetime "updated_at" - t.string "ipv6" + t.string "ipv6", array: true t.integer "domain_id" t.string "creator_str" t.string "updator_str" @@ -1011,9 +996,13 @@ ActiveRecord::Schema.define(version: 20151029152638) do t.datetime "updated_at" t.string "creator_str" t.string "updator_str" - t.hstore "names" + t.integer "legacy_id" + t.string "name" + t.string "password" end + add_index "reserved_domains", ["name"], name: "index_reserved_domains_on_name", using: :btree + create_table "settings", force: :cascade do |t| t.string "var", null: false t.text "value" diff --git a/db/structure.sql b/db/structure.sql index b2480a04e..c4ede9569 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -39,6 +39,106 @@ COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs SET search_path = public, pg_catalog; +-- +-- Name: fill_ident_country(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION fill_ident_country() RETURNS boolean + LANGUAGE plpgsql + AS $_$ + DECLARE + changed BOOLEAN; + multiplier INT []; + multiplier2 INT []; + multiplier3 INT []; + multiplier4 INT []; + r RECORD; + control TEXT; + total INT; + i INT; + mod INT; + counter INT; + BEGIN + + multiplier := ARRAY [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]; + multiplier2 := ARRAY [3, 4, 5, 6, 7, 8, 9, 1, 2, 3]; + multiplier3 := ARRAY [1, 2, 3, 4, 5, 6, 7]; + multiplier4 := ARRAY [3, 4, 5, 6, 7, 8, 9]; + + FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'priv' AND ident_country_code IS NULL + LOOP + IF (length(r.ident) = 11 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '3' OR substring(r.ident, 1, 1) = '4' OR substring(r.ident, 1, 1) = '5' OR substring(r.ident, 1, 1) = '6')) + THEN + total := 0; + counter := 1; + FOREACH i IN ARRAY multiplier + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + counter := 1; + IF (mod >= 10) + THEN + total = 0; + FOREACH i IN ARRAY multiplier2 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + END IF; + IF (mod = 10) + THEN + mod := 0; + END IF; + IF (substring(r.ident, 11, 1) = to_char(mod, 'FM999MI')) + THEN + UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; + END IF; + total := 0; + END IF; + END LOOP; + + FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'org' AND ident_country_code IS NULL + LOOP + IF (length(r.ident) = 8 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '1' OR substring(r.ident, 1, 1) = '8' OR substring(r.ident, 1, 1) = '9')) + THEN + total := 0; + counter := 1; + FOREACH i IN ARRAY multiplier3 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := total % 11; + total := 0; + counter := 1; + IF (mod >= 10) + THEN + total = 0; + FOREACH i IN ARRAY multiplier4 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + END IF; + IF (mod = 10) + THEN + mod := 0; + END IF; + IF (substring(r.ident, 8, 1) = to_char(mod, 'FM999MI')) + THEN + UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; + END IF; + END IF; + END LOOP; + RETURN changed; + END; + $_$; + + -- -- Name: generate_zonefile(character varying); Type: FUNCTION; Schema: public; Owner: - -- @@ -114,7 +214,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter AND ns.hostname LIKE '%.' || d.name AND d.name <> i_origin - AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '' + AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '{}' AND NOT ('{serverHold,clientHold}' && d.statuses) ), chr(10) ) INTO tmp_var; @@ -134,7 +234,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter AND ns.hostname LIKE '%.' || d.name AND d.name <> i_origin - AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '' + AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '{}' AND NOT ('{serverHold,clientHold}' && d.statuses) ), chr(10) ) INTO tmp_var; @@ -145,8 +245,8 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text SELECT array_to_string( array( SELECT concat( - d.name_puny, '. IN DS ', dk.ds_key_tag, ' ', - dk.ds_alg, ' ', dk.ds_digest_type, ' ( ', dk.ds_digest, ' )' + d.name_puny, '. 3600 IN DS ', dk.ds_key_tag, ' ', + dk.ds_alg, ' ', dk.ds_digest_type, ' ', dk.ds_digest ) FROM domains d JOIN dnskeys dk ON dk.domain_id = d.id @@ -745,7 +845,8 @@ CREATE TABLE dnskeys ( ds_digest character varying, creator_str character varying, updator_str character varying, - legacy_domain_id integer + legacy_domain_id integer, + updated_at timestamp without time zone ); @@ -1130,9 +1231,7 @@ CREATE TABLE legal_documents ( documentable_id integer, documentable_type character varying, created_at timestamp without time zone, - updated_at timestamp without time zone, creator_str character varying, - updator_str character varying, path character varying ); @@ -1863,43 +1962,6 @@ CREATE SEQUENCE log_keyrelays_id_seq ALTER SEQUENCE log_keyrelays_id_seq OWNED BY log_keyrelays.id; --- --- Name: log_legal_documents; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE log_legal_documents ( - id integer NOT NULL, - item_type character varying NOT NULL, - item_id integer NOT NULL, - event character varying NOT NULL, - whodunnit character varying, - object json, - object_changes json, - created_at timestamp without time zone, - session character varying, - children json -); - - --- --- Name: log_legal_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE log_legal_documents_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: log_legal_documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE log_legal_documents_id_seq OWNED BY log_legal_documents.id; - - -- -- Name: log_messages; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -2313,10 +2375,10 @@ ALTER SEQUENCE messages_id_seq OWNED BY messages.id; CREATE TABLE nameservers ( id integer NOT NULL, hostname character varying, - ipv4 character varying, + ipv4 character varying[], created_at timestamp without time zone, updated_at timestamp without time zone, - ipv6 character varying, + ipv6 character varying[], domain_id integer, creator_str character varying, updator_str character varying, @@ -2560,7 +2622,9 @@ CREATE TABLE reserved_domains ( updated_at timestamp without time zone, creator_str character varying, updator_str character varying, - names hstore + legacy_id integer, + name character varying, + password character varying ); @@ -3126,13 +3190,6 @@ ALTER TABLE ONLY log_invoices ALTER COLUMN id SET DEFAULT nextval('log_invoices_ ALTER TABLE ONLY log_keyrelays ALTER COLUMN id SET DEFAULT nextval('log_keyrelays_id_seq'::regclass); --- --- Name: id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY log_legal_documents ALTER COLUMN id SET DEFAULT nextval('log_legal_documents_id_seq'::regclass); - - -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3645,14 +3702,6 @@ ALTER TABLE ONLY log_keyrelays ADD CONSTRAINT log_keyrelays_pkey PRIMARY KEY (id); --- --- Name: log_legal_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: --- - -ALTER TABLE ONLY log_legal_documents - ADD CONSTRAINT log_legal_documents_pkey PRIMARY KEY (id); - - -- -- Name: log_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -3985,6 +4034,13 @@ CREATE INDEX index_domain_transfers_on_domain_id ON domain_transfers USING btree CREATE INDEX index_domains_on_delete_at ON domains USING btree (delete_at); +-- +-- Name: index_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE UNIQUE INDEX index_domains_on_name ON domains USING btree (name); + + -- -- Name: index_domains_on_outzone_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4349,20 +4405,6 @@ CREATE INDEX index_log_keyrelays_on_item_type_and_item_id ON log_keyrelays USING CREATE INDEX index_log_keyrelays_on_whodunnit ON log_keyrelays USING btree (whodunnit); --- --- Name: index_log_legal_documents_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_legal_documents_on_item_type_and_item_id ON log_legal_documents USING btree (item_type, item_id); - - --- --- Name: index_log_legal_documents_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_legal_documents_on_whodunnit ON log_legal_documents USING btree (whodunnit); - - -- -- Name: index_log_messages_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4510,6 +4552,13 @@ CREATE INDEX index_registrant_verifications_on_domain_id ON registrant_verificat CREATE INDEX index_registrars_on_code ON registrars USING btree (code); +-- +-- Name: index_reserved_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_reserved_domains_on_name ON reserved_domains USING btree (name); + + -- -- Name: index_settings_on_thing_type_and_thing_id_and_var; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4947,5 +4996,23 @@ INSERT INTO schema_migrations (version) VALUES ('20150921110152'); INSERT INTO schema_migrations (version) VALUES ('20150921111842'); +INSERT INTO schema_migrations (version) VALUES ('20151028183132'); + INSERT INTO schema_migrations (version) VALUES ('20151029152638'); +INSERT INTO schema_migrations (version) VALUES ('20151112160452'); + +INSERT INTO schema_migrations (version) VALUES ('20151117081204'); + +INSERT INTO schema_migrations (version) VALUES ('20151120090455'); + +INSERT INTO schema_migrations (version) VALUES ('20151124200353'); + +INSERT INTO schema_migrations (version) VALUES ('20151125155601'); + +INSERT INTO schema_migrations (version) VALUES ('20151127091716'); + +INSERT INTO schema_migrations (version) VALUES ('20151130175654'); + +INSERT INTO schema_migrations (version) VALUES ('20151202123506'); + From 737afe57dfa1f2edb8df48b5dc58db30e915f7c1 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 5 Jan 2016 15:07:20 +0200 Subject: [PATCH 120/182] Story#108091488 - revert DB schema --- db/schema-read-only.rb | 57 ++++++----- db/structure.sql | 219 ++++++++++++++--------------------------- 2 files changed, 110 insertions(+), 166 deletions(-) diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 6cb666e3b..b362619b0 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20151202123506) do +ActiveRecord::Schema.define(version: 20151029152638) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -240,20 +240,19 @@ ActiveRecord::Schema.define(version: 20151202123506) do end create_table "dnskeys", force: :cascade do |t| - t.integer "domain_id" - t.integer "flags" - t.integer "protocol" - t.integer "alg" - t.text "public_key" - t.integer "delegation_signer_id" - t.string "ds_key_tag" - t.integer "ds_alg" - t.integer "ds_digest_type" - t.string "ds_digest" - t.string "creator_str" - t.string "updator_str" - t.integer "legacy_domain_id" - t.datetime "updated_at" + t.integer "domain_id" + t.integer "flags" + t.integer "protocol" + t.integer "alg" + t.text "public_key" + t.integer "delegation_signer_id" + t.string "ds_key_tag" + t.integer "ds_alg" + t.integer "ds_digest_type" + t.string "ds_digest" + t.string "creator_str" + t.string "updator_str" + t.integer "legacy_domain_id" end add_index "dnskeys", ["delegation_signer_id"], name: "index_dnskeys_on_delegation_signer_id", using: :btree @@ -337,7 +336,6 @@ ActiveRecord::Schema.define(version: 20151202123506) do end add_index "domains", ["delete_at"], name: "index_domains_on_delete_at", using: :btree - add_index "domains", ["name"], name: "index_domains_on_name", unique: true, using: :btree add_index "domains", ["outzone_at"], name: "index_domains_on_outzone_at", using: :btree add_index "domains", ["registrant_id"], name: "index_domains_on_registrant_id", using: :btree add_index "domains", ["registrant_verification_asked_at"], name: "index_domains_on_registrant_verification_asked_at", using: :btree @@ -444,7 +442,9 @@ ActiveRecord::Schema.define(version: 20151202123506) do t.integer "documentable_id" t.string "documentable_type" t.datetime "created_at" + t.datetime "updated_at" t.string "creator_str" + t.string "updator_str" t.string "path" end @@ -739,6 +739,21 @@ ActiveRecord::Schema.define(version: 20151202123506) do add_index "log_keyrelays", ["item_type", "item_id"], name: "index_log_keyrelays_on_item_type_and_item_id", using: :btree add_index "log_keyrelays", ["whodunnit"], name: "index_log_keyrelays_on_whodunnit", using: :btree + create_table "log_legal_documents", force: :cascade do |t| + t.string "item_type", null: false + t.integer "item_id", null: false + t.string "event", null: false + t.string "whodunnit" + t.json "object" + t.json "object_changes" + t.datetime "created_at" + t.string "session" + t.json "children" + end + + add_index "log_legal_documents", ["item_type", "item_id"], name: "index_log_legal_documents_on_item_type_and_item_id", using: :btree + add_index "log_legal_documents", ["whodunnit"], name: "index_log_legal_documents_on_whodunnit", using: :btree + create_table "log_messages", force: :cascade do |t| t.string "item_type", null: false t.integer "item_id", null: false @@ -895,10 +910,10 @@ ActiveRecord::Schema.define(version: 20151202123506) do create_table "nameservers", force: :cascade do |t| t.string "hostname" - t.string "ipv4", array: true + t.string "ipv4" t.datetime "created_at" t.datetime "updated_at" - t.string "ipv6", array: true + t.string "ipv6" t.integer "domain_id" t.string "creator_str" t.string "updator_str" @@ -996,13 +1011,9 @@ ActiveRecord::Schema.define(version: 20151202123506) do t.datetime "updated_at" t.string "creator_str" t.string "updator_str" - t.integer "legacy_id" - t.string "name" - t.string "password" + t.hstore "names" end - add_index "reserved_domains", ["name"], name: "index_reserved_domains_on_name", using: :btree - create_table "settings", force: :cascade do |t| t.string "var", null: false t.text "value" diff --git a/db/structure.sql b/db/structure.sql index c4ede9569..b2480a04e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -39,106 +39,6 @@ COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs SET search_path = public, pg_catalog; --- --- Name: fill_ident_country(); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION fill_ident_country() RETURNS boolean - LANGUAGE plpgsql - AS $_$ - DECLARE - changed BOOLEAN; - multiplier INT []; - multiplier2 INT []; - multiplier3 INT []; - multiplier4 INT []; - r RECORD; - control TEXT; - total INT; - i INT; - mod INT; - counter INT; - BEGIN - - multiplier := ARRAY [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]; - multiplier2 := ARRAY [3, 4, 5, 6, 7, 8, 9, 1, 2, 3]; - multiplier3 := ARRAY [1, 2, 3, 4, 5, 6, 7]; - multiplier4 := ARRAY [3, 4, 5, 6, 7, 8, 9]; - - FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'priv' AND ident_country_code IS NULL - LOOP - IF (length(r.ident) = 11 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '3' OR substring(r.ident, 1, 1) = '4' OR substring(r.ident, 1, 1) = '5' OR substring(r.ident, 1, 1) = '6')) - THEN - total := 0; - counter := 1; - FOREACH i IN ARRAY multiplier - LOOP - total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); - counter := (counter + 1); - END LOOP; - mod := (total % 11); - counter := 1; - IF (mod >= 10) - THEN - total = 0; - FOREACH i IN ARRAY multiplier2 - LOOP - total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); - counter := (counter + 1); - END LOOP; - mod := (total % 11); - END IF; - IF (mod = 10) - THEN - mod := 0; - END IF; - IF (substring(r.ident, 11, 1) = to_char(mod, 'FM999MI')) - THEN - UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; - END IF; - total := 0; - END IF; - END LOOP; - - FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'org' AND ident_country_code IS NULL - LOOP - IF (length(r.ident) = 8 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '1' OR substring(r.ident, 1, 1) = '8' OR substring(r.ident, 1, 1) = '9')) - THEN - total := 0; - counter := 1; - FOREACH i IN ARRAY multiplier3 - LOOP - total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); - counter := (counter + 1); - END LOOP; - mod := total % 11; - total := 0; - counter := 1; - IF (mod >= 10) - THEN - total = 0; - FOREACH i IN ARRAY multiplier4 - LOOP - total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); - counter := (counter + 1); - END LOOP; - mod := (total % 11); - END IF; - IF (mod = 10) - THEN - mod := 0; - END IF; - IF (substring(r.ident, 8, 1) = to_char(mod, 'FM999MI')) - THEN - UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; - END IF; - END IF; - END LOOP; - RETURN changed; - END; - $_$; - - -- -- Name: generate_zonefile(character varying); Type: FUNCTION; Schema: public; Owner: - -- @@ -214,7 +114,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter AND ns.hostname LIKE '%.' || d.name AND d.name <> i_origin - AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '{}' + AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '' AND NOT ('{serverHold,clientHold}' && d.statuses) ), chr(10) ) INTO tmp_var; @@ -234,7 +134,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter AND ns.hostname LIKE '%.' || d.name AND d.name <> i_origin - AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '{}' + AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '' AND NOT ('{serverHold,clientHold}' && d.statuses) ), chr(10) ) INTO tmp_var; @@ -245,8 +145,8 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text SELECT array_to_string( array( SELECT concat( - d.name_puny, '. 3600 IN DS ', dk.ds_key_tag, ' ', - dk.ds_alg, ' ', dk.ds_digest_type, ' ', dk.ds_digest + d.name_puny, '. IN DS ', dk.ds_key_tag, ' ', + dk.ds_alg, ' ', dk.ds_digest_type, ' ( ', dk.ds_digest, ' )' ) FROM domains d JOIN dnskeys dk ON dk.domain_id = d.id @@ -845,8 +745,7 @@ CREATE TABLE dnskeys ( ds_digest character varying, creator_str character varying, updator_str character varying, - legacy_domain_id integer, - updated_at timestamp without time zone + legacy_domain_id integer ); @@ -1231,7 +1130,9 @@ CREATE TABLE legal_documents ( documentable_id integer, documentable_type character varying, created_at timestamp without time zone, + updated_at timestamp without time zone, creator_str character varying, + updator_str character varying, path character varying ); @@ -1962,6 +1863,43 @@ CREATE SEQUENCE log_keyrelays_id_seq ALTER SEQUENCE log_keyrelays_id_seq OWNED BY log_keyrelays.id; +-- +-- Name: log_legal_documents; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- + +CREATE TABLE log_legal_documents ( + id integer NOT NULL, + item_type character varying NOT NULL, + item_id integer NOT NULL, + event character varying NOT NULL, + whodunnit character varying, + object json, + object_changes json, + created_at timestamp without time zone, + session character varying, + children json +); + + +-- +-- Name: log_legal_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE log_legal_documents_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: log_legal_documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE log_legal_documents_id_seq OWNED BY log_legal_documents.id; + + -- -- Name: log_messages; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -2375,10 +2313,10 @@ ALTER SEQUENCE messages_id_seq OWNED BY messages.id; CREATE TABLE nameservers ( id integer NOT NULL, hostname character varying, - ipv4 character varying[], + ipv4 character varying, created_at timestamp without time zone, updated_at timestamp without time zone, - ipv6 character varying[], + ipv6 character varying, domain_id integer, creator_str character varying, updator_str character varying, @@ -2622,9 +2560,7 @@ CREATE TABLE reserved_domains ( updated_at timestamp without time zone, creator_str character varying, updator_str character varying, - legacy_id integer, - name character varying, - password character varying + names hstore ); @@ -3190,6 +3126,13 @@ ALTER TABLE ONLY log_invoices ALTER COLUMN id SET DEFAULT nextval('log_invoices_ ALTER TABLE ONLY log_keyrelays ALTER COLUMN id SET DEFAULT nextval('log_keyrelays_id_seq'::regclass); +-- +-- Name: id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY log_legal_documents ALTER COLUMN id SET DEFAULT nextval('log_legal_documents_id_seq'::regclass); + + -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3702,6 +3645,14 @@ ALTER TABLE ONLY log_keyrelays ADD CONSTRAINT log_keyrelays_pkey PRIMARY KEY (id); +-- +-- Name: log_legal_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY log_legal_documents + ADD CONSTRAINT log_legal_documents_pkey PRIMARY KEY (id); + + -- -- Name: log_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -4034,13 +3985,6 @@ CREATE INDEX index_domain_transfers_on_domain_id ON domain_transfers USING btree CREATE INDEX index_domains_on_delete_at ON domains USING btree (delete_at); --- --- Name: index_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE UNIQUE INDEX index_domains_on_name ON domains USING btree (name); - - -- -- Name: index_domains_on_outzone_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4405,6 +4349,20 @@ CREATE INDEX index_log_keyrelays_on_item_type_and_item_id ON log_keyrelays USING CREATE INDEX index_log_keyrelays_on_whodunnit ON log_keyrelays USING btree (whodunnit); +-- +-- Name: index_log_legal_documents_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_log_legal_documents_on_item_type_and_item_id ON log_legal_documents USING btree (item_type, item_id); + + +-- +-- Name: index_log_legal_documents_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_log_legal_documents_on_whodunnit ON log_legal_documents USING btree (whodunnit); + + -- -- Name: index_log_messages_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4552,13 +4510,6 @@ CREATE INDEX index_registrant_verifications_on_domain_id ON registrant_verificat CREATE INDEX index_registrars_on_code ON registrars USING btree (code); --- --- Name: index_reserved_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_reserved_domains_on_name ON reserved_domains USING btree (name); - - -- -- Name: index_settings_on_thing_type_and_thing_id_and_var; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4996,23 +4947,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150921110152'); INSERT INTO schema_migrations (version) VALUES ('20150921111842'); -INSERT INTO schema_migrations (version) VALUES ('20151028183132'); - INSERT INTO schema_migrations (version) VALUES ('20151029152638'); -INSERT INTO schema_migrations (version) VALUES ('20151112160452'); - -INSERT INTO schema_migrations (version) VALUES ('20151117081204'); - -INSERT INTO schema_migrations (version) VALUES ('20151120090455'); - -INSERT INTO schema_migrations (version) VALUES ('20151124200353'); - -INSERT INTO schema_migrations (version) VALUES ('20151125155601'); - -INSERT INTO schema_migrations (version) VALUES ('20151127091716'); - -INSERT INTO schema_migrations (version) VALUES ('20151130175654'); - -INSERT INTO schema_migrations (version) VALUES ('20151202123506'); - From 0c36b3045acf8357778833d21f4d8635006ae55d Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 5 Jan 2016 16:22:06 +0200 Subject: [PATCH 121/182] 111055076-callback_added --- app/models/invoice.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 2f54e2287..fdcb3cf61 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -19,6 +19,8 @@ class Invoice < ActiveRecord::Base before_create :set_invoice_number, :check_vat + before_save :check_vat + def set_invoice_number last_no = Invoice.order(number: :desc).where('number IS NOT NULL').limit(1).pluck(:number).first From cbe0193cbfb1dbdba5085d8041ac906993be6315 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 5 Jan 2016 17:57:56 +0200 Subject: [PATCH 122/182] 107279984-balance_fix --- app/controllers/admin/account_activities_controller.rb | 8 +++++++- app/views/admin/account_activities/index.haml | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/account_activities_controller.rb b/app/controllers/admin/account_activities_controller.rb index 640acf2e7..bb5b72df8 100644 --- a/app/controllers/admin/account_activities_controller.rb +++ b/app/controllers/admin/account_activities_controller.rb @@ -12,9 +12,15 @@ class Admin::AccountActivitiesController < AdminController logger.warn('Invalid date') end + balance_params = params[:q].deep_dup + + if balance_params[:created_at_gteq] + balance_params.delete('created_at_gteq') + end + @q = AccountActivity.includes(:invoice, account: :registrar).search(params[:q]) @q.sorts = 'id desc' if @q.sorts.empty? - @b = AccountActivity.where.not(id: @q.result.map(&:id)) + @b = AccountActivity.search(balance_params).result.where.not(id: @q.result.map(&:id)) respond_to do |format| format.html { @account_activities = @q.result.page(params[:page]) } diff --git a/app/views/admin/account_activities/index.haml b/app/views/admin/account_activities/index.haml index 6efefb814..4999fd558 100644 --- a/app/views/admin/account_activities/index.haml +++ b/app/views/admin/account_activities/index.haml @@ -62,7 +62,7 @@ %th{class: 'col-xs-2'} = sort_link(@q, 'sum') %tbody - -total = 0 + -total = @b.sum('sum').to_f - @account_activities.each do |x| %tr %td= link_to(x.account.registrar.try(:code), admin_registrar_path(x.account.registrar)) @@ -79,7 +79,7 @@ %td %td %td{class: 'text-right'}= t(:total) - %td{class: 'text-success'}= total > 0 ? "+#{total} EUR" : "#{total} EUR" + %td{class: total > 0 ? 'text-success' : 'text-danger'}= total > 0 ? "+#{total} EUR" : "#{total} EUR" .row .col-md-12 = paginate @account_activities From bb474ec62b7d4ca227fc90ae26676d1103b0d5c9 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 6 Jan 2016 09:17:45 +0200 Subject: [PATCH 123/182] Story#111066886 - Glue IP is required for nameservers with matching domain name endings --- 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 05ffafc4d..a9defdf50 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -544,7 +544,7 @@ class Domain < ActiveRecord::Base def validate_nameserver_ips nameservers.to_a.reject(&:marked_for_destruction?).each do |ns| - next unless ns.hostname.end_with?(name) + next unless ns.hostname.end_with?(".#{name}") next if ns.ipv4.present? errors.add(:nameservers, :invalid) if errors[:nameservers].blank? ns.errors.add(:ipv4, :blank) From 2f10e8d6a48209d33d990c3818ad19ef5aaccadd Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 6 Jan 2016 09:58:51 +0200 Subject: [PATCH 124/182] Story#109590460 - typo --- app/models/epp/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 345f7ecee..f4773f732 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -162,7 +162,7 @@ class Epp::Contact < Contact if ident_frame && ident_attr_valid?(ident_frame) org_priv = %w(org priv).freeze - if ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.in?(ident_frame.attr('type')) + if ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.include?(ident_frame.attr('type')) at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_frame.attr('type')) elsif ident_type == "birthday" && ident !=~ /\d{4}-\d{2}-\d{2}/ && (Date.parse(ident) rescue false) at.merge!(ident: ident_frame.text) From 2d35556f2b8c9c05685cd734ff2b2fc1f931a731 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Tue, 5 Jan 2016 14:53:04 +0200 Subject: [PATCH 125/182] disclose refix --- 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 528f84816..08d1cdf14 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -52,7 +52,7 @@ class WhoisRecord < ActiveRecord::Base h[:registrant] = domain.registrant.name - h[:registrant_email] = domain.registrant.email + h[:email] = domain.registrant.email @disclosed << [:email, domain.registrant.email] h[:registrant_changed] = domain.registrant.updated_at.try(:to_s, :iso8601) From a440169eaff75f6585e1f0b2e664247e75b11f27 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 6 Jan 2016 15:04:02 +0200 Subject: [PATCH 126/182] 11031910-callbacks_for_whois_server --- .../admin/reserved_domains_controller.rb | 2 +- app/models/reserved_domain.rb | 33 +++++++++++++++++++ app/views/for_models/whois_other.erb | 8 +++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 app/views/for_models/whois_other.erb diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb index 622f56eb2..402d33022 100644 --- a/app/controllers/admin/reserved_domains_controller.rb +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -24,7 +24,7 @@ class Admin::ReservedDomainsController < AdminController ReservedDomain.transaction do # removing old ones existing = ReservedDomain.any_of_domains(names.keys).pluck(:id) - ReservedDomain.where.not(id: existing).delete_all + ReservedDomain.where.not(id: existing).destroy_all #updating and adding names.each do |name, psw| diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 057321e56..141fd7263 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -1,6 +1,9 @@ class ReservedDomain < ActiveRecord::Base include Versions # version/reserved_domain_version.rb before_save :fill_empty_passwords + before_save :generate_data + before_destroy :remove_data + class << self def pw_for(domain_name) @@ -25,4 +28,34 @@ class ReservedDomain < ActiveRecord::Base def name= val super SimpleIDN.to_unicode(val) end + + def generate_data + @json = generate_json + @body = generate_body + update_whois_server + end + + def update_whois_server + wr = Whois::Record.find_or_initialize_by(name: name) + wr.body = @body + wr.json = @json + wr.save + end + + def generate_body + template = Rails.root.join("app/views/for_models/whois_other.erb".freeze) + ERB.new(template.read, nil, "-").result(binding) + end + + def generate_json + h = HashWithIndifferentAccess.new + h[:name] = self.name + h[:status] = 'Reserved' + h + end + + def remove_data + Whois::Record.where(name: name).delete_all + end + end diff --git a/app/views/for_models/whois_other.erb b/app/views/for_models/whois_other.erb new file mode 100644 index 000000000..50cf0b2dc --- /dev/null +++ b/app/views/for_models/whois_other.erb @@ -0,0 +1,8 @@ +Estonia .ee Top Level Domain WHOIS server + +Domain: +name: <%= @json['name'] %> +status: <%= @json['status'] %> + +Estonia .ee Top Level Domain WHOIS server +More information at http://internet.ee From c0f9a0105eb32bdc5a86123fe875b064bc2e7144 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 6 Jan 2016 17:30:05 +0200 Subject: [PATCH 127/182] Story#111065230 - send expiration_reminder Mail 2 days after --- app/mailers/domain_mailer.rb | 4 ++-- app/models/domain.rb | 2 +- app/views/admin/settings/index.haml | 1 + config/initializers/initial_settings.rb | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 66533e316..443ac6fa9 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -97,8 +97,8 @@ class DomainMailer < ApplicationMailer def expiration_reminder(domain_id) @domain = Domain.find_by(id: domain_id) - return unless @domain - return if whitelist_blocked?(@domain.registrant.email) + return if @domain.nil? || !@domain.statuses.include?(DomainStatus::EXPIRED) || whitelist_blocked?(@domain.registrant.email) + mail(to: format(@domain.registrant.email), subject: "#{I18n.t(:expiration_remind_subject, name: @domain.name)} [#{@domain.name}]") diff --git a/app/models/domain.rb b/app/models/domain.rb index 05ffafc4d..ca819783b 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -264,7 +264,7 @@ class Domain < ActiveRecord::Base domains.each do |domain| next unless domain.expirable? domain.set_graceful_expired - DomainMailer.expiration_reminder(domain.id).deliver + DomainMailer.expiration_reminder(domain.id).deliver_in(Setting.redemption_grace_period.days) STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? domain.save end diff --git a/app/views/admin/settings/index.haml b/app/views/admin/settings/index.haml index ede30e979..f03ca66bc 100644 --- a/app/views/admin/settings/index.haml +++ b/app/views/admin/settings/index.haml @@ -36,6 +36,7 @@ = render 'setting_row', var: :days_to_renew_domain_before_expire = render 'setting_row', var: :expire_warning_period = render 'setting_row', var: :redemption_grace_period + = render 'setting_row', var: :expiration_reminder_mail .panel.panel-default .panel-heading.clearfix diff --git a/config/initializers/initial_settings.rb b/config/initializers/initial_settings.rb index 812641a09..193d179b0 100644 --- a/config/initializers/initial_settings.rb +++ b/config/initializers/initial_settings.rb @@ -37,6 +37,7 @@ if con.present? && con.table_exists?('settings') Setting.save_default(:days_to_renew_domain_before_expire, 90) Setting.save_default(:expire_warning_period, 15) Setting.save_default(:redemption_grace_period, 30) + Setting.save_default(:expiration_reminder_mail, 2) Setting.save_default(:registrar_ip_whitelist_enabled, true) Setting.save_default(:api_ip_whitelist_enabled, true) From 6b3bfe01d2e8bd6ec8049c1b3e13fbc53c7e0df8 Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 7 Jan 2016 18:06:43 +0200 Subject: [PATCH 128/182] 111068693-date_cfg_change --- 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 893fe5665..91a3361b1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -21,7 +21,7 @@ en: default: "%d. %B %Y, %H:%M" longer: "%a, %e. %b %Y, %H:%M" long: "%A, %e. %B %Y, %H:%M" - short: "%d.%m.%y, %H:%M" + short: "%d.%m.%y" shorts: "%d.%m.%y, %H:%M:%S" date: "%d.%m.%y" date_long: "%d. %B %Y" From 74ee6b3e8c88c7d930ee68f6444f83f60e82536f Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 7 Jan 2016 19:08:49 +0200 Subject: [PATCH 129/182] 111068694-template_changes --- .../mailers/domain_mailer/expiration_reminder.html.erb | 6 +++--- .../mailers/domain_mailer/expiration_reminder.text.erb | 6 +++--- app/views/mailers/domain_mailer/force_delete.html.erb | 6 +++--- app/views/mailers/domain_mailer/force_delete.text.erb | 6 +++--- config/locales/en.yml | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/views/mailers/domain_mailer/expiration_reminder.html.erb b/app/views/mailers/domain_mailer/expiration_reminder.html.erb index 59f02c510..e29ca826e 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.html.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.html.erb @@ -1,7 +1,7 @@ Domeen <%= @domain.name %> on aegunud
Lugupeetud .ee domeeni kasutaja

-Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :short) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :short) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. +Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :date) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :date) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele.

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

@@ -27,7 +27,7 @@ Tel: +372 727 1000
The <%= @domain.name %> domain has expired
Dear user of .ee domain,

-The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :short) %>. From <%= l(@domain.delete_at, format: :short) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. +The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :date) %>. From <%= l(@domain.delete_at, format: :date) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis.

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

@@ -53,7 +53,7 @@ Phone: +372 727 1000
Домен <%= @domain.name %> устарел
Уважаемый пользователь домена .ee

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

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

diff --git a/app/views/mailers/domain_mailer/expiration_reminder.text.erb b/app/views/mailers/domain_mailer/expiration_reminder.text.erb index 988ae5e10..d16682ea5 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.text.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.text.erb @@ -1,7 +1,7 @@ Domeen <%= @domain.name %> on aegunud Lugupeetud .ee domeeni kasutaja -Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :short) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :short) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. +Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :date) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :date) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @domain.registrar.name %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. @@ -27,7 +27,7 @@ Tel: +372 727 1000 The <%= @domain.name %> domain has expired Dear user of .ee domain, -The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :short) %>. From <%= l(@domain.delete_at, format: :short) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. +The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :date) %>. From <%= l(@domain.delete_at, format: :date) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. To renew the domain registration, please contact your registrar <%= @domain.registrar.name %>. You can find the registrar's contacts at http://www.internet.ee/en/registripidajad/. @@ -53,7 +53,7 @@ Phone: +372 727 1000 Домен <%= @domain.name %> устарел Уважаемый пользователь домена .ee -Доменное имя <%= @domain.name %> устарело и с <%= l(@domain.outzone_at, format: :short) %> недоступно в Интернете. С <%= l(@domain.delete_at, format: :short) %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". +Доменное имя <%= @domain.name %> устарело и с <%= l(@domain.outzone_at, format: :date) %> недоступно в Интернете. С <%= l(@domain.delete_at, format: :date) %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". Для продления регистрации домена просим обратиться к своему регистратору <%= @domain.registrar.name %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/. diff --git a/app/views/mailers/domain_mailer/force_delete.html.erb b/app/views/mailers/domain_mailer/force_delete.html.erb index 82bdee156..6f4f4cb27 100644 --- a/app/views/mailers/domain_mailer/force_delete.html.erb +++ b/app/views/mailers/domain_mailer/force_delete.html.erb @@ -20,7 +20,7 @@ Registrikood: <%= @domain.registrant.try(:ident) %>

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

-

Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :short) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist “kes ees, see mees” põhimõttel uuesti registreerida.

+

Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :date) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist “kes ees, see mees” põhimõttel uuesti registreerida.

Lisaküsimuste korral võtke palun ühendust oma registripidajaga <%= @domain.registrar %>, kelle kontaktandmed leiate lingilt http://www.internet.ee/registripidajad



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

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

-

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

+

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

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



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

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

-

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

+

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

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



diff --git a/app/views/mailers/domain_mailer/force_delete.text.erb b/app/views/mailers/domain_mailer/force_delete.text.erb index 527288686..d6369c8cb 100644 --- a/app/views/mailers/domain_mailer/force_delete.text.erb +++ b/app/views/mailers/domain_mailer/force_delete.text.erb @@ -11,7 +11,7 @@ Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registre Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @domain.registrar %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleks esitada Registripidajale esimesel võimalusel. -Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :short) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist "kes ees, see mees" põhimõttel uuesti registreerida. +Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :date) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist "kes ees, see mees" põhimõttel uuesti registreerida. Lisaküsimuste korral võtke palun ühendust oma registripidajaga <%= @domain.registrar %>, kelle kontaktandmed leiate lingilt http://www.internet.ee/registripidajad/ @@ -30,7 +30,7 @@ As a terminated legal person cannot be the registrant of a domain, the EIF start According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @domain.registrar %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible. -If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours after <%= l(@domain.force_delete_at, format: :short) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis. +If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours after <%= l(@domain.force_delete_at, format: :date) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis. Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/registrars/ @@ -49,7 +49,7 @@ EIS стало известно, что юридическое лицо с ре Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @domain.registrar %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления. -Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :short) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел". +Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :date) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел". Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/registratory diff --git a/config/locales/en.yml b/config/locales/en.yml index 91a3361b1..893fe5665 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -21,7 +21,7 @@ en: default: "%d. %B %Y, %H:%M" longer: "%a, %e. %b %Y, %H:%M" long: "%A, %e. %B %Y, %H:%M" - short: "%d.%m.%y" + short: "%d.%m.%y, %H:%M" shorts: "%d.%m.%y, %H:%M:%S" date: "%d.%m.%y" date_long: "%d. %B %Y" From 11d543d9672544e6830de052b132e658b4552dc4 Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 11 Jan 2016 10:12:15 +0200 Subject: [PATCH 130/182] 111297422-blocked_domains --- .../admin/blocked_domains_controller.rb | 37 +- app/models/blocked_domain.rb | 46 +- ...36_name_and_password_for_blocked_domain.rb | 17 + db/schema-read-only.rb | 61 ++- db/structure.sql | 441 ++++++++++++++---- 5 files changed, 465 insertions(+), 137 deletions(-) create mode 100644 db/migrate/20160108135436_name_and_password_for_blocked_domain.rb diff --git a/app/controllers/admin/blocked_domains_controller.rb b/app/controllers/admin/blocked_domains_controller.rb index 2df3f90d9..92e012cf5 100644 --- a/app/controllers/admin/blocked_domains_controller.rb +++ b/app/controllers/admin/blocked_domains_controller.rb @@ -2,20 +2,45 @@ class Admin::BlockedDomainsController < AdminController load_and_authorize_resource def index - bd = BlockedDomain.first_or_initialize - @blocked_domains = bd.names.join("\n") + bd = BlockedDomain.pluck(:name) + if bd + @blocked_domains = bd.to_yaml.gsub("---\n", '').gsub("-", '').gsub(/\.\.\..?\n/, '') + end end def create - names = params[:blocked_domains].split("\r\n").map(&:strip) + @blocked_domains = params[:blocked_domains] - bd = BlockedDomain.first_or_create + begin + params[:blocked_domains] = "---\n" if params[:blocked_domains].blank? + names = YAML.load(params[:blocked_domains]) + fail if names == false + rescue + flash.now[:alert] = I18n.t('invalid_yaml') + logger.warn 'Invalid YAML' + render :index and return + end - if bd.update(names: names) + result = true + BlockedDomain.transaction do + # removing old ones + existing = BlockedDomain.any_of_domains(names).pluck(:id) + BlockedDomain.where.not(id: existing).destroy_all + + #updating and adding + names.each do |name| + rec = BlockedDomain.find_or_initialize_by(name: name) + unless rec.save + result = false + raise ActiveRecord::Rollback + end + end + end + + if result flash[:notice] = I18n.t('record_updated') redirect_to :back else - @blocked_domains = params[:blocked_domains] flash.now[:alert] = I18n.t('failed_to_update_record') render :index end diff --git a/app/models/blocked_domain.rb b/app/models/blocked_domain.rb index 2a646a74f..a25e1ff6a 100644 --- a/app/models/blocked_domain.rb +++ b/app/models/blocked_domain.rb @@ -1,5 +1,49 @@ class BlockedDomain < ActiveRecord::Base include Versions + before_save :generate_data + before_destroy :remove_data - after_initialize -> { self.names = [] if names.nil? } + + class << self + def by_domain name + where(name: name) + end + + def any_of_domains names + where(name: names) + end + end + + def name= val + super SimpleIDN.to_unicode(val) + end + + def generate_data + @json = generate_json + @body = generate_body + update_whois_server + end + + def update_whois_server + wr = Whois::Record.find_or_initialize_by(name: name) + wr.body = @body + wr.json = @json + wr.save + end + + def generate_body + template = Rails.root.join("app/views/for_models/whois_other.erb".freeze) + ERB.new(template.read, nil, "-").result(binding) + end + + def generate_json + h = HashWithIndifferentAccess.new + h[:name] = self.name + h[:status] = 'Blocked' + h + end + + def remove_data + Whois::Record.where(name: name).delete_all + end end diff --git a/db/migrate/20160108135436_name_and_password_for_blocked_domain.rb b/db/migrate/20160108135436_name_and_password_for_blocked_domain.rb new file mode 100644 index 000000000..1935043b2 --- /dev/null +++ b/db/migrate/20160108135436_name_and_password_for_blocked_domain.rb @@ -0,0 +1,17 @@ +class NameAndPasswordForBlockedDomain < ActiveRecord::Migration + def up + add_column :blocked_domains, :name, :string + add_index :blocked_domains, :name + + BlockedDomain.find_each do |x, domain| + names = domain.names + domain.update_columns(name: names[x]) + end + + remove_column :blocked_domains, :names + end + + def down + + end +end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index b362619b0..78722223a 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20151029152638) do +ActiveRecord::Schema.define(version: 20160108135436) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -135,13 +135,15 @@ ActiveRecord::Schema.define(version: 20151029152638) do end create_table "blocked_domains", force: :cascade do |t| - t.string "names", array: true t.datetime "created_at" t.datetime "updated_at" t.string "creator_str" t.string "updator_str" + t.string "name" end + add_index "blocked_domains", ["name"], name: "index_blocked_domains_on_name", using: :btree + create_table "cached_nameservers", id: false, force: :cascade do |t| t.string "hostname", limit: 255 t.string "ipv4", limit: 255 @@ -240,19 +242,20 @@ ActiveRecord::Schema.define(version: 20151029152638) do end create_table "dnskeys", force: :cascade do |t| - t.integer "domain_id" - t.integer "flags" - t.integer "protocol" - t.integer "alg" - t.text "public_key" - t.integer "delegation_signer_id" - t.string "ds_key_tag" - t.integer "ds_alg" - t.integer "ds_digest_type" - t.string "ds_digest" - t.string "creator_str" - t.string "updator_str" - t.integer "legacy_domain_id" + t.integer "domain_id" + t.integer "flags" + t.integer "protocol" + t.integer "alg" + t.text "public_key" + t.integer "delegation_signer_id" + t.string "ds_key_tag" + t.integer "ds_alg" + t.integer "ds_digest_type" + t.string "ds_digest" + t.string "creator_str" + t.string "updator_str" + t.integer "legacy_domain_id" + t.datetime "updated_at" end add_index "dnskeys", ["delegation_signer_id"], name: "index_dnskeys_on_delegation_signer_id", using: :btree @@ -336,6 +339,7 @@ ActiveRecord::Schema.define(version: 20151029152638) do end add_index "domains", ["delete_at"], name: "index_domains_on_delete_at", using: :btree + add_index "domains", ["name"], name: "index_domains_on_name", unique: true, using: :btree add_index "domains", ["outzone_at"], name: "index_domains_on_outzone_at", using: :btree add_index "domains", ["registrant_id"], name: "index_domains_on_registrant_id", using: :btree add_index "domains", ["registrant_verification_asked_at"], name: "index_domains_on_registrant_verification_asked_at", using: :btree @@ -442,9 +446,7 @@ ActiveRecord::Schema.define(version: 20151029152638) do t.integer "documentable_id" t.string "documentable_type" t.datetime "created_at" - t.datetime "updated_at" t.string "creator_str" - t.string "updator_str" t.string "path" end @@ -739,21 +741,6 @@ ActiveRecord::Schema.define(version: 20151029152638) do add_index "log_keyrelays", ["item_type", "item_id"], name: "index_log_keyrelays_on_item_type_and_item_id", using: :btree add_index "log_keyrelays", ["whodunnit"], name: "index_log_keyrelays_on_whodunnit", using: :btree - create_table "log_legal_documents", force: :cascade do |t| - t.string "item_type", null: false - t.integer "item_id", null: false - t.string "event", null: false - t.string "whodunnit" - t.json "object" - t.json "object_changes" - t.datetime "created_at" - t.string "session" - t.json "children" - end - - add_index "log_legal_documents", ["item_type", "item_id"], name: "index_log_legal_documents_on_item_type_and_item_id", using: :btree - add_index "log_legal_documents", ["whodunnit"], name: "index_log_legal_documents_on_whodunnit", using: :btree - create_table "log_messages", force: :cascade do |t| t.string "item_type", null: false t.integer "item_id", null: false @@ -910,10 +897,10 @@ ActiveRecord::Schema.define(version: 20151029152638) do create_table "nameservers", force: :cascade do |t| t.string "hostname" - t.string "ipv4" + t.string "ipv4", default: [], array: true t.datetime "created_at" t.datetime "updated_at" - t.string "ipv6" + t.string "ipv6", default: [], array: true t.integer "domain_id" t.string "creator_str" t.string "updator_str" @@ -1011,9 +998,13 @@ ActiveRecord::Schema.define(version: 20151029152638) do t.datetime "updated_at" t.string "creator_str" t.string "updator_str" - t.hstore "names" + t.integer "legacy_id" + t.string "name" + t.string "password" end + add_index "reserved_domains", ["name"], name: "index_reserved_domains_on_name", using: :btree + create_table "settings", force: :cascade do |t| t.string "var", null: false t.text "value" diff --git a/db/structure.sql b/db/structure.sql index b2480a04e..cf413eff1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -39,6 +39,242 @@ COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs SET search_path = public, pg_catalog; +-- +-- Name: change_ident_country(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION change_ident_country() RETURNS boolean + LANGUAGE plpgsql + AS $_$ +DECLARE + changed BOOLEAN; + multiplier INT []; + multiplier2 INT []; + multiplier3 INT []; + multiplier4 INT []; + r RECORD; + control TEXT; + total INT; + i INT; + mod INT; + counter INT; +BEGIN + + multiplier := ARRAY [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]; + + multiplier2 := ARRAY [3, 4, 5, 6, 7, 8, 9, 1, 2, 3]; + + multiplier3 := ARRAY [1, 2, 3, 4, 5, 6, 7]; + + multiplier4 := ARRAY [3, 4, 5, 6, 7, 8, 9]; + + FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'priv' /*AND ident_country_code IS NULL*/ + LOOP + IF (length(r.ident) = 11 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '3' OR substring(r.ident, 1, 1) = '4' OR substring(r.ident, 1, 1) = '5' OR substring(r.ident, 1, 1) = '6')) + THEN + total := 0; + counter := 1; + FOREACH i IN ARRAY multiplier + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + counter := 1; + + IF (mod >= 10) + THEN + total = 0; + FOREACH i IN ARRAY multiplier2 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + END IF; + + IF (mod < 10 AND substring(r.ident, 11, 1) = to_char(mod, 'FM999MI')) + THEN + UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; + END IF; + total = 0; + END IF; + END LOOP; + + FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'org' + LOOP + IF (length(r.ident) = 8 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '1' OR substring(r.ident, 1, 1) = '8' OR substring(r.ident, 1, 1) = '9')) + THEN + total := 0; + counter := 1; + FOREACH i IN ARRAY multiplier3 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := total % 11; + total = 0; + counter := 1; + + IF (mod >= 10) + THEN + total = 0; + FOREACH i IN ARRAY multiplier4 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + END IF; + + IF (mod < 10 AND (substring(r.ident, 8, 1) = to_char(mod, 'FM999MI'))) + THEN + UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; + END IF; + END IF; + END LOOP; + + + + RETURN changed; +END; +$_$; + + +-- +-- Name: change_ident_country(integer, text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION change_ident_country(id integer, type text) RETURNS boolean + LANGUAGE plpgsql + AS $_$ +DECLARE + changed BOOLEAN; + multiplier int[]; + multiplier2 int[]; + code int; +BEGIN + + multiplier := ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 1]; + + multiplier2 := ARRAY[3, 4, 5, 6, 7, 8, 9, 1, 2, 3]; + + code := (SELECT code FROM contacts WHERE id = 208 AND ident_country_code = 'EE'); + + + + UPDATE contacts + SET ident = '' + WHERE id = $1 and ident_type = $2 AND ident_country_code = 'EE' + AND ident = ''; + + RETURN changed; +END; +$_$; + + +-- +-- Name: fill_ident_country(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION fill_ident_country() RETURNS boolean + LANGUAGE plpgsql + AS $_$ + DECLARE + changed BOOLEAN; + multiplier INT []; + multiplier2 INT []; + multiplier3 INT []; + multiplier4 INT []; + r RECORD; + control TEXT; + total INT; + i INT; + mod INT; + counter INT; + BEGIN + + multiplier := ARRAY [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]; + multiplier2 := ARRAY [3, 4, 5, 6, 7, 8, 9, 1, 2, 3]; + multiplier3 := ARRAY [1, 2, 3, 4, 5, 6, 7]; + multiplier4 := ARRAY [3, 4, 5, 6, 7, 8, 9]; + + FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'priv' AND ident_country_code IS NULL + LOOP + IF (length(r.ident) = 11 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '3' OR substring(r.ident, 1, 1) = '4' OR substring(r.ident, 1, 1) = '5' OR substring(r.ident, 1, 1) = '6')) + THEN + total := 0; + counter := 1; + FOREACH i IN ARRAY multiplier + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + counter := 1; + IF (mod >= 10) + THEN + total = 0; + FOREACH i IN ARRAY multiplier2 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + END IF; + + IF (mod = 10) + THEN + mod := 0; + END IF; + + IF (substring(r.ident, 11, 1) = to_char(mod, 'FM999MI')) + THEN + UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; + END IF; + total := 0; + END IF; + END LOOP; + + FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'org' AND ident_country_code IS NULL + LOOP + IF (length(r.ident) = 8 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '1' OR substring(r.ident, 1, 1) = '8' OR substring(r.ident, 1, 1) = '9')) + THEN + total := 0; + counter := 1; + FOREACH i IN ARRAY multiplier3 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := total % 11; + total := 0; + counter := 1; + IF (mod >= 10) + THEN + total = 0; + FOREACH i IN ARRAY multiplier4 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + END IF; + IF (mod = 10) + THEN + mod := 0; + END IF; + IF (substring(r.ident, 8, 1) = to_char(mod, 'FM999MI')) + THEN + UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; + END IF; + END IF; + END LOOP; + RETURN changed; + END; + $_$; + + -- -- Name: generate_zonefile(character varying); Type: FUNCTION; Schema: public; Owner: - -- @@ -55,7 +291,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text ret text; BEGIN -- define filters - include_filter = '%.' || i_origin; + include_filter = '%' || i_origin; -- for %.%.% IF i_origin ~ '\.' THEN @@ -82,10 +318,6 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text ret = concat(tmp_var, chr(10), chr(10)); - -- origin ns records - SELECT ns_records FROM zonefile_settings zf WHERE i_origin = zf.origin INTO tmp_var; - ret := concat(ret, '; Zone NS Records', chr(10), tmp_var, chr(10)); - -- ns records SELECT array_to_string( array( @@ -93,17 +325,26 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text FROM domains d JOIN nameservers ns ON ns.domain_id = d.id WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter - AND NOT ('{serverHold,clientHold}' && d.statuses) ORDER BY d.name ), chr(10) ) INTO tmp_var; - ret := concat(ret, tmp_var, chr(10), chr(10)); + ret := concat(ret, '; Zone NS Records', chr(10), tmp_var, chr(10), chr(10)); - -- origin a glue records - SELECT a_records FROM zonefile_settings zf WHERE i_origin = zf.origin INTO tmp_var; - ret := concat(ret, '; Zone A Records', chr(10), tmp_var, chr(10)); + -- a glue records for origin nameservers + SELECT array_to_string( + array( + SELECT concat(ns.hostname, '. IN A ', ns.ipv4) + FROM nameservers ns + JOIN domains d ON d.id = ns.domain_id + WHERE d.name = i_origin + AND ns.hostname LIKE '%.' || d.name + AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '' + ), chr(10) + ) INTO tmp_var; + + ret := concat(ret, '; Zone A Records', chr(10), tmp_var); -- a glue records for other nameservers SELECT array_to_string( @@ -115,15 +356,43 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text AND ns.hostname LIKE '%.' || d.name AND d.name <> i_origin AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '' - AND NOT ('{serverHold,clientHold}' && d.statuses) + AND NOT EXISTS ( -- filter out glue records that already appeared in origin glue recrods + SELECT 1 FROM nameservers nsi + JOIN domains di ON nsi.domain_id = di.id + WHERE di.name = i_origin + AND nsi.hostname = ns.hostname + ) ), chr(10) ) INTO tmp_var; - ret := concat(ret, tmp_var, chr(10), chr(10)); + -- TODO This is a possible subtitition to the previous query, stress testing is needed to see which is faster - -- origin aaaa glue records - SELECT a4_records FROM zonefile_settings zf WHERE i_origin = zf.origin INTO tmp_var; - ret := concat(ret, '; Zone AAAA Records', chr(10), tmp_var, chr(10)); + -- SELECT ns.* + -- FROM nameservers ns + -- JOIN domains d ON d.id = ns.domain_id + -- WHERE d.name LIKE '%ee' AND d.name NOT LIKE '%pri.ee' + -- AND ns.hostname LIKE '%.' || d.name + -- AND d.name <> 'ee' + -- AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '' + -- AND ns.hostname NOT IN ( + -- SELECT ns.hostname FROM domains d JOIN nameservers ns ON d.id = ns.domain_id WHERE d.name = 'ee' + -- ) + + ret := concat(ret, chr(10), tmp_var, chr(10), chr(10)); + + -- aaaa glue records for origin nameservers + SELECT array_to_string( + array( + SELECT concat(ns.hostname, '. IN AAAA ', ns.ipv6) + FROM nameservers ns + JOIN domains d ON d.id = ns.domain_id + WHERE d.name = i_origin + AND ns.hostname LIKE '%.' || d.name + AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '' + ), chr(10) + ) INTO tmp_var; + + ret := concat(ret, '; Zone AAAA Records', chr(10), tmp_var); -- aaaa glue records for other nameservers SELECT array_to_string( @@ -135,23 +404,27 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text AND ns.hostname LIKE '%.' || d.name AND d.name <> i_origin AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '' - AND NOT ('{serverHold,clientHold}' && d.statuses) + AND NOT EXISTS ( -- filter out glue records that already appeared in origin glue recrods + SELECT 1 FROM nameservers nsi + JOIN domains di ON nsi.domain_id = di.id + WHERE di.name = i_origin + AND nsi.hostname = ns.hostname + ) ), chr(10) ) INTO tmp_var; - ret := concat(ret, tmp_var, chr(10), chr(10)); + ret := concat(ret, chr(10), tmp_var, chr(10), chr(10)); -- ds records SELECT array_to_string( array( SELECT concat( - d.name_puny, '. IN DS ', dk.ds_key_tag, ' ', - dk.ds_alg, ' ', dk.ds_digest_type, ' ( ', dk.ds_digest, ' )' + d.name_puny, '. 3600 IN DS ', dk.ds_key_tag, ' ', + dk.ds_alg, ' ', dk.ds_digest_type, ' ', dk.ds_digest ) FROM domains d JOIN dnskeys dk ON dk.domain_id = d.id - WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter AND dk.flags = 257 - AND NOT ('{serverHold,clientHold}' && d.statuses) + WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter ), chr(10) ) INTO tmp_var; @@ -457,11 +730,11 @@ ALTER SEQUENCE banklink_transactions_id_seq OWNED BY banklink_transactions.id; CREATE TABLE blocked_domains ( id integer NOT NULL, - names character varying[], created_at timestamp without time zone, updated_at timestamp without time zone, creator_str character varying, - updator_str character varying + updator_str character varying, + name character varying ); @@ -745,7 +1018,8 @@ CREATE TABLE dnskeys ( ds_digest character varying, creator_str character varying, updator_str character varying, - legacy_domain_id integer + legacy_domain_id integer, + updated_at timestamp without time zone ); @@ -1130,9 +1404,7 @@ CREATE TABLE legal_documents ( documentable_id integer, documentable_type character varying, created_at timestamp without time zone, - updated_at timestamp without time zone, creator_str character varying, - updator_str character varying, path character varying ); @@ -1863,43 +2135,6 @@ CREATE SEQUENCE log_keyrelays_id_seq ALTER SEQUENCE log_keyrelays_id_seq OWNED BY log_keyrelays.id; --- --- Name: log_legal_documents; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE log_legal_documents ( - id integer NOT NULL, - item_type character varying NOT NULL, - item_id integer NOT NULL, - event character varying NOT NULL, - whodunnit character varying, - object json, - object_changes json, - created_at timestamp without time zone, - session character varying, - children json -); - - --- --- Name: log_legal_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE log_legal_documents_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: log_legal_documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE log_legal_documents_id_seq OWNED BY log_legal_documents.id; - - -- -- Name: log_messages; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -2313,10 +2548,10 @@ ALTER SEQUENCE messages_id_seq OWNED BY messages.id; CREATE TABLE nameservers ( id integer NOT NULL, hostname character varying, - ipv4 character varying, + ipv4 character varying[] DEFAULT '{}'::character varying[], created_at timestamp without time zone, updated_at timestamp without time zone, - ipv6 character varying, + ipv6 character varying[] DEFAULT '{}'::character varying[], domain_id integer, creator_str character varying, updator_str character varying, @@ -2560,7 +2795,9 @@ CREATE TABLE reserved_domains ( updated_at timestamp without time zone, creator_str character varying, updator_str character varying, - names hstore + legacy_id integer, + name character varying, + password character varying ); @@ -3126,13 +3363,6 @@ ALTER TABLE ONLY log_invoices ALTER COLUMN id SET DEFAULT nextval('log_invoices_ ALTER TABLE ONLY log_keyrelays ALTER COLUMN id SET DEFAULT nextval('log_keyrelays_id_seq'::regclass); --- --- Name: id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY log_legal_documents ALTER COLUMN id SET DEFAULT nextval('log_legal_documents_id_seq'::regclass); - - -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3645,14 +3875,6 @@ ALTER TABLE ONLY log_keyrelays ADD CONSTRAINT log_keyrelays_pkey PRIMARY KEY (id); --- --- Name: log_legal_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: --- - -ALTER TABLE ONLY log_legal_documents - ADD CONSTRAINT log_legal_documents_pkey PRIMARY KEY (id); - - -- -- Name: log_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -3880,6 +4102,13 @@ CREATE INDEX index_accounts_on_registrar_id ON accounts USING btree (registrar_i CREATE INDEX index_api_users_on_registrar_id ON api_users USING btree (registrar_id); +-- +-- Name: index_blocked_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_blocked_domains_on_name ON blocked_domains USING btree (name); + + -- -- Name: index_cached_nameservers_on_hostname_and_ipv4_and_ipv6; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -3985,6 +4214,13 @@ CREATE INDEX index_domain_transfers_on_domain_id ON domain_transfers USING btree CREATE INDEX index_domains_on_delete_at ON domains USING btree (delete_at); +-- +-- Name: index_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE UNIQUE INDEX index_domains_on_name ON domains USING btree (name); + + -- -- Name: index_domains_on_outzone_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4349,20 +4585,6 @@ CREATE INDEX index_log_keyrelays_on_item_type_and_item_id ON log_keyrelays USING CREATE INDEX index_log_keyrelays_on_whodunnit ON log_keyrelays USING btree (whodunnit); --- --- Name: index_log_legal_documents_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_legal_documents_on_item_type_and_item_id ON log_legal_documents USING btree (item_type, item_id); - - --- --- Name: index_log_legal_documents_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_legal_documents_on_whodunnit ON log_legal_documents USING btree (whodunnit); - - -- -- Name: index_log_messages_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4510,6 +4732,13 @@ CREATE INDEX index_registrant_verifications_on_domain_id ON registrant_verificat CREATE INDEX index_registrars_on_code ON registrars USING btree (code); +-- +-- Name: index_reserved_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_reserved_domains_on_name ON reserved_domains USING btree (name); + + -- -- Name: index_settings_on_thing_type_and_thing_id_and_var; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4947,5 +5176,27 @@ INSERT INTO schema_migrations (version) VALUES ('20150921110152'); INSERT INTO schema_migrations (version) VALUES ('20150921111842'); +INSERT INTO schema_migrations (version) VALUES ('20151028183132'); + INSERT INTO schema_migrations (version) VALUES ('20151029152638'); +INSERT INTO schema_migrations (version) VALUES ('20151112160452'); + +INSERT INTO schema_migrations (version) VALUES ('20151117081204'); + +INSERT INTO schema_migrations (version) VALUES ('20151120090455'); + +INSERT INTO schema_migrations (version) VALUES ('20151124200353'); + +INSERT INTO schema_migrations (version) VALUES ('20151125155601'); + +INSERT INTO schema_migrations (version) VALUES ('20151127091716'); + +INSERT INTO schema_migrations (version) VALUES ('20151130175654'); + +INSERT INTO schema_migrations (version) VALUES ('20151202123506'); + +INSERT INTO schema_migrations (version) VALUES ('20160106092052'); + +INSERT INTO schema_migrations (version) VALUES ('20160108135436'); + From 4a0b1fea39368bb1859550eef64e3a1622582f6c Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 11 Jan 2016 11:03:31 +0200 Subject: [PATCH 131/182] 111297422-mask_fix --- app/controllers/admin/blocked_domains_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/blocked_domains_controller.rb b/app/controllers/admin/blocked_domains_controller.rb index 92e012cf5..9394a9334 100644 --- a/app/controllers/admin/blocked_domains_controller.rb +++ b/app/controllers/admin/blocked_domains_controller.rb @@ -4,7 +4,7 @@ class Admin::BlockedDomainsController < AdminController def index bd = BlockedDomain.pluck(:name) if bd - @blocked_domains = bd.to_yaml.gsub("---\n", '').gsub("-", '').gsub(/\.\.\..?\n/, '') + @blocked_domains = bd.to_yaml.gsub("---\n", '').gsub("-", '').gsub(" ", '') end end @@ -21,13 +21,12 @@ class Admin::BlockedDomainsController < AdminController render :index and return end + names = names.split(' ') result = true BlockedDomain.transaction do - # removing old ones existing = BlockedDomain.any_of_domains(names).pluck(:id) BlockedDomain.where.not(id: existing).destroy_all - #updating and adding names.each do |name| rec = BlockedDomain.find_or_initialize_by(name: name) unless rec.save From 1370a5f0feee1c265e9b6a59a27962b1347ee2e1 Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 11 Jan 2016 11:05:01 +0200 Subject: [PATCH 132/182] 111297422-migration_fix --- .../20160108135436_name_and_password_for_blocked_domain.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/db/migrate/20160108135436_name_and_password_for_blocked_domain.rb b/db/migrate/20160108135436_name_and_password_for_blocked_domain.rb index 1935043b2..efd46ac88 100644 --- a/db/migrate/20160108135436_name_and_password_for_blocked_domain.rb +++ b/db/migrate/20160108135436_name_and_password_for_blocked_domain.rb @@ -2,12 +2,6 @@ class NameAndPasswordForBlockedDomain < ActiveRecord::Migration def up add_column :blocked_domains, :name, :string add_index :blocked_domains, :name - - BlockedDomain.find_each do |x, domain| - names = domain.names - domain.update_columns(name: names[x]) - end - remove_column :blocked_domains, :names end From b047ce27ca5cb799a2b2efa22c65cdd0a21df2a8 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 11 Jan 2016 12:40:44 +0200 Subject: [PATCH 133/182] Story#111065230 - set whitelist check --- app/mailers/domain_mailer.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 443ac6fa9..28e232a8c 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -98,6 +98,7 @@ class DomainMailer < ApplicationMailer def expiration_reminder(domain_id) @domain = Domain.find_by(id: domain_id) return if @domain.nil? || !@domain.statuses.include?(DomainStatus::EXPIRED) || whitelist_blocked?(@domain.registrant.email) + return if whitelist_blocked?(@domain.registrant.email) mail(to: format(@domain.registrant.email), subject: "#{I18n.t(:expiration_remind_subject, From a807aba1f4f3f1bc032e049dc598549e365f99ff Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 11 Jan 2016 12:44:32 +0200 Subject: [PATCH 134/182] Story#111065230 - fix typo --- app/models/domain.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index ca819783b..8dace41a9 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -264,7 +264,7 @@ class Domain < ActiveRecord::Base domains.each do |domain| next unless domain.expirable? domain.set_graceful_expired - DomainMailer.expiration_reminder(domain.id).deliver_in(Setting.redemption_grace_period.days) + DomainMailer.expiration_reminder(domain.id).deliver_in(Setting.expiration_reminder_mail.days) STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? domain.save end From 96552a03440cd080eb4a570007a55d57a954505b Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 11 Jan 2016 15:44:26 +0200 Subject: [PATCH 135/182] 107279984-filter_changes --- .../admin/account_activities_controller.rb | 44 ++++++++++++++++++- app/views/admin/account_activities/index.haml | 10 +++-- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/account_activities_controller.rb b/app/controllers/admin/account_activities_controller.rb index bb5b72df8..1419dbea9 100644 --- a/app/controllers/admin/account_activities_controller.rb +++ b/app/controllers/admin/account_activities_controller.rb @@ -19,11 +19,51 @@ class Admin::AccountActivitiesController < AdminController end @q = AccountActivity.includes(:invoice, account: :registrar).search(params[:q]) + @b = AccountActivity.search(balance_params) @q.sorts = 'id desc' if @q.sorts.empty? - @b = AccountActivity.search(balance_params).result.where.not(id: @q.result.map(&:id)) + + + + @account_activities = @q.result.page(params[:page]).per(params[:results_per_page]) + sort = @account_activities.orders.map(&:to_sql).join(",") + + + if params[:page] && params[:page].to_i > 1 + + + @sum = @q.result.reorder(sort).limit(@account_activities.offset_value) + @b.result.where.not(id: @q.result.map(&:id)) + + else + + @sum = @b.result.where.not(id: @q.result.map(&:id)) + + + end + + + + + + + # throw "cdsfs" + + # if params[:page] && params[:page].to_i > 1 + # + # @b = @q.result.page(params[:page].to_i - 1) + # + # @b = @b.per(params[:results_per_page]) + # + # + # else + # + # @b = AccountActivity.search(balance_params) + # + # @b = @b.result.where.not(id: @q.result.map(&:id)) + # + # end respond_to do |format| - format.html { @account_activities = @q.result.page(params[:page]) } + format.html format.csv do send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv" end diff --git a/app/views/admin/account_activities/index.haml b/app/views/admin/account_activities/index.haml index 4999fd558..80ebba2f6 100644 --- a/app/views/admin/account_activities/index.haml +++ b/app/views/admin/account_activities/index.haml @@ -29,7 +29,11 @@ .form-group = f.label t(:receipt_date_until) = f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control datepicker', placeholder: t(:receipt_date_until), autocomplete: 'off' - .col-md-6{style: 'padding-top: 25px;'} + .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-default.search   %span.glyphicon.glyphicon-search @@ -41,7 +45,7 @@ .col-md-3 .col-md-2 .col-md-4{class: 'text-right'} - = t(:starting_balance) + " #{@b.sum('sum').to_f} EUR" + = t(:starting_balance) + " #{@sum.to_a.map(&:sum).sum.to_f} EUR" %hr @@ -62,7 +66,7 @@ %th{class: 'col-xs-2'} = sort_link(@q, 'sum') %tbody - -total = @b.sum('sum').to_f + -total = @sum.to_a.map(&:sum).sum.to_f - @account_activities.each do |x| %tr %td= link_to(x.account.registrar.try(:code), admin_registrar_path(x.account.registrar)) From 830afc0e0edf5dd2f347f34429aebe85edf488ab Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 11 Jan 2016 16:26:54 +0200 Subject: [PATCH 136/182] 111297422-validation_method_fix --- app/validators/domain_name_validator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb index e39437f2b..be83f0835 100644 --- a/app/validators/domain_name_validator.rb +++ b/app/validators/domain_name_validator.rb @@ -38,7 +38,7 @@ class DomainNameValidator < ActiveModel::EachValidator def validate_blocked(value) return true unless value - return false if BlockedDomain.where("names @> ?::varchar[]", "{#{value}}").count > 0 + return false if BlockedDomain.where(name: value).count > 0 ZonefileSetting.where(origin: value).count == 0 end end From c4ead607da38e05f7c17a7bf420fff65fc0b38cd Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 11 Jan 2016 17:02:35 +0200 Subject: [PATCH 137/182] 107279984-refactor --- .../admin/account_activities_controller.rb | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/app/controllers/admin/account_activities_controller.rb b/app/controllers/admin/account_activities_controller.rb index 1419dbea9..0f095734f 100644 --- a/app/controllers/admin/account_activities_controller.rb +++ b/app/controllers/admin/account_activities_controller.rb @@ -22,46 +22,15 @@ class Admin::AccountActivitiesController < AdminController @b = AccountActivity.search(balance_params) @q.sorts = 'id desc' if @q.sorts.empty? - - @account_activities = @q.result.page(params[:page]).per(params[:results_per_page]) sort = @account_activities.orders.map(&:to_sql).join(",") - if params[:page] && params[:page].to_i > 1 - - @sum = @q.result.reorder(sort).limit(@account_activities.offset_value) + @b.result.where.not(id: @q.result.map(&:id)) - else - @sum = @b.result.where.not(id: @q.result.map(&:id)) - - end - - - - - - # throw "cdsfs" - - # if params[:page] && params[:page].to_i > 1 - # - # @b = @q.result.page(params[:page].to_i - 1) - # - # @b = @b.per(params[:results_per_page]) - # - # - # else - # - # @b = AccountActivity.search(balance_params) - # - # @b = @b.result.where.not(id: @q.result.map(&:id)) - # - # end - respond_to do |format| format.html format.csv do From b28748d667c76ef73e69ae69f2a303d4c195a49d Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 12 Jan 2016 14:06:32 +0200 Subject: [PATCH 138/182] Story#111503520 - couldn't apply pending update as registrar wasn't valid --- app/jobs/domain_update_confirm_job.rb | 7 ++----- app/models/epp/domain.rb | 13 ++++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index be0ada219..3da95287d 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -3,19 +3,16 @@ class DomainUpdateConfirmJob < Que::Job # it's recommended to keep transaction against job table as short as possible. ActiveRecord::Base.transaction do domain = Epp::Domain.find(domain_id) + domain.is_admin = true 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.apply_pending_update! domain.clean_pendings! - 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) 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 diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index d84de4ca6..15e16163a 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -507,18 +507,17 @@ class Epp::Domain < Domain 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 - + self.statuses.delete(DomainStatus::PENDING_UPDATE) ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user + + send_mail :registrant_updated_notification_for_old_registrant return unless update(frame, user, false) clean_pendings! send_mail :registrant_updated_notification_for_new_registrant - update_whois_record + WhoisRecord.find_by(domain_id: id).save # need to reload model + + save! # for notification if everything fails true end From cb6601ce1dc688a61a4d69b448b9242828842ee3 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 12 Jan 2016 14:10:34 +0200 Subject: [PATCH 139/182] Story#111396470 - show special message on contact ident update --- app/models/contact.rb | 5 +++-- app/models/epp/contact.rb | 1 + config/locales/en.yml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index ccc44851d..573ffe22e 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -238,13 +238,14 @@ class Contact < ActiveRecord::Base def ident_valid_format? case ident_country_code when 'EE'.freeze + err_msg = "invalid_EE_identity_format#{"__update" if id}".to_sym case ident_type when 'priv'.freeze - errors.add(:ident, :invalid_EE_identity_format) unless Isikukood.new(ident).valid? + errors.add(:ident, err_msg) unless Isikukood.new(ident).valid? when 'org'.freeze # !%w(1 7 8 9).freeze.include?(ident.first) || if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/) - errors.add(:ident, :invalid_EE_identity_format) + errors.add(:ident, err_msg) end end end diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index f4773f732..5f0a7b209 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -123,6 +123,7 @@ class Epp::Contact < Contact [:email, :invalid], [:ident, :invalid], [:ident, :invalid_EE_identity_format], + [:ident, :invalid_EE_identity_format_update], [:ident, :invalid_birthday_format], [:ident, :invalid_country_code], [:ident_type, :missing], diff --git a/config/locales/en.yml b/config/locales/en.yml index 893fe5665..61a476ab6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -49,6 +49,7 @@ en: ident: blank: "Required parameter missing - ident" invalid_EE_identity_format: "Ident not in valid Estonian identity format." + invalid_EE_identity_format_update: "Ident not in valid Estonian identity format. Please create new contact" invalid_birthday_format: "Ident not in valid birthady format, should be YYYY-MM-DD" invalid_country_code: "Ident country code is not valid, should be in ISO_3166-1 alpha 2 format" domains: From a20df5243a921a1bc762e02eb4d86d1651addf52 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 12 Jan 2016 14:24:32 +0200 Subject: [PATCH 140/182] Story#111396470 - show special message on contact ident update (typo fix) --- 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 573ffe22e..75f03de09 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -238,7 +238,7 @@ class Contact < ActiveRecord::Base def ident_valid_format? case ident_country_code when 'EE'.freeze - err_msg = "invalid_EE_identity_format#{"__update" if id}".to_sym + err_msg = "invalid_EE_identity_format#{"_update" if id}".to_sym case ident_type when 'priv'.freeze errors.add(:ident, err_msg) unless Isikukood.new(ident).valid? From e27cd0c31676675858fd4cd6f455ce99486e2a33 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 12 Jan 2016 17:11:31 +0200 Subject: [PATCH 141/182] Story#111396470 - better code --- app/models/contact.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 75f03de09..99a41a6a4 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -29,7 +29,7 @@ class Contact < ActiveRecord::Base uniqueness: { message: :epp_id_taken }, format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid }, length: { maximum: 100, message: :too_long_contact_code } - validate :ident_valid_format? + validate :val_ident_valid_format? validate :uniq_statuses? validate :validate_html @@ -235,7 +235,7 @@ class Contact < ActiveRecord::Base name || '[no name]' end - def ident_valid_format? + def val_ident_valid_format? case ident_country_code when 'EE'.freeze err_msg = "invalid_EE_identity_format#{"_update" if id}".to_sym From 782fcc9deccb5d389e23c4f67a98e58b8fbe0c84 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 12 Jan 2016 17:29:13 +0200 Subject: [PATCH 142/182] Story#111503520 - reject verification shouldn't validate --- 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 3da95287d..f028b95f8 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -13,7 +13,7 @@ class DomainUpdateConfirmJob < Que::Job domain.send_mail :pending_update_rejected_notification_for_new_registrant domain.poll_message!(:poll_pending_update_rejected_by_registrant) domain.clean_pendings! - domain.save + domain.save(validate: false) end destroy # it's best to destroy the job in the same transaction end From d9d8aef813fdc99a529086da899a430d6af4e202 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 12 Jan 2016 18:27:29 +0200 Subject: [PATCH 143/182] Story#111503520 - custom lowlevel pending state rejection --- app/jobs/domain_update_confirm_job.rb | 3 +-- app/models/domain.rb | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index f028b95f8..098b9853e 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -12,8 +12,7 @@ class DomainUpdateConfirmJob < Que::Job 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.save(validate: false) + domain.clean_pendings_lowlevel end destroy # it's best to destroy the job in the same transaction end diff --git a/app/models/domain.rb b/app/models/domain.rb index 05ffafc4d..baf7d0308 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -244,7 +244,7 @@ class Domain < ActiveRecord::Base if domain.pending_delete? || domain.pending_delete_confirmation? DomainMailer.pending_delete_expired_notification(domain.id, true).deliver end - domain.clean_pendings! + domain.clean_pendings_lowlevel unless Rails.env.test? STDOUT << "#{Time.zone.now.utc} Domain.clean_expired_pendings: ##{domain.id} (#{domain.name})\n" end @@ -439,6 +439,25 @@ class Domain < ActiveRecord::Base save end + + # state change shouln't be + def clean_pendings_lowlevel + statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) + statuses.delete(DomainStatus::PENDING_UPDATE) + statuses.delete(DomainStatus::PENDING_DELETE) + + status_notes[DomainStatus::PENDING_UPDATE] = '' + status_notes[DomainStatus::PENDING_DELETE] = '' + + update_columns( + registrant_verification_token: nil, + registrant_verification_asked_at: nil, + pending_json: {}, + status_notes: status_notes, + statuses: statuses.presence || [DomainStatus::OK] + ) + end + def pending_update! return true if pending_update? self.epp_pending_update = true # for epp From f019bf5e0da5adf093fa2a2a9558ca3b4071f11c Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 13 Jan 2016 15:41:21 +0200 Subject: [PATCH 144/182] 110152326-filter_fix --- app/controllers/admin/contacts_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/contacts_controller.rb b/app/controllers/admin/contacts_controller.rb index 50131066f..960d74002 100644 --- a/app/controllers/admin/contacts_controller.rb +++ b/app/controllers/admin/contacts_controller.rb @@ -11,7 +11,7 @@ class Admin::ContactsController < AdminController end @q = Contact.includes(:registrar).search(search_params) - @contacts = @q.result.page(params[:page]) + @contacts = @q.result(distinct: :true).page(params[:page]) if params[:statuses_contains] contacts = Contact.includes(:registrar).where( @@ -23,7 +23,7 @@ class Admin::ContactsController < AdminController normalize_search_parameters do @q = contacts.search(search_params) - @contacts = @q.result.page(params[:page]) + @contacts = @q.result(distinct: :true).page(params[:page]) end @contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 From 764abdfd89555ea8317049964b6839646ee1e99c Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 13 Jan 2016 15:54:30 +0200 Subject: [PATCH 145/182] 111297422-whitespaces --- app/views/for_models/whois_other.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/for_models/whois_other.erb b/app/views/for_models/whois_other.erb index 50cf0b2dc..33ee735e7 100644 --- a/app/views/for_models/whois_other.erb +++ b/app/views/for_models/whois_other.erb @@ -2,7 +2,7 @@ Estonia .ee Top Level Domain WHOIS server Domain: name: <%= @json['name'] %> -status: <%= @json['status'] %> +status: <%= @json['status'] %> Estonia .ee Top Level Domain WHOIS server More information at http://internet.ee From 86bc1e81a0a54708a0be7c95ee20e4d01571ee92 Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 14 Jan 2016 15:11:15 +0200 Subject: [PATCH 146/182] 111237776-renew_logic_change --- app/models/domain.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index e4882473a..26148ca78 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -408,8 +408,7 @@ class Domain < ActiveRecord::Base end end - return false if statuses.include_any?(DomainStatus::DELETE_CANDIDATE, DomainStatus::SERVER_RENEW_PROHIBITED, - DomainStatus::CLIENT_RENEW_PROHIBITED, DomainStatus::PENDING_RENEW, + return false if statuses.include_any?(DomainStatus::DELETE_CANDIDATE, DomainStatus::PENDING_RENEW, DomainStatus::PENDING_TRANSFER, DomainStatus::PENDING_DELETE, DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE_CONFIRMATION) true From b85a637ef2a9fc1b0dbb8f281c418a71b8bf1208 Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 15 Jan 2016 17:34:05 +0200 Subject: [PATCH 147/182] 111219288-template_fix_for_corrupted_log --- app/views/admin/domain_versions/_version.haml | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/app/views/admin/domain_versions/_version.haml b/app/views/admin/domain_versions/_version.haml index fd449b4b0..321e9abda 100644 --- a/app/views/admin/domain_versions/_version.haml +++ b/app/views/admin/domain_versions/_version.haml @@ -55,43 +55,47 @@ = "#{l(domain.valid_to, format: :date)}" %td - - registrant.each do |r| - %p - = r[:name] - = r[:phone] - = r[:email] - %p - = r[:code] + - if registrant + - registrant.each do |r| + %p + = r[:name] + = r[:phone] + = r[:email] + %p + = r[:code] %td - - admin_contacts.each do |ac| - %p - = ac[:name] - = ac[:phone] - = ac[:email] - %p - = ac[:code] + - if admin_contacts + - admin_contacts.each do |ac| + %p + = ac[:name] + = ac[:phone] + = ac[:email] + %p + = ac[:code] %td - - tech_contacts.each do |tc| - %p - = tc[:name] - = tc[:phone] - = tc[:email] - %p - = tc[:code] + - if tech_contacts + - tech_contacts.each do |tc| + %p + = tc[:name] + = tc[:phone] + = tc[:email] + %p + = tc[:code] %td %p - - nameservers.each do |ns| - = ns[:hostname] - %br - = ns[:ipv4] - = ns[:ipv6] + - if nameservers + - nameservers.each do |ns| + = ns[:hostname] + %br + = ns[:ipv4] + = ns[:ipv6] %td %p - = domain.registrar.name + = domain.registrar.name if domain.registrar - if domain.pending_json.present? %tr.js-pending{ style: 'display: none;' } From 49e66d33dee67e3ed353edbc3046ab091b754057 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 18 Jan 2016 14:13:28 +0200 Subject: [PATCH 148/182] Story#105852786 - Push bank transfers to directo --- Gemfile | 1 + Gemfile.lock | 13 +++++ app/models/bank_transaction.rb | 30 ++++++++---- app/models/directo.rb | 47 +++++++++++++++++++ app/views/admin/settings/index.haml | 2 + config/application-example.yml | 2 + config/initializers/initial_settings.rb | 2 + db/migrate/20160113143447_create_directos.rb | 10 ++++ ...2453_add_in_directo_to_bank_transaction.rb | 5 ++ spec/models/directo_spec.rb | 5 ++ 10 files changed, 108 insertions(+), 9 deletions(-) create mode 100644 app/models/directo.rb create mode 100644 db/migrate/20160113143447_create_directos.rb create mode 100644 db/migrate/20160118092453_add_in_directo_to_bank_transaction.rb create mode 100644 spec/models/directo_spec.rb diff --git a/Gemfile b/Gemfile index 10c680786..d29fa223b 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,7 @@ gem 'rails', '4.2.4' # when update, all initializers eis_custom files nee gem 'iso8601', '0.8.6' # for dates and times gem 'hashie-forbidden_attributes', '0.1.1' gem 'SyslogLogger', '2.0', require: 'syslog/logger' +gem 'rest-client' # load env gem 'figaro', '1.1.1' diff --git a/Gemfile.lock b/Gemfile.lock index b92d6dc1b..45eb09943 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -188,6 +188,8 @@ GEM nokogiri (>= 1.4.0) savon (>= 2.4.0) docile (1.1.5) + domain_name (0.5.25) + unf (>= 0.0.5, < 1.0.0) epp-xml (1.0.4) activesupport (~> 4.1) builder (~> 3.2) @@ -261,6 +263,8 @@ GEM nokogiri (~> 1.6.0) ruby_parser (~> 3.5) html5_validators (1.2.2) + http-cookie (1.0.2) + domain_name (~> 0.5) httpclient (2.6.0.1) httpi (2.4.1) rack @@ -320,6 +324,7 @@ GEM multi_json (1.11.2) multi_xml (0.5.5) nenv (0.2.0) + netrc (0.11.0) newrelic_rpm (3.12.0.288) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) @@ -412,6 +417,10 @@ GEM request_store (1.1.0) responders (2.1.0) railties (>= 4.2.0, < 5) + rest-client (1.8.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) rspec (3.3.0) rspec-core (~> 3.3.0) rspec-expectations (~> 3.3.0) @@ -515,6 +524,9 @@ GEM uglifier (2.7.1) execjs (>= 0.3.0) json (>= 1.8.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.1) unicorn (4.9.0) kgio (~> 2.6) rack @@ -617,6 +629,7 @@ DEPENDENCIES rails-settings-cached (= 0.4.1) rake ransack (= 1.5.1) + rest-client rspec-rails (= 3.3.2) rubocop (= 0.32.1) rubycritic (= 1.4.0) diff --git a/app/models/bank_transaction.rb b/app/models/bank_transaction.rb index 2e5b90a2e..b827670c4 100644 --- a/app/models/bank_transaction.rb +++ b/app/models/bank_transaction.rb @@ -2,6 +2,7 @@ class BankTransaction < ActiveRecord::Base include Versions belongs_to :bank_statement has_one :account_activity + has_many :directo_records, as: :item, class_name: 'Directo' scope :unbinded, lambda { where('id NOT IN (SELECT bank_transaction_id FROM account_activities where bank_transaction_id IS NOT NULL)') @@ -16,21 +17,32 @@ class BankTransaction < ActiveRecord::Base account_activity.invoice end + + def invoice_num + return @invoice_no if defined?(@invoice_no) + + match = description.match(/^[^\d]*(\d+)/) + return unless match + + @invoice_no = match[1].try(:to_i) + end + + def invoice + @invoice ||= registrar.invoices.find_by(number: invoice_num) if registrar + end + + def registrar + @registrar ||= Registrar.find_by(reference_no: reference_no) + end + + # For successful binding, reference number, invoice id and sum must match with the invoice # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/CyclomaticComplexity def autobind_invoice return if binded? - registrar = Registrar.find_by(reference_no: reference_no) return unless registrar - - match = description.match(/^[^\d]*(\d+)/) - return unless match - - invoice_no = match[1].to_i - return unless invoice_no - - invoice = registrar.invoices.find_by(number: invoice_no) + return unless invoice_num return unless invoice return if invoice.binded? diff --git a/app/models/directo.rb b/app/models/directo.rb new file mode 100644 index 000000000..73b88e0ae --- /dev/null +++ b/app/models/directo.rb @@ -0,0 +1,47 @@ +class Directo < ActiveRecord::Base + belongs_to :item, polymorphic: true + + def self.send_receipts + new_trans = BankTransaction.where(in_directo: false) + new_trans.find_in_batches(batch_size: 10).each do |group| + mappers = {} # need them as no direct connection between transaction and invoice + builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| + xml.invoices { + group.each do |transaction| + next unless transaction.invoice + num = transaction.invoice_num + mappers[num] = transaction + + xml.invoice( + "SalesAgent" => transaction.invoice.seller_name, + "Number" => num, + "InvoiceDate" => (transaction.paid_at||transaction.created_at).strftime("%Y-%m-%dT%H:%M:%S"), + "PaymentTerm" => Setting.directo_receipt_payment_term, + "Currency" => transaction.currency, + "CustomerCode"=> transaction.invoice.try(:buyer).try(:directo_handle) + ){ + xml.line( + "ProductID"=> Setting.directo_receipt_product_name, + "Quantity" => 1, + "UnitPriceWoVAT" =>ActionController::Base.helpers.number_with_precision(transaction.sum.to_f/1.2, precision: 2, separator: "."), + "ProductName" => transaction.description + ) + } + end + } + end + + data = builder.to_xml.gsub("\n",'') + response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false).to_s + dump_result_to_db(mappers, response) + end + end + + def self.dump_result_to_db mappers, xml + Nokogiri::XML(xml).css("Result").each do |res| + obj = mappers[res.attributes["docid"].value.to_i] + obj.directo_records.first_or_create!(response: res.as_json.to_h) + obj.update_columns(in_directo: true) + end + end +end diff --git a/app/views/admin/settings/index.haml b/app/views/admin/settings/index.haml index f03ca66bc..52430eb2a 100644 --- a/app/views/admin/settings/index.haml +++ b/app/views/admin/settings/index.haml @@ -71,6 +71,8 @@ = render 'setting_row', var: :days_to_keep_invoices_active = render 'setting_row', var: :days_to_keep_overdue_invoices_active = render 'setting_row', var: :minimum_deposit + = render 'setting_row', var: :directo_receipt_payment_term + = render 'setting_row', var: :directo_receipt_product_name = render 'setting_row', var: :registry_billing_email = render 'setting_row', var: :registry_invoice_contact = render 'setting_row', var: :registry_vat_no diff --git a/config/application-example.yml b/config/application-example.yml index b08a1b007..cf6e26357 100644 --- a/config/application-example.yml +++ b/config/application-example.yml @@ -45,6 +45,8 @@ ca_cert_path: '/home/registry/registry/shared/ca/certs/ca.crt.pem' ca_key_path: '/home/registry/registry/shared/ca/private/ca.key.pem' ca_key_password: 'your-root-key-password' +directo_invoice_url: 'https://domain/ddddd.asp' + # # EPP diff --git a/config/initializers/initial_settings.rb b/config/initializers/initial_settings.rb index 193d179b0..8309d299a 100644 --- a/config/initializers/initial_settings.rb +++ b/config/initializers/initial_settings.rb @@ -33,6 +33,8 @@ if con.present? && con.table_exists?('settings') Setting.save_default(:days_to_keep_invoices_active, 30) Setting.save_default(:days_to_keep_overdue_invoices_active, 30) Setting.save_default(:minimum_deposit, 0.0) + Setting.save_default(:directo_receipt_payment_term, "R") + Setting.save_default(:directo_receipt_product_name, "ETTEM06") Setting.save_default(:days_to_renew_domain_before_expire, 90) Setting.save_default(:expire_warning_period, 15) diff --git a/db/migrate/20160113143447_create_directos.rb b/db/migrate/20160113143447_create_directos.rb new file mode 100644 index 000000000..2fb6f85f8 --- /dev/null +++ b/db/migrate/20160113143447_create_directos.rb @@ -0,0 +1,10 @@ +class CreateDirectos < ActiveRecord::Migration + def change + create_table :directos do |t| + t.belongs_to :item, index: true, polymorphic: true + t.json :response + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160118092453_add_in_directo_to_bank_transaction.rb b/db/migrate/20160118092453_add_in_directo_to_bank_transaction.rb new file mode 100644 index 000000000..14433b341 --- /dev/null +++ b/db/migrate/20160118092453_add_in_directo_to_bank_transaction.rb @@ -0,0 +1,5 @@ +class AddInDirectoToBankTransaction < ActiveRecord::Migration + def change + add_column :bank_transactions, :in_directo, :boolean, default: false + end +end diff --git a/spec/models/directo_spec.rb b/spec/models/directo_spec.rb new file mode 100644 index 000000000..bf187d2bf --- /dev/null +++ b/spec/models/directo_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Directo, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From b111285334a7c41102fdb030e4f40c4c75e09f40 Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 18 Jan 2016 14:20:27 +0200 Subject: [PATCH 149/182] 111396946-templates_and_actions --- .../admin/reserved_domains_controller.rb | 38 ++++++++- app/views/admin/reserved_domains/_form.haml | 23 ++++++ app/views/admin/reserved_domains/index.haml | 82 ++++++++++++++++--- app/views/admin/reserved_domains/new.haml | 3 + 4 files changed, 132 insertions(+), 14 deletions(-) create mode 100644 app/views/admin/reserved_domains/_form.haml create mode 100644 app/views/admin/reserved_domains/new.haml diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb index 402d33022..48677bea2 100644 --- a/app/controllers/admin/reserved_domains_controller.rb +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -2,11 +2,43 @@ class Admin::ReservedDomainsController < AdminController load_and_authorize_resource def index - names = ReservedDomain.pluck(:name, :password).each_with_object({}){|domain, hash| hash[domain[0]] = domain[1]} - names.names = nil if names.blank? - @reserved_domains = names.to_yaml.gsub(/---.?\n/, '').gsub(/\.\.\..?\n/, '') + + params[:q] ||= {} + domains = ReservedDomain.all + @q = domains.search(params[:q]) + @domains = @q.result.page(params[:page]) + @domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 + end + def new + @domain = ReservedDomain.new + end + + def edit + authorize! :update, Depp::Domain + @data = @domain.info(params[:domain_name]) + @domain_params = Depp::Domain.construct_params_from_server_data(@data) + end + + def update + authorize! :update, Depp::Domain + @domain_params = params[:domain] + @data = @domain.update(@domain_params) + + if response_ok? + redirect_to info_registrar_domains_url(domain_name: @domain_params[:name]) + else + params[:domain_name] = @domain_params[:name] + render 'new' + end + end + + def delete + authorize! :delete, Depp::Domain + end + + def create @reserved_domains = params[:reserved_domains] diff --git a/app/views/admin/reserved_domains/_form.haml b/app/views/admin/reserved_domains/_form.haml new file mode 100644 index 000000000..bfbacbfd9 --- /dev/null +++ b/app/views/admin/reserved_domains/_form.haml @@ -0,0 +1,23 @@ += form_for([:admin, @domain], html: {class: 'form-horizontal'}) do |f| + = render 'shared/full_errors', object: @domain + + .row + .col-md-8 + .panel.panel-default + .panel-heading.clearfix + .pull-left= t(:general) + .panel-body + .form-group + .col-md-4.control-label + = f.label :name + .col-md-7 + = f.text_field(:name, class: 'form-control') + .form-group + .col-md-4.control-label + = f.label :password + .col-md-7 + = f.text_field(:password, class: 'form-control') +%hr + .row + .col-md-8.text-right + = button_tag(t(:save), class: 'btn btn-primary') diff --git a/app/views/admin/reserved_domains/index.haml b/app/views/admin/reserved_domains/index.haml index 15840ff93..808ad1480 100644 --- a/app/views/admin/reserved_domains/index.haml +++ b/app/views/admin/reserved_domains/index.haml @@ -1,14 +1,74 @@ - content_for :actions do - = link_to('#', class: 'btn btn-default', "data-container": "body", "data-title": t('list_format_is_in_yaml'), "data-content": "domain.ee: authinfopw
seconddomain.ee:
thirddomain.ee: authinfo3

#{t('if_auth_info_is_left_empty_it_will_be_auto_generated')}
#{t('each_domain_name_must_end_with_colon_sign')}", "data-placement": "left", "data-toggle": "popover", "data-html" => "true") do - %span.glyphicon.glyphicon-info-sign{"aria-hidden" => "true"} - + = link_to(t(:new), new_admin_reserved_domain_path, class: 'btn btn-primary') = render 'shared/title', name: t(:reserved_domains) -= form_tag([:admin, :reserved_domains]) do |f| - .row - .col-md-12 - = text_area_tag :reserved_domains, @reserved_domains, class: 'form-control', rows: 30 - %hr - .row - .col-md-12.text-right - %button.btn.btn-warning=t(:save) +.row + .col-md-12 + = search_form_for [:admin, @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(: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) + .row + .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) +%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') + %th{class: 'col-xs-2'} + = sort_link(@q, 'password') + %th{class: 'col-xs-2'} + = sort_link(@q, 'created_at', t(:created_at)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'updated_at', t(:updated_at)) + %th{class: 'col-xs-2'} + = t(:actions) + %tbody + - @domains.each do |x| + %tr + %td= x.name + %td= x.password + %td= l(x.created_at, format: :short) + %td= l(x.updated_at, format: :short) + %td + = link_to(t(:edit), edit_admin_reserved_domains_path(name: x.name), + class: 'btn btn-primary btn-xs') + = link_to(t(:renew), renew_admin_reserved_domains_path(name: x.name), + class: 'btn btn-default btn-xs') + = link_to(t(:delete), delete_admin_reserved_domains_path(name: x.name), + class: 'btn btn-default btn-xs') +.row + .col-md-6 + = paginate @domains + .col-md-6.text-right + .pagination + = t(:result_count, count: @domains.total_count) + +:coffee + $(".js-reset-form").on "click", (e) -> + e.preventDefault(); + window.location = "#{admin_reserved_domains_path}" diff --git a/app/views/admin/reserved_domains/new.haml b/app/views/admin/reserved_domains/new.haml new file mode 100644 index 000000000..937fdebde --- /dev/null +++ b/app/views/admin/reserved_domains/new.haml @@ -0,0 +1,3 @@ += render 'shared/title', name: t(:new_reserved_domain) + += render 'form' From 975dd523689658c5fc78ddaceaf3a04b73a70d81 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 18 Jan 2016 20:26:03 +0200 Subject: [PATCH 150/182] Story#105852786 - Sales agent is set by config --- app/models/directo.rb | 2 +- app/views/admin/settings/index.haml | 1 + config/initializers/initial_settings.rb | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index 73b88e0ae..e51313b5b 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -13,7 +13,7 @@ class Directo < ActiveRecord::Base mappers[num] = transaction xml.invoice( - "SalesAgent" => transaction.invoice.seller_name, + "SalesAgent" => Setting.directo_sales_agent, "Number" => num, "InvoiceDate" => (transaction.paid_at||transaction.created_at).strftime("%Y-%m-%dT%H:%M:%S"), "PaymentTerm" => Setting.directo_receipt_payment_term, diff --git a/app/views/admin/settings/index.haml b/app/views/admin/settings/index.haml index 52430eb2a..e09e48396 100644 --- a/app/views/admin/settings/index.haml +++ b/app/views/admin/settings/index.haml @@ -73,6 +73,7 @@ = render 'setting_row', var: :minimum_deposit = render 'setting_row', var: :directo_receipt_payment_term = render 'setting_row', var: :directo_receipt_product_name + = render 'setting_row', var: :directo_sales_agent = render 'setting_row', var: :registry_billing_email = render 'setting_row', var: :registry_invoice_contact = render 'setting_row', var: :registry_vat_no diff --git a/config/initializers/initial_settings.rb b/config/initializers/initial_settings.rb index 8309d299a..1b25ddeb3 100644 --- a/config/initializers/initial_settings.rb +++ b/config/initializers/initial_settings.rb @@ -35,6 +35,7 @@ if con.present? && con.table_exists?('settings') Setting.save_default(:minimum_deposit, 0.0) Setting.save_default(:directo_receipt_payment_term, "R") Setting.save_default(:directo_receipt_product_name, "ETTEM06") + Setting.save_default(:directo_sales_agent, "JAANA") Setting.save_default(:days_to_renew_domain_before_expire, 90) Setting.save_default(:expire_warning_period, 15) From 51c54f77c7a4d728e7dd09c903950032c4c6633d Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 18 Jan 2016 21:29:16 +0200 Subject: [PATCH 151/182] Story#105852786 - Directo transaction sum is taken from invoice --- app/models/directo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index e51313b5b..2a1ec118c 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -23,7 +23,7 @@ class Directo < ActiveRecord::Base xml.line( "ProductID"=> Setting.directo_receipt_product_name, "Quantity" => 1, - "UnitPriceWoVAT" =>ActionController::Base.helpers.number_with_precision(transaction.sum.to_f/1.2, precision: 2, separator: "."), + "UnitPriceWoVAT" =>ActionController::Base.helpers.number_with_precision(transaction.invoice.sum_without_vat, precision: 2, separator: "."), "ProductName" => transaction.description ) } From bc640c63fe2116a59cffa6cf70b11a3045e30d1b Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 19 Jan 2016 09:38:46 +0200 Subject: [PATCH 152/182] Story#105852786 - cleaner code --- app/models/directo.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index 2a1ec118c..3ca40eaf1 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -8,8 +8,9 @@ class Directo < ActiveRecord::Base builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| xml.invoices { group.each do |transaction| - next unless transaction.invoice - num = transaction.invoice_num + invoice = transaction.invoice + next unless invoice + num = transaction.invoice_num mappers[num] = transaction xml.invoice( @@ -18,12 +19,12 @@ class Directo < ActiveRecord::Base "InvoiceDate" => (transaction.paid_at||transaction.created_at).strftime("%Y-%m-%dT%H:%M:%S"), "PaymentTerm" => Setting.directo_receipt_payment_term, "Currency" => transaction.currency, - "CustomerCode"=> transaction.invoice.try(:buyer).try(:directo_handle) + "CustomerCode"=> invoice.buyer.try(:directo_handle) ){ xml.line( "ProductID"=> Setting.directo_receipt_product_name, "Quantity" => 1, - "UnitPriceWoVAT" =>ActionController::Base.helpers.number_with_precision(transaction.invoice.sum_without_vat, precision: 2, separator: "."), + "UnitPriceWoVAT" =>ActionController::Base.helpers.number_with_precision(invoice.sum_cache/(1+invoice.vat_prc), precision: 2, separator: "."), "ProductName" => transaction.description ) } From 72bd54dc7cac8814c3cf0f827bc80b3516001870 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 19 Jan 2016 12:39:42 +0200 Subject: [PATCH 153/182] Story#105852786 - Directo invoices are calculated based on invoices --- app/models/bank_link.rb | 3 ++- app/models/bank_transaction.rb | 2 +- app/models/directo.rb | 19 ++++++++----------- app/models/invoice.rb | 7 ++++++- ...2453_add_in_directo_to_bank_transaction.rb | 5 ----- ...0160118092454_add_in_directo_to_invoice.rb | 5 +++++ 6 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 db/migrate/20160118092453_add_in_directo_to_bank_transaction.rb create mode 100644 db/migrate/20160118092454_add_in_directo_to_invoice.rb diff --git a/app/models/bank_link.rb b/app/models/bank_link.rb index 31be3e222..29857951f 100644 --- a/app/models/bank_link.rb +++ b/app/models/bank_link.rb @@ -32,7 +32,7 @@ class BankLink hash["VK_AMOUNT"] = number_with_precision(invoice.sum_cache, :precision => 2, :separator => ".") hash["VK_CURR"] = invoice.currency hash["VK_REF"] = "" - hash["VK_MSG"] = "Order nr. #{invoice.number}" + hash["VK_MSG"] = invoice.description hash["VK_RETURN"] = controller.registrar_return_payment_with_url(type) hash["VK_CANCEL"] = controller.registrar_return_payment_with_url(type) hash["VK_DATETIME"] = Time.now.strftime("%Y-%m-%dT%H:%M:%S%z") @@ -101,6 +101,7 @@ class BankLink transaction.buyer_iban = params["VK_SND_ACC"] transaction.buyer_name = params["VK_SND_NAME"] transaction.paid_at = Time.parse(params["VK_T_DATETIME"]) + transaction.save! transaction.autobind_invoice end diff --git a/app/models/bank_transaction.rb b/app/models/bank_transaction.rb index b827670c4..1a34965bf 100644 --- a/app/models/bank_transaction.rb +++ b/app/models/bank_transaction.rb @@ -2,7 +2,7 @@ class BankTransaction < ActiveRecord::Base include Versions belongs_to :bank_statement has_one :account_activity - has_many :directo_records, as: :item, class_name: 'Directo' + has_many :directo_records, as: :item, class_name: 'Directo'# Deprecated scope :unbinded, lambda { where('id NOT IN (SELECT bank_transaction_id FROM account_activities where bank_transaction_id IS NOT NULL)') diff --git a/app/models/directo.rb b/app/models/directo.rb index 3ca40eaf1..4116e2985 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -2,30 +2,27 @@ class Directo < ActiveRecord::Base belongs_to :item, polymorphic: true def self.send_receipts - new_trans = BankTransaction.where(in_directo: false) + new_trans = Invoice.where(invoice_type: "DEB", in_directo: false) new_trans.find_in_batches(batch_size: 10).each do |group| - mappers = {} # need them as no direct connection between transaction and invoice + mappers = {} # need them as no direct connection between invoice builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| xml.invoices { - group.each do |transaction| - invoice = transaction.invoice - next unless invoice - num = transaction.invoice_num - mappers[num] = transaction - + group.each do |invoice| + num = invoice.number + mappers[num] = invoice xml.invoice( "SalesAgent" => Setting.directo_sales_agent, "Number" => num, - "InvoiceDate" => (transaction.paid_at||transaction.created_at).strftime("%Y-%m-%dT%H:%M:%S"), + "InvoiceDate" => (invoice.account_activity.try(:bank_transaction).try(:paid_at) || invoice.updated_at).strftime("%Y-%m-%dT%H:%M:%S"), "PaymentTerm" => Setting.directo_receipt_payment_term, - "Currency" => transaction.currency, + "Currency" => invoice.currency, "CustomerCode"=> invoice.buyer.try(:directo_handle) ){ xml.line( "ProductID"=> Setting.directo_receipt_product_name, "Quantity" => 1, "UnitPriceWoVAT" =>ActionController::Base.helpers.number_with_precision(invoice.sum_cache/(1+invoice.vat_prc), precision: 2, separator: "."), - "ProductName" => transaction.description + "ProductName" => invoice.description ) } end diff --git a/app/models/invoice.rb b/app/models/invoice.rb index fdcb3cf61..5c7dafe85 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -2,8 +2,9 @@ class Invoice < ActiveRecord::Base include Versions belongs_to :seller, class_name: 'Registrar' belongs_to :buyer, class_name: 'Registrar' + has_one :account_activity has_many :invoice_items - has_one :account_activity + has_many :directo_records, as: :item, class_name: 'Directo' accepts_nested_attributes_for :invoice_items @@ -99,6 +100,10 @@ class Invoice < ActiveRecord::Base kit.to_pdf end + def description + "Order nr. #{number}" + end + def pdf_name "invoice-#{number}.pdf" end diff --git a/db/migrate/20160118092453_add_in_directo_to_bank_transaction.rb b/db/migrate/20160118092453_add_in_directo_to_bank_transaction.rb deleted file mode 100644 index 14433b341..000000000 --- a/db/migrate/20160118092453_add_in_directo_to_bank_transaction.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddInDirectoToBankTransaction < ActiveRecord::Migration - def change - add_column :bank_transactions, :in_directo, :boolean, default: false - end -end diff --git a/db/migrate/20160118092454_add_in_directo_to_invoice.rb b/db/migrate/20160118092454_add_in_directo_to_invoice.rb new file mode 100644 index 000000000..0e93c3835 --- /dev/null +++ b/db/migrate/20160118092454_add_in_directo_to_invoice.rb @@ -0,0 +1,5 @@ +class AddInDirectoToInvoice < ActiveRecord::Migration + def change + add_column :invoices, :in_directo, :boolean, default: false + end +end From 67fb02d7c498e653634d0cc5e8ed88fdc73efcf3 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 19 Jan 2016 14:50:08 +0200 Subject: [PATCH 154/182] Story#105852786 - Directo skip if bank_transaction is not set --- app/models/directo.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index 4116e2985..502dfe089 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -8,12 +8,14 @@ class Directo < ActiveRecord::Base builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| xml.invoices { group.each do |invoice| + next if invoice.account_activity.nil? || invoice.account_activity.bank_transaction.nil? + num = invoice.number mappers[num] = invoice xml.invoice( "SalesAgent" => Setting.directo_sales_agent, "Number" => num, - "InvoiceDate" => (invoice.account_activity.try(:bank_transaction).try(:paid_at) || invoice.updated_at).strftime("%Y-%m-%dT%H:%M:%S"), + "InvoiceDate" => invoice.created_at.strftime("%Y-%m-%dT%H:%M:%S"), "PaymentTerm" => Setting.directo_receipt_payment_term, "Currency" => invoice.currency, "CustomerCode"=> invoice.buyer.try(:directo_handle) From 6c8bab56bf08d0853810c4edb97ff28155257448 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 19 Jan 2016 15:02:29 +0200 Subject: [PATCH 155/182] Story#105852786 - add Directo.send_receipts into whenever to generate cron jobs --- config/schedule.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/schedule.rb b/config/schedule.rb index 5524f10ab..f3bbad764 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -53,6 +53,10 @@ if @cron_group == 'registry' every 52.minutes do runner 'Domain.start_redemption_grace_period' end + + every :day, at: '19:00pm' do + runner 'Directo.send_receipts' + end if @environment == 'production' end every 10.minutes do From 63fcbd9515684e7f5e39a925cbaf482041b99f6f Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 19 Jan 2016 15:17:33 +0200 Subject: [PATCH 156/182] Story#105852786 - Invoice' bank transaction should have sum in order to mean that invoice payment finished --- app/models/directo.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index 502dfe089..bf5bc9043 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -8,7 +8,7 @@ class Directo < ActiveRecord::Base builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| xml.invoices { group.each do |invoice| - next if invoice.account_activity.nil? || invoice.account_activity.bank_transaction.nil? + next if invoice.account_activity.nil? || invoice.account_activity.bank_transaction.nil? || invoice.account_activity.bank_transaction.sum.nil? num = invoice.number mappers[num] = invoice @@ -32,8 +32,9 @@ class Directo < ActiveRecord::Base end data = builder.to_xml.gsub("\n",'') - response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false).to_s - dump_result_to_db(mappers, response) + # response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false).to_s + # dump_result_to_db(mappers, response) + binding.pry end end From c3db50b5cdd2f650cc495684b1276ab5a08ef253 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 19 Jan 2016 15:27:17 +0200 Subject: [PATCH 157/182] Story#105852786 - Invoice' bank transaction should have sum in order to mean that invoice payment finished --- app/models/directo.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index bf5bc9043..ae8c2b48c 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -8,7 +8,8 @@ class Directo < ActiveRecord::Base builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| xml.invoices { group.each do |invoice| - next if invoice.account_activity.nil? || invoice.account_activity.bank_transaction.nil? || invoice.account_activity.bank_transaction.sum.nil? + next if invoice.account_activity.nil? || invoice.account_activity.bank_transaction.nil? + next if invoice.account_activity.bank_transaction.sum.nil? num = invoice.number mappers[num] = invoice @@ -32,9 +33,8 @@ class Directo < ActiveRecord::Base end data = builder.to_xml.gsub("\n",'') - # response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false).to_s - # dump_result_to_db(mappers, response) - binding.pry + response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false).to_s + dump_result_to_db(mappers, response) end end From 66bdc5146b9f1d94e8378697395aa81c4f0ca9bc Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 19 Jan 2016 15:36:50 +0200 Subject: [PATCH 158/182] Story#105852786 - Do not send invoice to directo if sum is not matching with bank transaction --- app/models/directo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index ae8c2b48c..af62d21a2 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -9,7 +9,7 @@ class Directo < ActiveRecord::Base xml.invoices { group.each do |invoice| next if invoice.account_activity.nil? || invoice.account_activity.bank_transaction.nil? - next if invoice.account_activity.bank_transaction.sum.nil? + next if invoice.account_activity.bank_transaction.sum.nil? || invoice.account_activity.bank_transaction.sum != invoice.sum_cache num = invoice.number mappers[num] = invoice From d3295e349cd5f08859444ce7daa05e633a1a24fb Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 19 Jan 2016 17:00:00 +0200 Subject: [PATCH 159/182] Story#105852786 - Do not check for now bank transactions sum --- app/models/directo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index af62d21a2..07b02e625 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -9,7 +9,7 @@ class Directo < ActiveRecord::Base xml.invoices { group.each do |invoice| next if invoice.account_activity.nil? || invoice.account_activity.bank_transaction.nil? - next if invoice.account_activity.bank_transaction.sum.nil? || invoice.account_activity.bank_transaction.sum != invoice.sum_cache + # next if invoice.account_activity.bank_transaction.sum.nil? || invoice.account_activity.bank_transaction.sum != invoice.sum_cache num = invoice.number mappers[num] = invoice From e99dbe9a18ceeaeb66e89439a58f43431617defb Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 20 Jan 2016 13:30:34 +0200 Subject: [PATCH 160/182] Story#105852786 - each time invoice is being sent to Directo, record is saved to DB --- app/models/directo.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index 07b02e625..2b82ee289 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -22,10 +22,10 @@ class Directo < ActiveRecord::Base "CustomerCode"=> invoice.buyer.try(:directo_handle) ){ xml.line( - "ProductID"=> Setting.directo_receipt_product_name, - "Quantity" => 1, - "UnitPriceWoVAT" =>ActionController::Base.helpers.number_with_precision(invoice.sum_cache/(1+invoice.vat_prc), precision: 2, separator: "."), - "ProductName" => invoice.description + "ProductID" => Setting.directo_receipt_product_name, + "Quantity" => 1, + "UnitPriceWoVAT" => ActionController::Base.helpers.number_with_precision(invoice.sum_cache/(1+invoice.vat_prc), precision: 2, separator: "."), + "ProductName" => invoice.description ) } end @@ -41,7 +41,7 @@ class Directo < ActiveRecord::Base def self.dump_result_to_db mappers, xml Nokogiri::XML(xml).css("Result").each do |res| obj = mappers[res.attributes["docid"].value.to_i] - obj.directo_records.first_or_create!(response: res.as_json.to_h) + obj.directo_records.create!(response: res.as_json.to_h) obj.update_columns(in_directo: true) end end From f86453fa0b9ef79f192b610b9a68bfadc9684d22 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 20 Jan 2016 13:49:44 +0200 Subject: [PATCH 161/182] Story#105852786 - skip cancelled invoices to be sent to directo --- app/models/directo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index 2b82ee289..83eaf1a29 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -2,7 +2,7 @@ class Directo < ActiveRecord::Base belongs_to :item, polymorphic: true def self.send_receipts - new_trans = Invoice.where(invoice_type: "DEB", in_directo: false) + new_trans = Invoice.where(invoice_type: "DEB", in_directo: false).where.not(cancelled_at: nil) new_trans.find_in_batches(batch_size: 10).each do |group| mappers = {} # need them as no direct connection between invoice builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| From 793bc359ea013d2a1f650bc8af54f12100288704 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 20 Jan 2016 15:44:55 +0200 Subject: [PATCH 162/182] 111396946-methods --- .../admin/reserved_domains_controller.rb | 60 +------------------ app/views/admin/reserved_domains/index.haml | 8 +-- 2 files changed, 5 insertions(+), 63 deletions(-) diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb index 48677bea2..4cb7ba51f 100644 --- a/app/controllers/admin/reserved_domains_controller.rb +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -16,66 +16,10 @@ class Admin::ReservedDomainsController < AdminController end def edit - authorize! :update, Depp::Domain - @data = @domain.info(params[:domain_name]) - @domain_params = Depp::Domain.construct_params_from_server_data(@data) - end - - def update - authorize! :update, Depp::Domain - @domain_params = params[:domain] - @data = @domain.update(@domain_params) - - if response_ok? - redirect_to info_registrar_domains_url(domain_name: @domain_params[:name]) - else - params[:domain_name] = @domain_params[:name] - render 'new' - end + authorize! :update, ReservedDomain end def delete - authorize! :delete, Depp::Domain - end - - - def create - @reserved_domains = params[:reserved_domains] - - begin - params[:reserved_domains] = "---\n" if params[:reserved_domains].blank? - names = YAML.load(params[:reserved_domains]) - fail if names == false - rescue - flash.now[:alert] = I18n.t('invalid_yaml') - logger.warn 'Invalid YAML' - render :index and return - end - - result = true - ReservedDomain.transaction do - # removing old ones - existing = ReservedDomain.any_of_domains(names.keys).pluck(:id) - ReservedDomain.where.not(id: existing).destroy_all - - #updating and adding - names.each do |name, psw| - rec = ReservedDomain.find_or_initialize_by(name: name) - rec.password = psw - - unless rec.save - result = false - raise ActiveRecord::Rollback - end - end - end - - if result - flash[:notice] = I18n.t('record_updated') - redirect_to :back - else - flash.now[:alert] = I18n.t('failed_to_update_record') - render :index - end + authorize! :delete, ReservedDomain end end diff --git a/app/views/admin/reserved_domains/index.haml b/app/views/admin/reserved_domains/index.haml index 808ad1480..6ac65d14b 100644 --- a/app/views/admin/reserved_domains/index.haml +++ b/app/views/admin/reserved_domains/index.haml @@ -55,12 +55,10 @@ %td= l(x.created_at, format: :short) %td= l(x.updated_at, format: :short) %td - = link_to(t(:edit), edit_admin_reserved_domains_path(name: x.name), + = link_to(t(:edit), edit_admin_reserved_domain_path(id: x.id), + class: 'btn btn-primary btn-xs') + = link_to(t(:delete), delete_admin_reserved_domain_path(id: x.id), class: 'btn btn-primary btn-xs') - = link_to(t(:renew), renew_admin_reserved_domains_path(name: x.name), - class: 'btn btn-default btn-xs') - = link_to(t(:delete), delete_admin_reserved_domains_path(name: x.name), - class: 'btn btn-default btn-xs') .row .col-md-6 = paginate @domains From 3b515ab2dd7afeebfc115588a9953d1b07c56fad Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 20 Jan 2016 16:41:55 +0200 Subject: [PATCH 163/182] Story#112054829 - Use casting --- 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 e4882473a..c57d742e1 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -264,7 +264,7 @@ class Domain < ActiveRecord::Base domains.each do |domain| next unless domain.expirable? domain.set_graceful_expired - DomainMailer.expiration_reminder(domain.id).deliver_in(Setting.expiration_reminder_mail.days) + DomainMailer.expiration_reminder(domain.id).deliver_in(Setting.expiration_reminder_mail.to_i.days) STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? domain.save end From 762aff6bc0caad95c94a1651ed940c267ec6609f Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 25 Jan 2016 11:19:23 +0200 Subject: [PATCH 164/182] Story#112043941 - Add syslog to directo --- app/models/directo.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/directo.rb b/app/models/directo.rb index 83eaf1a29..5a719d0a7 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -43,6 +43,7 @@ class Directo < ActiveRecord::Base obj = mappers[res.attributes["docid"].value.to_i] obj.directo_records.create!(response: res.as_json.to_h) obj.update_columns(in_directo: true) + Rails.logger.info("[DIRECTO] Invoice #{res.attributes["docid"].value} was pushed and return is #{res.as_json.to_h.inspect}") end end end From b2787a21bad33d6d3b3ea85d0e6d6df47d5a077c Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 25 Jan 2016 11:37:12 +0200 Subject: [PATCH 165/182] Story#112127475 - server set statuses were not applied on broken domains --- app/models/domain.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index c57d742e1..138afa66e 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -266,7 +266,7 @@ class Domain < ActiveRecord::Base domain.set_graceful_expired DomainMailer.expiration_reminder(domain.id).deliver_in(Setting.expiration_reminder_mail.to_i.days) STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? - domain.save + domain.save(validate: false) end STDOUT << "#{Time.zone.now.utc} - Successfully expired #{domains.count} domains\n" unless Rails.env.test? @@ -280,7 +280,7 @@ class Domain < ActiveRecord::Base next unless domain.server_holdable? domain.statuses << DomainStatus::SERVER_HOLD STDOUT << "#{Time.zone.now.utc} Domain.start_redemption_grace_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? - domain.save + domain.save(validate: false) end STDOUT << "#{Time.zone.now.utc} - Successfully set server_hold to #{d.count} domains\n" unless Rails.env.test? @@ -294,7 +294,7 @@ class Domain < ActiveRecord::Base next unless domain.delete_candidateable? domain.statuses << DomainStatus::DELETE_CANDIDATE STDOUT << "#{Time.zone.now.utc} Domain.start_delete_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? - domain.save + domain.save(validate: false) end return if Rails.env.test? From df68b705ff58f134968e3466a3479a4328afb454 Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 25 Jan 2016 11:58:13 +0200 Subject: [PATCH 166/182] 110152326-distinct_added --- app/controllers/registrar/contacts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index c0b814993..0581a3cfc 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -27,7 +27,7 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller normalize_search_parameters do @q = contacts.search(search_params) - @contacts = @q.result.page(params[:page]) + @contacts = @q.result(distinct: :true).page(params[:page]) end @contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 From 8ed8a46046def125e48aa90b1f4bf343237a208f Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 25 Jan 2016 16:56:04 +0200 Subject: [PATCH 167/182] 111297422-que_jobs --- app/jobs/update_whois_record_job.rb | 10 ++++++++++ app/models/whois_record.rb | 2 +- lib/tasks/whois.rake | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 app/jobs/update_whois_record_job.rb diff --git a/app/jobs/update_whois_record_job.rb b/app/jobs/update_whois_record_job.rb new file mode 100644 index 000000000..39abeeb9c --- /dev/null +++ b/app/jobs/update_whois_record_job.rb @@ -0,0 +1,10 @@ +class UpdateWhoisRecordJob < Que::Job + def run(ids, type) + ids.each do |id| + record = WhoisRecord.find_by(id: id) + return unless record + + record.save + end + end +end \ No newline at end of file diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index 08d1cdf14..c16e5ce73 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -106,7 +106,7 @@ class WhoisRecord < ActiveRecord::Base self.json = generated_json self.body = generated_body self.name = json['name'] - self.registrar_id = domain.registrar_id # for faster registrar updates + self.registrar_id = domain.registrar_id if domain # for faster registrar updates end def update_whois_server diff --git a/lib/tasks/whois.rake b/lib/tasks/whois.rake index fd905e383..afd4cd62e 100644 --- a/lib/tasks/whois.rake +++ b/lib/tasks/whois.rake @@ -12,6 +12,10 @@ namespace :whois do puts(@i += 10000) GC.start end + + GC.start + UpdateWhoisRecordJob.enqueue WhoisRecord.find_each.map(&:id), 'domain' + end puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds" end From a0fcd8be8bbb857f1cb608e0226a51fa6fad6929 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 26 Jan 2016 14:36:09 +0200 Subject: [PATCH 168/182] 111297422-job_and_method_update --- app/jobs/update_whois_record_job.rb | 16 +++++++++++----- app/models/blocked_domain.rb | 2 ++ app/models/reserved_domain.rb | 2 ++ lib/tasks/whois.rake | 21 +++++++++++++-------- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/app/jobs/update_whois_record_job.rb b/app/jobs/update_whois_record_job.rb index 39abeeb9c..b7edb1fdd 100644 --- a/app/jobs/update_whois_record_job.rb +++ b/app/jobs/update_whois_record_job.rb @@ -1,10 +1,16 @@ class UpdateWhoisRecordJob < Que::Job - def run(ids, type) - ids.each do |id| - record = WhoisRecord.find_by(id: id) - return unless record - record.save + def run(ids, type) + klass = case type + when 'reserved'then ReservedDomain + when 'blocked' then BlockedDomain + else Domain + end + + ids.each do |id| + record = klass.find_by(id: id) + next unless record + record.update_whois_record end end end \ No newline at end of file diff --git a/app/models/blocked_domain.rb b/app/models/blocked_domain.rb index a25e1ff6a..079926512 100644 --- a/app/models/blocked_domain.rb +++ b/app/models/blocked_domain.rb @@ -24,6 +24,8 @@ class BlockedDomain < ActiveRecord::Base update_whois_server end + alias_method :update_whois_record, :generate_data + def update_whois_server wr = Whois::Record.find_or_initialize_by(name: name) wr.body = @body diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 141fd7263..d477f2524 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -35,6 +35,8 @@ class ReservedDomain < ActiveRecord::Base update_whois_server end + alias_method :update_whois_record, :generate_data + def update_whois_server wr = Whois::Record.find_or_initialize_by(name: name) wr.body = @body diff --git a/lib/tasks/whois.rake b/lib/tasks/whois.rake index afd4cd62e..c8c3ba2a1 100644 --- a/lib/tasks/whois.rake +++ b/lib/tasks/whois.rake @@ -3,18 +3,23 @@ namespace :whois do task regenerate: :environment do start = Time.zone.now.to_f - @i = 0 print "-----> Regenerate Registry whois_records table and sync with whois server..." ActiveRecord::Base.uncached do - puts "\n#{@i}" - Domain.included.find_in_batches(batch_size: 10000) do |batch| - batch.map(&:update_whois_record) - puts(@i += 10000) - GC.start + + print "\n-----> Update domains whois_records" + Domain.find_in_batches.each do |group| + UpdateWhoisRecordJob.enqueue group.map(&:id), 'domain' end - GC.start - UpdateWhoisRecordJob.enqueue WhoisRecord.find_each.map(&:id), 'domain' + print "\n-----> Update blocked domains whois_records" + BlockedDomain.find_in_batches.each do |group| + UpdateWhoisRecordJob.enqueue group.map(&:id), 'blocked' + end + + print "\n-----> Update reserved domains whois_records" + ReservedDomain.find_in_batches.each do |group| + UpdateWhoisRecordJob.enqueue group.map(&:id), 'reserved' + end end puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds" From da2f30f8a9c95c6254798452ff8461d783353d37 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 28 Jan 2016 13:10:32 +0200 Subject: [PATCH 169/182] Story#109590460 - fix ruby bug in comparing with regexp --- app/models/epp/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 5f0a7b209..3526cd463 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -165,7 +165,7 @@ class Epp::Contact < Contact org_priv = %w(org priv).freeze if ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.include?(ident_frame.attr('type')) at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_frame.attr('type')) - elsif ident_type == "birthday" && ident !=~ /\d{4}-\d{2}-\d{2}/ && (Date.parse(ident) rescue false) + elsif ident_type == "birthday" && ident[/\A\d{4}-\d{2}-\d{2}\z/] && (Date.parse(ident) rescue false) at.merge!(ident: ident_frame.text) at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? elsif ident_type.blank? && ident_country_code.blank? From f1d4d1f5522d69e2efdfa8059728b05485932d2a Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 28 Jan 2016 14:39:39 +0200 Subject: [PATCH 170/182] Story#109590460 - fix --- app/models/epp/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 3526cd463..54806b88d 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -165,7 +165,7 @@ class Epp::Contact < Contact org_priv = %w(org priv).freeze if ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.include?(ident_frame.attr('type')) at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_frame.attr('type')) - elsif ident_type == "birthday" && ident[/\A\d{4}-\d{2}-\d{2}\z/] && (Date.parse(ident) rescue false) + elsif ident_type == "birthday" && !ident[/\A\d{4}-\d{2}-\d{2}\z/] && (Date.parse(ident) rescue false) at.merge!(ident: ident_frame.text) at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? elsif ident_type.blank? && ident_country_code.blank? From 205b837121066c85c7e77cadc0dff9b83285a7ad Mon Sep 17 00:00:00 2001 From: Stas Date: Sat, 30 Jan 2016 15:32:14 +0200 Subject: [PATCH 171/182] 111237776-delete_update_prohibited_in_renew --- 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 15e16163a..596289bf1 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -590,6 +590,7 @@ class Epp::Domain < Domain statuses.delete(DomainStatus::SERVER_HOLD) statuses.delete(DomainStatus::EXPIRED) + statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED) save end From dd881c45684bf36d7af19bea1890d0ffc5fbe0d6 Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 1 Feb 2016 14:48:51 +0200 Subject: [PATCH 172/182] 111237776-condition_added --- app/models/epp/domain.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 596289bf1..3f32ce6d5 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -8,7 +8,7 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions return if is_admin # this bad hack for 109086524, refactor later - return true if is_transfer + return true if is_transfer || is_renewal return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false From 3e929a895c73818d6a0052ffe9ce4f4c17f9be58 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 3 Feb 2016 11:26:55 +0200 Subject: [PATCH 173/182] Story#112965483 - skip generating whoises for reserved and blocked domains if domain exists --- app/models/blocked_domain.rb | 2 ++ app/models/reserved_domain.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/models/blocked_domain.rb b/app/models/blocked_domain.rb index 079926512..9f2b62aee 100644 --- a/app/models/blocked_domain.rb +++ b/app/models/blocked_domain.rb @@ -19,6 +19,8 @@ class BlockedDomain < ActiveRecord::Base end def generate_data + next if Domain.where(name: name).any? + @json = generate_json @body = generate_body update_whois_server diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index d477f2524..4695b0bcd 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -30,6 +30,8 @@ class ReservedDomain < ActiveRecord::Base end def generate_data + next if Domain.where(name: name).any? + @json = generate_json @body = generate_body update_whois_server From 2fea2975f6c778071634b5103dffc1f6c13c1892 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 3 Feb 2016 11:35:26 +0200 Subject: [PATCH 174/182] Story#112965483 - skip removing whoises for reserved and blocked domains if domain exists --- app/models/blocked_domain.rb | 2 ++ app/models/reserved_domain.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/models/blocked_domain.rb b/app/models/blocked_domain.rb index 9f2b62aee..a52f80248 100644 --- a/app/models/blocked_domain.rb +++ b/app/models/blocked_domain.rb @@ -48,6 +48,8 @@ class BlockedDomain < ActiveRecord::Base end def remove_data + next if Domain.where(name: name).any? + Whois::Record.where(name: name).delete_all end end diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 4695b0bcd..070d9fca8 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -59,6 +59,8 @@ class ReservedDomain < ActiveRecord::Base end def remove_data + next if Domain.where(name: name).any? + Whois::Record.where(name: name).delete_all end From 54c86e15a32c14eb8a1bac70c264ca462efc4e7d Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 3 Feb 2016 12:20:42 +0200 Subject: [PATCH 175/182] Story#112965483 - we need to return from method, no iteration here --- app/models/blocked_domain.rb | 4 ++-- app/models/reserved_domain.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/blocked_domain.rb b/app/models/blocked_domain.rb index a52f80248..f5ca0371c 100644 --- a/app/models/blocked_domain.rb +++ b/app/models/blocked_domain.rb @@ -19,7 +19,7 @@ class BlockedDomain < ActiveRecord::Base end def generate_data - next if Domain.where(name: name).any? + return if Domain.where(name: name).any? @json = generate_json @body = generate_body @@ -48,7 +48,7 @@ class BlockedDomain < ActiveRecord::Base end def remove_data - next if Domain.where(name: name).any? + return if Domain.where(name: name).any? Whois::Record.where(name: name).delete_all end diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 070d9fca8..c5d0cf9f2 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -30,7 +30,7 @@ class ReservedDomain < ActiveRecord::Base end def generate_data - next if Domain.where(name: name).any? + return if Domain.where(name: name).any? @json = generate_json @body = generate_body @@ -59,7 +59,7 @@ class ReservedDomain < ActiveRecord::Base end def remove_data - next if Domain.where(name: name).any? + return if Domain.where(name: name).any? Whois::Record.where(name: name).delete_all end From 2ab5d8500a75b755de77037cd0c3fa574df168de Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 3 Feb 2016 15:55:39 +0200 Subject: [PATCH 176/182] 111396946-views_methods --- .../admin/blocked_domains_controller.rb | 46 +++++++++--- .../admin/reserved_domains_controller.rb | 47 +++++++++++- app/models/reserved_domain.rb | 7 +- app/views/admin/blocked_domains/_form.haml | 17 +++++ app/views/admin/blocked_domains/edit.haml | 3 + app/views/admin/blocked_domains/index.haml | 73 +++++++++++++++++-- app/views/admin/blocked_domains/new.haml | 3 + app/views/admin/reserved_domains/_form.haml | 3 +- app/views/admin/reserved_domains/edit.haml | 3 + app/views/admin/reserved_domains/index.haml | 4 +- app/views/admin/reserved_domains/new.haml | 2 +- config/locales/en.yml | 3 + config/routes.rb | 12 ++- 13 files changed, 194 insertions(+), 29 deletions(-) create mode 100644 app/views/admin/blocked_domains/_form.haml create mode 100644 app/views/admin/blocked_domains/edit.haml create mode 100644 app/views/admin/blocked_domains/new.haml create mode 100644 app/views/admin/reserved_domains/edit.haml diff --git a/app/controllers/admin/blocked_domains_controller.rb b/app/controllers/admin/blocked_domains_controller.rb index 2df3f90d9..c30b2dfb8 100644 --- a/app/controllers/admin/blocked_domains_controller.rb +++ b/app/controllers/admin/blocked_domains_controller.rb @@ -2,22 +2,46 @@ class Admin::BlockedDomainsController < AdminController load_and_authorize_resource def index - bd = BlockedDomain.first_or_initialize - @blocked_domains = bd.names.join("\n") + + params[:q] ||= {} + domains = BlockedDomain.all + @q = domains.search(params[:q]) + @domains = @q.result.page(params[:page]) + @domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 + + end + + def new + + @domain = BlockedDomain.new + end def create - names = params[:blocked_domains].split("\r\n").map(&:strip) - bd = BlockedDomain.first_or_create + abort - if bd.update(names: names) - flash[:notice] = I18n.t('record_updated') - redirect_to :back + end + + def delete + + if BlockedDomain.find(params[:id]).destroy + flash[:notice] = I18n.t('domain_deleted') + redirect_to admin_blocked_domains_path else - @blocked_domains = params[:blocked_domains] - flash.now[:alert] = I18n.t('failed_to_update_record') - render :index + flash.now[:alert] = I18n.t('failed_to_delete_domain') + redirect_to admin_blocked_domains_path end end -end + + + def blocked_params + params.require(:blocked_domain).permit(:name) + end + + private + + def set_domain + @domain = BlockedDomain.find(params[:id]) + end +end \ No newline at end of file diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb index 4cb7ba51f..b0af2fb9f 100644 --- a/app/controllers/admin/reserved_domains_controller.rb +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -1,5 +1,6 @@ class Admin::ReservedDomainsController < AdminController load_and_authorize_resource + before_action :set_domain, only: [:edit, :update] def index @@ -16,10 +17,52 @@ class Admin::ReservedDomainsController < AdminController end def edit - authorize! :update, ReservedDomain + end + + def create + + @domain = ReservedDomain.new(reserved_params) + + if @domain.save + flash[:notice] = I18n.t('domain_added') + redirect_to admin_reserved_domains_path + else + flash.now[:alert] = I18n.t('failed_to_add_domain') + render 'new' + end + + end + + def update + + if @domain.update(reserved_params) + flash[:notice] = I18n.t('domain_updated') + else + flash.now[:alert] = I18n.t('failed_to_update_domain') + end + render 'edit' + end def delete - authorize! :delete, ReservedDomain + + if ReservedDomain.find(params[:id]).destroy + flash[:notice] = I18n.t('domain_deleted') + redirect_to admin_reserved_domains_path + else + flash.now[:alert] = I18n.t('failed_to_delete_domain') + redirect_to admin_reserved_domains_path + end + + end + + private + + def reserved_params + params.require(:reserved_domain).permit(:name, :password) + end + + def set_domain + @domain = ReservedDomain.find(params[:id]) end end diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 141fd7263..e141ab7ee 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -22,7 +22,12 @@ class ReservedDomain < ActiveRecord::Base def fill_empty_passwords - self.password = SecureRandom.hex unless self.password + + if self.password.empty? + + self.password = SecureRandom.hex + + end end def name= val diff --git a/app/views/admin/blocked_domains/_form.haml b/app/views/admin/blocked_domains/_form.haml new file mode 100644 index 000000000..996d52843 --- /dev/null +++ b/app/views/admin/blocked_domains/_form.haml @@ -0,0 +1,17 @@ += form_for([:admin, @domain], html: {class: 'form-horizontal'}) do |f| + = render 'shared/full_errors', object: @domain + + .row + .col-md-8 + .panel.panel-default + .panel-heading.clearfix + .pull-left= t(:general) + .panel-body + .form-group + .col-md-4.control-label + = f.label :name + .col-md-7 + = f.text_field(:name, class: 'form-control') + .row + .col-md-8.text-right + = button_tag(t(:save), class: 'btn btn-primary') diff --git a/app/views/admin/blocked_domains/edit.haml b/app/views/admin/blocked_domains/edit.haml new file mode 100644 index 000000000..51d77f0cc --- /dev/null +++ b/app/views/admin/blocked_domains/edit.haml @@ -0,0 +1,3 @@ += render 'shared/title', name: t(:edit_pw) + += render 'form' diff --git a/app/views/admin/blocked_domains/index.haml b/app/views/admin/blocked_domains/index.haml index bd5660193..5accae030 100644 --- a/app/views/admin/blocked_domains/index.haml +++ b/app/views/admin/blocked_domains/index.haml @@ -1,10 +1,67 @@ +- content_for :actions do + = link_to(t(:new), new_admin_blocked_domain_path, class: 'btn btn-primary') = render 'shared/title', name: t(:blocked_domains) -= form_tag([:admin, :blocked_domains]) do |f| - .row - .col-md-12 - = text_area_tag :blocked_domains, @blocked_domains, class: 'form-control', rows: 30 - %hr - .row - .col-md-12.text-right - %button.btn.btn-warning=t(:save) +.row + .col-md-12 + = search_form_for [:admin, @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(: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) + .row + .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) +%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') + %th{class: 'col-xs-2'} + = sort_link(@q, 'created_at', t(:created_at)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'updated_at', t(:updated_at)) + %th{class: 'col-xs-2'} + = t(:actions) + %tbody + - @domains.each do |x| + %tr + %td= x.name + %td= l(x.created_at, format: :short) + %td= l(x.updated_at, format: :short) + %td + = link_to(t(:delete), delete_admin_blocked_domain_path(id: x.id), + data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger btn-xs') +.row + .col-md-6 + = paginate @domains + .col-md-6.text-right + .pagination + = t(:result_count, count: @domains.total_count) + +:coffee + $(".js-reset-form").on "click", (e) -> + e.preventDefault(); + window.location = "#{admin_blocked_domains_path}" diff --git a/app/views/admin/blocked_domains/new.haml b/app/views/admin/blocked_domains/new.haml new file mode 100644 index 000000000..4461eea40 --- /dev/null +++ b/app/views/admin/blocked_domains/new.haml @@ -0,0 +1,3 @@ += render 'shared/title', name: t(:add_blocked_domain) + += render 'form' diff --git a/app/views/admin/reserved_domains/_form.haml b/app/views/admin/reserved_domains/_form.haml index bfbacbfd9..2ba2431e9 100644 --- a/app/views/admin/reserved_domains/_form.haml +++ b/app/views/admin/reserved_domains/_form.haml @@ -11,13 +11,12 @@ .col-md-4.control-label = f.label :name .col-md-7 - = f.text_field(:name, class: 'form-control') + = f.text_field(:name, class: 'form-control', disabled: !f.object.new_record?) .form-group .col-md-4.control-label = f.label :password .col-md-7 = f.text_field(:password, class: 'form-control') -%hr .row .col-md-8.text-right = button_tag(t(:save), class: 'btn btn-primary') diff --git a/app/views/admin/reserved_domains/edit.haml b/app/views/admin/reserved_domains/edit.haml new file mode 100644 index 000000000..51d77f0cc --- /dev/null +++ b/app/views/admin/reserved_domains/edit.haml @@ -0,0 +1,3 @@ += render 'shared/title', name: t(:edit_pw) + += render 'form' diff --git a/app/views/admin/reserved_domains/index.haml b/app/views/admin/reserved_domains/index.haml index 6ac65d14b..06825b624 100644 --- a/app/views/admin/reserved_domains/index.haml +++ b/app/views/admin/reserved_domains/index.haml @@ -55,10 +55,10 @@ %td= l(x.created_at, format: :short) %td= l(x.updated_at, format: :short) %td - = link_to(t(:edit), edit_admin_reserved_domain_path(id: x.id), + = link_to(t(:edit_pw), edit_admin_reserved_domain_path(id: x.id), class: 'btn btn-primary btn-xs') = link_to(t(:delete), delete_admin_reserved_domain_path(id: x.id), - class: 'btn btn-primary btn-xs') + data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger btn-xs') .row .col-md-6 = paginate @domains diff --git a/app/views/admin/reserved_domains/new.haml b/app/views/admin/reserved_domains/new.haml index 937fdebde..cd6e189f9 100644 --- a/app/views/admin/reserved_domains/new.haml +++ b/app/views/admin/reserved_domains/new.haml @@ -1,3 +1,3 @@ -= render 'shared/title', name: t(:new_reserved_domain) += render 'shared/title', name: t(:add_reserved_domain) = render 'form' diff --git a/config/locales/en.yml b/config/locales/en.yml index 2cc8b1387..bad2571e2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -930,3 +930,6 @@ en: if_auth_info_is_left_empty_it_will_be_auto_generated: 'If auth info is left empty, it will be auto generated.' each_domain_name_must_end_with_colon_sign: 'Each domain name must end with colon (:) sign.' expiration_remind_subject: 'The %{name} domain has expired' + add_reserved_domain: 'Add domain to reserved list' + add_blocked_domain: 'Add domain to blocked list' + edit_pw: 'Edit Pw' \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 9dd7faf7d..86bdccaa9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -204,8 +204,16 @@ Rails.application.routes.draw do resources :settings - resources :blocked_domains - resources :reserved_domains + resources :blocked_domains do + member do + get 'delete' + end + end + resources :reserved_domains do + member do + get 'delete' + end + end resources :registrars do resources :api_users From f31db65d2cd6562a671d7abe275d530a81e53b36 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 3 Feb 2016 17:17:38 +0200 Subject: [PATCH 177/182] 111396946-validates --- app/controllers/admin/blocked_domains_controller.rb | 12 ++++++++++-- app/controllers/admin/reserved_domains_controller.rb | 6 +++--- app/models/blocked_domain.rb | 1 + app/models/reserved_domain.rb | 3 +++ app/views/admin/reserved_domains/_form.haml | 2 +- config/locales/en.yml | 3 ++- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/controllers/admin/blocked_domains_controller.rb b/app/controllers/admin/blocked_domains_controller.rb index c30b2dfb8..a21e01fd1 100644 --- a/app/controllers/admin/blocked_domains_controller.rb +++ b/app/controllers/admin/blocked_domains_controller.rb @@ -19,7 +19,15 @@ class Admin::BlockedDomainsController < AdminController def create - abort + @domain = BlockedDomain.new(blocked_domain_params) + + if @domain.save + flash[:notice] = I18n.t('domain_added') + redirect_to admin_blocked_domains_path + else + flash.now[:alert] = I18n.t('failed_to_add_domain') + render 'new' + end end @@ -35,7 +43,7 @@ class Admin::BlockedDomainsController < AdminController end - def blocked_params + def blocked_domain_params params.require(:blocked_domain).permit(:name) end diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb index b0af2fb9f..319a6275c 100644 --- a/app/controllers/admin/reserved_domains_controller.rb +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -21,7 +21,7 @@ class Admin::ReservedDomainsController < AdminController def create - @domain = ReservedDomain.new(reserved_params) + @domain = ReservedDomain.new(reserved_domain_params) if @domain.save flash[:notice] = I18n.t('domain_added') @@ -35,7 +35,7 @@ class Admin::ReservedDomainsController < AdminController def update - if @domain.update(reserved_params) + if @domain.update(reserved_domain_params) flash[:notice] = I18n.t('domain_updated') else flash.now[:alert] = I18n.t('failed_to_update_domain') @@ -58,7 +58,7 @@ class Admin::ReservedDomainsController < AdminController private - def reserved_params + def reserved_domain_params params.require(:reserved_domain).permit(:name, :password) end diff --git a/app/models/blocked_domain.rb b/app/models/blocked_domain.rb index 2a646a74f..e433aae85 100644 --- a/app/models/blocked_domain.rb +++ b/app/models/blocked_domain.rb @@ -1,5 +1,6 @@ class BlockedDomain < ActiveRecord::Base include Versions +validates :name, domain_name: true, uniqueness: true after_initialize -> { self.names = [] if names.nil? } end diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index e141ab7ee..718d90bcf 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -3,6 +3,9 @@ class ReservedDomain < ActiveRecord::Base before_save :fill_empty_passwords before_save :generate_data before_destroy :remove_data + validates :name, domain_name: true, uniqueness: true + + class << self diff --git a/app/views/admin/reserved_domains/_form.haml b/app/views/admin/reserved_domains/_form.haml index 2ba2431e9..ec7492659 100644 --- a/app/views/admin/reserved_domains/_form.haml +++ b/app/views/admin/reserved_domains/_form.haml @@ -16,7 +16,7 @@ .col-md-4.control-label = f.label :password .col-md-7 - = f.text_field(:password, class: 'form-control') + = f.text_field(:password, placeholder: t(:optional), class: 'form-control') .row .col-md-8.text-right = button_tag(t(:save), class: 'btn btn-primary') diff --git a/config/locales/en.yml b/config/locales/en.yml index bad2571e2..2e36ec69d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -932,4 +932,5 @@ en: expiration_remind_subject: 'The %{name} domain has expired' add_reserved_domain: 'Add domain to reserved list' add_blocked_domain: 'Add domain to blocked list' - edit_pw: 'Edit Pw' \ No newline at end of file + edit_pw: 'Edit Pw' + optional: 'Optional' \ No newline at end of file From 0ce6b84ddffa9063e78c17eb137324f28ee76fe6 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 4 Feb 2016 15:54:58 +0200 Subject: [PATCH 178/182] Story#112050051 - fix invoice sorting in admin --- app/controllers/admin/invoices_controller.rb | 2 +- app/views/admin/invoices/index.haml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/invoices_controller.rb b/app/controllers/admin/invoices_controller.rb index 5aa6d4438..709dc866a 100644 --- a/app/controllers/admin/invoices_controller.rb +++ b/app/controllers/admin/invoices_controller.rb @@ -23,7 +23,7 @@ class Admin::InvoicesController < AdminController def index @q = Invoice.includes(:account_activity).search(params[:q]) - @q.sorts = 'id desc' if @q.sorts.empty? + @q.sorts = 'number desc' if @q.sorts.empty? @invoices = @q.result.page(params[:page]) end diff --git a/app/views/admin/invoices/index.haml b/app/views/admin/invoices/index.haml index 75b6285a4..f2954f927 100644 --- a/app/views/admin/invoices/index.haml +++ b/app/views/admin/invoices/index.haml @@ -8,13 +8,13 @@ %thead %tr %th{class: 'col-xs-3'} - = sort_link(@q, 'invoice') + = sort_link(@q, :number) %th{class: 'col-xs-3'} - = sort_link(@q, 'buyer') + = sort_link(@q, :buyer_name, "Buyer") %th{class: 'col-xs-3'} - = sort_link(@q, 'due_date') + = sort_link(@q, :due_date) %th{class: 'col-xs-3'} - = sort_link(@q, 'receipt_date') + = sort_link(@q, :account_activity_created_at, "Receipt date") %tbody - @invoices.each do |x| %tr From db819447c6829158ee773f1468f64756686a7391 Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 4 Feb 2016 17:24:26 +0200 Subject: [PATCH 179/182] 111396946-order_and_style_changes --- app/controllers/admin/blocked_domains_controller.rb | 2 +- app/controllers/admin/reserved_domains_controller.rb | 2 +- app/views/admin/blocked_domains/index.haml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/blocked_domains_controller.rb b/app/controllers/admin/blocked_domains_controller.rb index a21e01fd1..49cc65675 100644 --- a/app/controllers/admin/blocked_domains_controller.rb +++ b/app/controllers/admin/blocked_domains_controller.rb @@ -4,7 +4,7 @@ class Admin::BlockedDomainsController < AdminController def index params[:q] ||= {} - domains = BlockedDomain.all + domains = BlockedDomain.all.order(:name) @q = domains.search(params[:q]) @domains = @q.result.page(params[:page]) @domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb index 319a6275c..7de8d9891 100644 --- a/app/controllers/admin/reserved_domains_controller.rb +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -5,7 +5,7 @@ class Admin::ReservedDomainsController < AdminController def index params[:q] ||= {} - domains = ReservedDomain.all + domains = ReservedDomain.all.order(:name) @q = domains.search(params[:q]) @domains = @q.result.page(params[:page]) @domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 diff --git a/app/views/admin/blocked_domains/index.haml b/app/views/admin/blocked_domains/index.haml index 5accae030..ab5f79bc7 100644 --- a/app/views/admin/blocked_domains/index.haml +++ b/app/views/admin/blocked_domains/index.haml @@ -43,7 +43,7 @@ = sort_link(@q, 'created_at', t(:created_at)) %th{class: 'col-xs-2'} = sort_link(@q, 'updated_at', t(:updated_at)) - %th{class: 'col-xs-2'} + %th{class: 'col-xs-1'} = t(:actions) %tbody - @domains.each do |x| @@ -51,9 +51,9 @@ %td= x.name %td= l(x.created_at, format: :short) %td= l(x.updated_at, format: :short) - %td + %td{class: 'col-xs-1'} = link_to(t(:delete), delete_admin_blocked_domain_path(id: x.id), - data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger btn-xs') + data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger btn-xs center-block') .row .col-md-6 = paginate @domains From 6984bb9baed74f41b3887daba92e7acaf18cb283 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 4 Feb 2016 17:53:54 +0200 Subject: [PATCH 180/182] Story#112993395 - in reserved domains we are using columns, not hash --- 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 d0f8d6260..9da57e27a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -93,7 +93,7 @@ class Domain < ActiveRecord::Base def update_reserved_domains return unless in_reserved_list? rd = ReservedDomain.by_domain(name).first - rd.names[name] = SecureRandom.hex + rd.password = SecureRandom.hex rd.save end From 2650ca1922f77ebba9af91e3d622df3cd9855e78 Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 4 Feb 2016 17:59:48 +0200 Subject: [PATCH 181/182] 111396946-style_change --- app/views/admin/blocked_domains/index.haml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/admin/blocked_domains/index.haml b/app/views/admin/blocked_domains/index.haml index ab5f79bc7..5f6ac69d0 100644 --- a/app/views/admin/blocked_domains/index.haml +++ b/app/views/admin/blocked_domains/index.haml @@ -51,9 +51,10 @@ %td= x.name %td= l(x.created_at, format: :short) %td= l(x.updated_at, format: :short) - %td{class: 'col-xs-1'} - = link_to(t(:delete), delete_admin_blocked_domain_path(id: x.id), - data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger btn-xs center-block') + %td + %div{class: 'text-center'} + = link_to(t(:delete), delete_admin_blocked_domain_path(id: x.id), + data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger btn-xs') .row .col-md-6 = paginate @domains From db6f78ede42a4513f661f5b6a16881faf7b15b3c Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 8 Feb 2016 10:36:22 +0200 Subject: [PATCH 182/182] Story#112050051 - extend ransack to sort invoices by custom scopes --- app/models/invoice.rb | 12 +++++++++ app/views/admin/invoices/index.haml | 4 +-- config/initializers/eis_ransack.rb | 40 +++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 config/initializers/eis_ransack.rb diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 5c7dafe85..425202a4c 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -11,6 +11,18 @@ class Invoice < ActiveRecord::Base scope :unbinded, lambda { where('id NOT IN (SELECT invoice_id FROM account_activities where invoice_id IS NOT NULL)') } + scope :all_columns, ->{select("invoices.*")} + scope :sort_due_date_column, ->{all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN + (invoices.cancelled_at + interval '100 year') ELSE + invoices.due_date END AS sort_due_date")} + scope :sort_by_sort_due_date_asc, ->{sort_due_date_column.order("sort_due_date ASC")} + scope :sort_by_sort_due_date_desc, ->{sort_due_date_column.order("sort_due_date DESC")} + scope :sort_receipt_date_column, ->{all_columns.includes(:account_activity).references(:account_activity).select(%Q{ + CASE WHEN account_activities.created_at is not null THEN account_activities.created_at + WHEN invoices.cancelled_at is not null THEN invoices.cancelled_at + interval '100 year' + ELSE NULL END AS sort_receipt_date })} + scope :sort_by_sort_receipt_date_asc, ->{sort_receipt_date_column.order("sort_receipt_date ASC")} + scope :sort_by_sort_receipt_date_desc, ->{sort_receipt_date_column.order("sort_receipt_date DESC")} attr_accessor :billing_email validates :billing_email, email_format: { message: :invalid }, allow_blank: true diff --git a/app/views/admin/invoices/index.haml b/app/views/admin/invoices/index.haml index f2954f927..4b34dba94 100644 --- a/app/views/admin/invoices/index.haml +++ b/app/views/admin/invoices/index.haml @@ -12,9 +12,9 @@ %th{class: 'col-xs-3'} = sort_link(@q, :buyer_name, "Buyer") %th{class: 'col-xs-3'} - = sort_link(@q, :due_date) + = sort_link(@q, :sort_due_date, "Due date") %th{class: 'col-xs-3'} - = sort_link(@q, :account_activity_created_at, "Receipt date") + = sort_link(@q, :sort_receipt_date, "Receipt date") %tbody - @invoices.each do |x| %tr diff --git a/config/initializers/eis_ransack.rb b/config/initializers/eis_ransack.rb new file mode 100644 index 000000000..c23791ef7 --- /dev/null +++ b/config/initializers/eis_ransack.rb @@ -0,0 +1,40 @@ +# A custom initializer that enables sorting via custom scopes in Ransack (like the same feature in MetaSearch) + +module Ransack + module Adapters + module ActiveRecord + class Context < ::Ransack::Context + + # Allows for sorting by custom scopes + # + # + # Define your custom scopes in your model, e. g. sort_by_title_asc and sort_by_title_desc + # (The scopes would sort by some calculated column or a column added via some crazy join, etc.) + # + # In your sort links refer to the scopes like to standard fields, e. g. + # <%= sort_link(@q, :title, 'Crazy calculated title') %> + def evaluate(search, opts = {}) + viz = Visitor.new + relation = @object.where(viz.accept(search.base)) + if search.sorts.any? + custom_scopes = search.sorts.select do |s| + custom_scope_name = :"sort_by_#{s.name}_#{s.dir}" + relation.respond_to?(custom_scope_name) + end + attribute_scopes = search.sorts - custom_scopes + + relation = relation.except(:order) + + custom_scopes.each do |s| + custom_scope_name = :"sort_by_#{s.name}_#{s.dir}" + relation = relation.public_send(custom_scope_name) + end + + relation = relation.reorder(viz.accept(attribute_scopes)) if attribute_scopes.any? + end + opts[:distinct] ? relation.distinct : relation + end + end + end + end +end \ No newline at end of file