From 9cf287b35c2e6e270991ec4f00d4a1b641b3a8a7 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Tue, 17 Nov 2015 17:48:11 +0200 Subject: [PATCH 1/6] Story #104525314 - fix missing error message on probibited change admin/tech contact --- app/models/epp/domain.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index f59df6ddc..2b273f93a 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -236,7 +236,7 @@ class Epp::Domain < Domain def admin_domain_contacts_attrs(frame, action) admin_attrs = domain_contact_attrs_from(frame, action, 'admin') - if action && !admin_attrs.empty? && admin_change_prohibited? + if admin_attrs.present? && admin_change_prohibited? add_epp_error('2304', 'admin', DomainStatus::SERVER_ADMIN_CHANGE_PROHIBITED, I18n.t(:object_status_prohibits_operation)) return [] end @@ -252,7 +252,7 @@ class Epp::Domain < Domain def tech_domain_contacts_attrs(frame, action) tech_attrs = domain_contact_attrs_from(frame, action, 'tech') - if action && !tech_attrs.empty? && tech_change_prohibited? + if tech_attrs.present? && tech_change_prohibited? add_epp_error('2304', 'tech', DomainStatus::SERVER_TECH_CHANGE_PROHIBITED, I18n.t(:object_status_prohibits_operation)) return [] end @@ -439,7 +439,7 @@ class Epp::Domain < Domain at.deep_merge!(attrs_from(frame.css('chg'), current_user, 'chg')) at.deep_merge!(attrs_from(frame.css('rem'), current_user, 'rem')) - at_add = attrs_from(frame.css('add'), current_user) + at_add = attrs_from(frame.css('add'), current_user, 'add') at[:nameservers_attributes] += at_add[:nameservers_attributes] if !at[:admin_domain_contacts_attributes].empty? && admin_change_prohibited? From afbddad42fc9aeb48c44fa3fb76b286104ce9d67 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Tue, 17 Nov 2015 17:48:28 +0200 Subject: [PATCH 2/6] Story #104525314 - avoid reporting no errors when error raised --- app/controllers/epp/domains_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index 57136be63..db47570d2 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -68,8 +68,12 @@ class Epp::DomainsController < EppController else handle_errors(@domain) end - rescue - handle_errors(@domain) + rescue => e + if @domain.errors.any? + handle_errors(@domain) + else + throw e + end end end From 5b325882f1ff6d6cba501549296dcebd4a6072a4 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 18 Nov 2015 10:01:52 +0200 Subject: [PATCH 3/6] Story #104525314 - remove reject/accept button from pendingDelete, allow only for pending...Confirmation --- app/views/admin/domains/form/_pending_delete.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/domains/form/_pending_delete.haml b/app/views/admin/domains/form/_pending_delete.haml index 2e199d0b7..e3d71f3f4 100644 --- a/app/views/admin/domains/form/_pending_delete.haml +++ b/app/views/admin/domains/form/_pending_delete.haml @@ -1,4 +1,4 @@ -- if (status == DomainStatus::PENDING_DELETE || status == DomainStatus::PENDING_DELETE_CONFIRMATION) +- if status == DomainStatus::PENDING_DELETE_CONFIRMATION = link_to(t(:accept_delete), admin_domain_pending_delete_path(f.object.id, f.object.id), method: :patch, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger btn-xs') From df3f91f4825b0735d4e99f0b4b4c73b08f8ac713 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 18 Nov 2015 10:28:23 +0200 Subject: [PATCH 4/6] Story #104525314 - clean up, finishes prior commit 9cf287b35c2e6e270991ec4f00d4a1b641b3a8a7 --- app/models/epp/domain.rb | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 2b273f93a..feafb36a7 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -441,19 +441,8 @@ class Epp::Domain < Domain at_add = attrs_from(frame.css('add'), current_user, 'add') at[:nameservers_attributes] += at_add[:nameservers_attributes] - - if !at[:admin_domain_contacts_attributes].empty? && admin_change_prohibited? - add_epp_error('2304', 'admin', DomainStatus::SERVER_ADMIN_CHANGE_PROHIBITED, I18n.t(:object_status_prohibits_operation)) - else - at[:admin_domain_contacts_attributes] += at_add[:admin_domain_contacts_attributes] - end - - if !at[:tech_domain_contacts_attributes].empty? && tech_change_prohibited? - add_epp_error('2304', 'tech', DomainStatus::SERVER_TECH_CHANGE_PROHIBITED, I18n.t(:object_status_prohibits_operation)) - else - at[:tech_domain_contacts_attributes] += at_add[:tech_domain_contacts_attributes] - end - + at[:admin_domain_contacts_attributes] += at_add[:admin_domain_contacts_attributes] + at[:tech_domain_contacts_attributes] += at_add[:tech_domain_contacts_attributes] at[:dnskeys_attributes] += at_add[:dnskeys_attributes] at[:statuses] = statuses - domain_statuses_attrs(frame.css('rem'), 'rem') + domain_statuses_attrs(frame.css('add'), 'add') From 69f0f8af1227a85ae6d609723309a95821b1b10d Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 18 Nov 2015 12:42:04 +0200 Subject: [PATCH 5/6] Story #104525314 - bug fix, now pendingDeleteConfirmation must transit to pendingDelete, or cancel pending --- app/jobs/domain_delete_confirm_job.rb | 4 +--- app/models/domain.rb | 6 ++++++ app/models/epp/domain.rb | 5 ++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/jobs/domain_delete_confirm_job.rb b/app/jobs/domain_delete_confirm_job.rb index 7d890ef16..785483cad 100644 --- a/app/jobs/domain_delete_confirm_job.rb +++ b/app/jobs/domain_delete_confirm_job.rb @@ -7,12 +7,10 @@ class DomainDeleteConfirmJob < Que::Job when RegistrantVerification::CONFIRMED domain.poll_message!(:poll_pending_delete_confirmed_by_registrant) domain.apply_pending_delete! - domain.clean_pendings! when RegistrantVerification::REJECTED DomainMailer.pending_delete_rejected_notification(domain).deliver_now - domain.statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) domain.poll_message!(:poll_pending_delete_rejected_by_registrant) - domain.clean_pendings! + domain.cancel_pending_delete 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 5580cb837..3ce220733 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -492,6 +492,12 @@ class Domain < ActiveRecord::Base DomainMailer.pending_deleted(self).deliver_now end + def cancel_pending_delete + statuses.delete DomainStatus::PENDING_DELETE_CONFIRMATION + statuses.delete DomainStatus::PENDING_DELETE + delete_at = nil + end + def pricelist(operation, period_i = nil, unit = nil) period_i ||= period unit ||= period_unit diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index feafb36a7..614bf5963 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -483,9 +483,8 @@ class Epp::Domain < Domain statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) statuses.delete(DomainStatus::PENDING_DELETE) DomainMailer.delete_confirmation(self).deliver_now - - # TODO: confirm that this actually makes sense - clean_pendings! if valid? && set_pending_delete! + clean_pendings! + set_pending_delete! true end From 6c559b8c254903bc53de1eaffb0c3a0113c181fe Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 19 Nov 2015 10:19:29 +0200 Subject: [PATCH 6/6] Story #104525314 - allow admin to remove pendingDelete and clear delete_at --- app/controllers/admin/domains_controller.rb | 1 + app/models/domain.rb | 31 +++++++++++++++------ app/models/domain_status.rb | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 562505dc1..377912bad 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -47,6 +47,7 @@ class Admin::DomainsController < AdminController def update dp = ignore_empty_statuses @domain.is_admin = true + @domain.admin_status_update dp[:statuses] if @domain.update(dp) flash[:notice] = I18n.t('domain_updated') diff --git a/app/models/domain.rb b/app/models/domain.rb index 3ce220733..493fc14ac 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -495,7 +495,7 @@ class Domain < ActiveRecord::Base def cancel_pending_delete statuses.delete DomainStatus::PENDING_DELETE_CONFIRMATION statuses.delete DomainStatus::PENDING_DELETE - delete_at = nil + self.delete_at = nil end def pricelist(operation, period_i = nil, unit = nil) @@ -679,16 +679,31 @@ class Domain < ActiveRecord::Base statuses.include?(DomainStatus::FORCE_DELETE) end + # special handling for admin changing status + def admin_status_update(update) + # check for deleted status + statuses.each do |s| + unless update.includes? s + case s + when DomainStatus::PENDING_DELETE + self.delete_at = nil + # Handle any other special remove cases? + # when DomainStatus::FORCE_DELETE unset_force_delete + end + end + end + end + def pending_update_prohibited? (statuses_was & [ DomainStatus::PENDING_DELETE_CONFIRMATION, - DomainStatus::CLIENT_UPDATE_PROHIBITED, - DomainStatus::SERVER_UPDATE_PROHIBITED, - DomainStatus::PENDING_CREATE, - DomainStatus::PENDING_UPDATE, - DomainStatus::PENDING_DELETE, - DomainStatus::PENDING_RENEW, - DomainStatus::PENDING_TRANSFER + DomainStatus::CLIENT_UPDATE_PROHIBITED, + DomainStatus::SERVER_UPDATE_PROHIBITED, + DomainStatus::PENDING_CREATE, + DomainStatus::PENDING_UPDATE, + DomainStatus::PENDING_DELETE, + DomainStatus::PENDING_RENEW, + DomainStatus::PENDING_TRANSFER ]).present? end diff --git a/app/models/domain_status.rb b/app/models/domain_status.rb index 543ba0ff4..c784a86e3 100644 --- a/app/models/domain_status.rb +++ b/app/models/domain_status.rb @@ -148,7 +148,7 @@ class DomainStatus < ActiveRecord::Base INACTIVE, FORCE_DELETE, PENDING_CREATE, - PENDING_DELETE, + #PENDING_DELETE, PENDING_RENEW, PENDING_TRANSFER, PENDING_UPDATE,