From d294105c59b8be35675c0a1af29dc40373a41e64 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 16 Jan 2017 01:36:38 +0200 Subject: [PATCH 01/28] Add "removed_company" template to delete domain mailer #268 --- .../{forced.html.erb => forced/removed_company.html.erb} | 0 .../{forced.text.erb => forced/removed_company.text.erb} | 0 .../removed_company.html.erb_spec.rb} | 4 ++-- .../{forced_shared.rb => forced/removed_company.rb} | 0 .../removed_company.text.erb_spec.rb} | 4 ++-- 5 files changed, 4 insertions(+), 4 deletions(-) rename app/views/mailers/domain_delete_mailer/{forced.html.erb => forced/removed_company.html.erb} (100%) rename app/views/mailers/domain_delete_mailer/{forced.text.erb => forced/removed_company.text.erb} (100%) rename spec/views/mailers/domain_delete_mailer/{forced.html.erb_spec.rb => forced/removed_company.html.erb_spec.rb} (76%) rename spec/views/mailers/domain_delete_mailer/{forced_shared.rb => forced/removed_company.rb} (100%) rename spec/views/mailers/domain_delete_mailer/{forced.text.erb_spec.rb => forced/removed_company.text.erb_spec.rb} (76%) diff --git a/app/views/mailers/domain_delete_mailer/forced.html.erb b/app/views/mailers/domain_delete_mailer/forced/removed_company.html.erb similarity index 100% rename from app/views/mailers/domain_delete_mailer/forced.html.erb rename to app/views/mailers/domain_delete_mailer/forced/removed_company.html.erb diff --git a/app/views/mailers/domain_delete_mailer/forced.text.erb b/app/views/mailers/domain_delete_mailer/forced/removed_company.text.erb similarity index 100% rename from app/views/mailers/domain_delete_mailer/forced.text.erb rename to app/views/mailers/domain_delete_mailer/forced/removed_company.text.erb diff --git a/spec/views/mailers/domain_delete_mailer/forced.html.erb_spec.rb b/spec/views/mailers/domain_delete_mailer/forced/removed_company.html.erb_spec.rb similarity index 76% rename from spec/views/mailers/domain_delete_mailer/forced.html.erb_spec.rb rename to spec/views/mailers/domain_delete_mailer/forced/removed_company.html.erb_spec.rb index 4f38b7743..5a92165b0 100644 --- a/spec/views/mailers/domain_delete_mailer/forced.html.erb_spec.rb +++ b/spec/views/mailers/domain_delete_mailer/forced/removed_company.html.erb_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -require_relative 'forced_shared' +require_relative 'removed_company' -RSpec.describe 'mailers/domain_delete_mailer/forced.html.erb' do +RSpec.describe 'mailers/domain_delete_mailer/forced/removed_company.html.erb' do before :example do stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian' stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english' diff --git a/spec/views/mailers/domain_delete_mailer/forced_shared.rb b/spec/views/mailers/domain_delete_mailer/forced/removed_company.rb similarity index 100% rename from spec/views/mailers/domain_delete_mailer/forced_shared.rb rename to spec/views/mailers/domain_delete_mailer/forced/removed_company.rb diff --git a/spec/views/mailers/domain_delete_mailer/forced.text.erb_spec.rb b/spec/views/mailers/domain_delete_mailer/forced/removed_company.text.erb_spec.rb similarity index 76% rename from spec/views/mailers/domain_delete_mailer/forced.text.erb_spec.rb rename to spec/views/mailers/domain_delete_mailer/forced/removed_company.text.erb_spec.rb index a53c5beca..ec527b0d7 100644 --- a/spec/views/mailers/domain_delete_mailer/forced.text.erb_spec.rb +++ b/spec/views/mailers/domain_delete_mailer/forced/removed_company.text.erb_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -require_relative 'forced_shared' +require_relative 'removed_company' -RSpec.describe 'mailers/domain_delete_mailer/forced.text.erb' do +RSpec.describe 'mailers/domain_delete_mailer/forced/removed_company.text.erb' do before :example do stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian' stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english' From 92c6279e462ab88d8ebb30a1712afe463d1fe694 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 17 Jan 2017 03:06:36 +0200 Subject: [PATCH 02/28] Use default layout path in admin area #268 --- app/controllers/admin/sessions_controller.rb | 1 - app/controllers/admin_controller.rb | 1 - app/views/admin/_menu.haml | 44 ++++++++++++++++++++ app/views/layouts/admin.haml | 36 ++++++++++++++++ app/views/layouts/devise.haml | 29 +++++++++++++ 5 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 app/views/admin/_menu.haml create mode 100644 app/views/layouts/admin.haml create mode 100644 app/views/layouts/devise.haml diff --git a/app/controllers/admin/sessions_controller.rb b/app/controllers/admin/sessions_controller.rb index 5dc244398..d907fe1f3 100644 --- a/app/controllers/admin/sessions_controller.rb +++ b/app/controllers/admin/sessions_controller.rb @@ -1,6 +1,5 @@ class Admin::SessionsController < Devise::SessionsController skip_authorization_check only: :create - layout 'admin/application' def login @admin_user = AdminUser.new diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 29b7be698..ec335ae65 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,5 +1,4 @@ class AdminController < ApplicationController - layout 'admin/application' before_action :authenticate_user! helper_method :head_title_sufix diff --git a/app/views/admin/_menu.haml b/app/views/admin/_menu.haml new file mode 100644 index 000000000..4077e58f2 --- /dev/null +++ b/app/views/admin/_menu.haml @@ -0,0 +1,44 @@ +.navbar-collapse.collapse + %ul.nav.navbar-nav + - if can? :show, Domain + %li= link_to t(:domains), admin_domains_path + - if can? :show, Contact + %li= link_to t(:contacts), admin_contacts_path + - if can? :show, Registrar + %li= link_to t(:registrars), admin_registrars_path + - if can? :show, Keyrelay + %li= link_to t(:keyrelays), admin_keyrelays_path + - if can?(:access, :settings_menu) + %li.dropdown + %a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"} + = t(:settings) + %span.caret + %ul.dropdown-menu{role: "menu"} + %li.dropdown-header= t(:users) + %li= link_to t(:api_users), admin_api_users_path + %li= link_to t(:admin_users), admin_admin_users_path + %li.divider + %li.dropdown-header= t(:billing) + - if can? :view, Pricelist + %li= link_to t(:pricelists), admin_pricelists_path + %li= link_to t(:bank_statements), admin_bank_statements_path + %li= link_to t(:invoices), admin_invoices_path + %li= link_to t(:account_activities), admin_account_activities_path(created_after: 'today') + %li.divider + %li.dropdown-header= t(:archive) + %li= link_to t(:domains_history), admin_domain_versions_path + %li= link_to t(:contacts_history), admin_contact_versions_path + %li.divider + %li.dropdown-header= t(:system) + %li= link_to t(:settings), admin_settings_path + %li= link_to t(:zonefile), admin_zonefile_settings_path + %li= link_to t(:blocked_domains), admin_blocked_domains_path + %li= link_to t(:reserved_domains), admin_reserved_domains_path + %li= link_to t(:mail_templates), admin_mail_templates_path + %li= link_to t(:epp_logs), admin_epp_logs_path(created_after: 'today') + %li= link_to t(:repp_logs), admin_repp_logs_path(created_after: 'today') + %li= link_to t(:que), '/admin/que' + + - if signed_in? + %ul.nav.navbar-nav.navbar-right + %li= link_to t(:log_out, user: current_user), '/admin/logout' diff --git a/app/views/layouts/admin.haml b/app/views/layouts/admin.haml new file mode 100644 index 000000000..70ee14cfc --- /dev/null +++ b/app/views/layouts/admin.haml @@ -0,0 +1,36 @@ +!!! 5 +%html{lang: I18n.locale.to_s} + %head + %meta{charset: "utf-8"}/ + %meta{content: "width=device-width, initial-scale=1", name: "viewport"}/ + - if content_for? :head_title + = yield :head_title + - else + %title= t(:admin_head_title) + = csrf_meta_tags + = stylesheet_link_tag 'admin-manifest', media: 'all', 'data-turbolinks-track' => true + = favicon_link_tag 'favicon.ico' + %body{:style => env_style} + .navbar.navbar-inverse.navbar-static-top{role: "navigation"} + .container + .navbar-header + %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} + %span.sr-only Toggle navigation + %span.icon-bar + %span.icon-bar + %span.icon-bar + = link_to admin_dashboard_path, class: 'navbar-brand' do + = ENV['app_name'] + - if unstable_env.present? + .text-center + %small{style: 'color: #0074B3;'}= unstable_env + + = render 'menu' + .container + = render 'shared/flash' + = yield + + .footer.text-right + Version + = CURRENT_COMMIT_HASH + = javascript_include_tag 'admin-manifest', async: true diff --git a/app/views/layouts/devise.haml b/app/views/layouts/devise.haml new file mode 100644 index 000000000..14534e374 --- /dev/null +++ b/app/views/layouts/devise.haml @@ -0,0 +1,29 @@ +!!! 5 +%html{lang: I18n.locale.to_s} + %head + %meta{charset: "utf-8"}/ + - if content_for? :head_title + = yield :head_title + - else + %title= t(:admin_head_title) + = csrf_meta_tags + = stylesheet_link_tag 'admin-manifest', media: 'all', 'data-turbolinks-track' => true + = favicon_link_tag 'favicon.ico' + %body{:style => env_style} + .navbar.navbar-inverse.navbar-static-top{role: "navigation"} + .container + .navbar-header + %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} + %span.sr-only Toggle navigation + %span.icon-bar + %span.icon-bar + %span.icon-bar + = link_to admin_dashboard_path, class: 'navbar-brand' do + = ENV['app_name'] + - if unstable_env.present? + .text-center + %small{style: 'color: #0074B3;'}= unstable_env + + .container + = render 'shared/flash' + = yield From 5c85314168b0cdd515644e43656a545c3159c019 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 17 Jan 2017 03:14:32 +0200 Subject: [PATCH 03/28] Disable asset debug in dev env #268 --- config/environments/development-example.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/development-example.rb b/config/environments/development-example.rb index f2e07435a..59efe01d9 100644 --- a/config/environments/development-example.rb +++ b/config/environments/development-example.rb @@ -24,7 +24,7 @@ Rails.application.configure do # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. - config.assets.debug = true + config.assets.debug = false # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. From fec7f82a96492ee615cf6b1402d21ffd3ff215a5 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 17 Jan 2017 03:17:48 +0200 Subject: [PATCH 04/28] Remove turbolinks, load js in async mode #268 --- app/assets/javascripts/admin-manifest.coffee | 1 - .../javascripts/admin/application.coffee | 87 +++++++++---------- app/views/layouts/admin.haml | 2 +- app/views/layouts/admin/application.haml | 85 ------------------ 4 files changed, 44 insertions(+), 131 deletions(-) delete mode 100644 app/views/layouts/admin/application.haml diff --git a/app/assets/javascripts/admin-manifest.coffee b/app/assets/javascripts/admin-manifest.coffee index 51bc5f419..c386c45e6 100644 --- a/app/assets/javascripts/admin-manifest.coffee +++ b/app/assets/javascripts/admin-manifest.coffee @@ -1,6 +1,5 @@ #= require jquery #= require jquery_ujs -#= require turbolinks #= require bootstrap-sprockets #= require typeahead.bundle.min #= require admin/autocomplete diff --git a/app/assets/javascripts/admin/application.coffee b/app/assets/javascripts/admin/application.coffee index 1b3335d63..6a6c30bec 100644 --- a/app/assets/javascripts/admin/application.coffee +++ b/app/assets/javascripts/admin/application.coffee @@ -1,53 +1,52 @@ -$(document).on 'page:change', -> - $('.selectize').selectize({ - allowEmptyOption: true - }) - $('.selectize_create').selectize({ - allowEmptyOption: true, create: true - }) +$('.selectize').selectize({ + allowEmptyOption: true +}) +$('.selectize_create').selectize({ + allowEmptyOption: true, create: true +}) - $('.js-datepicker').datepicker({ - showAnim: "", - autoclose: true, - dateFormat: "dd.mm.yy", - changeMonth: true, - changeYear: true - }) +$('.js-datepicker').datepicker({ + showAnim: "", + autoclose: true, + dateFormat: "dd.mm.yy", + changeMonth: true, + changeYear: true +}) - # client side validate all forms - $('form').each -> - $(this).validate() - - $('[data-toggle="popover"]').popover() +# client side validate all forms +$('form').each -> + $(this).validate() + +$('[data-toggle="popover"]').popover() - # doublescroll - $('[data-doublescroll]').doubleScroll({ - onlyIfScroll: false, - scrollCss: - 'overflow-x': 'auto' - 'overflow-y': 'hidden' - contentCss: - 'overflow-x': 'auto' - 'overflow-y': 'hidden' - resetOnWindowResize: true - }) +# doublescroll +$('[data-doublescroll]').doubleScroll({ + onlyIfScroll: false, + scrollCss: + 'overflow-x': 'auto' + 'overflow-y': 'hidden' + contentCss: + 'overflow-x': 'auto' + 'overflow-y': 'hidden' + resetOnWindowResize: true +}) - positionSlider = -> - for scroll in document.querySelectorAll('[data-doublescroll]') - wrapper = scroll.previousSibling - if $(scroll).offset().top < $(window).scrollTop() - wrapper.style.position = 'fixed' - wrapper.style.top = '-5px' - else - wrapper.style.position = 'relative' - wrapper.style.top = '0' - return +positionSlider = -> + for scroll in document.querySelectorAll('[data-doublescroll]') + wrapper = scroll.previousSibling + if $(scroll).offset().top < $(window).scrollTop() + wrapper.style.position = 'fixed' + wrapper.style.top = '-5px' + else + wrapper.style.position = 'relative' + wrapper.style.top = '0' + return - positionSlider() - $(window).scroll(positionSlider).resize positionSlider - #due .report-table width: auto top scrollbar appears after resize so we do fake resize action - $(window).resize() +positionSlider() +$(window).scroll(positionSlider).resize positionSlider +#due .report-table width: auto top scrollbar appears after resize so we do fake resize action +$(window).resize(); diff --git a/app/views/layouts/admin.haml b/app/views/layouts/admin.haml index 70ee14cfc..8e8e3230e 100644 --- a/app/views/layouts/admin.haml +++ b/app/views/layouts/admin.haml @@ -8,7 +8,7 @@ - else %title= t(:admin_head_title) = csrf_meta_tags - = stylesheet_link_tag 'admin-manifest', media: 'all', 'data-turbolinks-track' => true + = stylesheet_link_tag 'admin-manifest', media: 'all' = favicon_link_tag 'favicon.ico' %body{:style => env_style} .navbar.navbar-inverse.navbar-static-top{role: "navigation"} diff --git a/app/views/layouts/admin/application.haml b/app/views/layouts/admin/application.haml deleted file mode 100644 index 9937937e6..000000000 --- a/app/views/layouts/admin/application.haml +++ /dev/null @@ -1,85 +0,0 @@ -!!! 5 -%html{lang: I18n.locale.to_s} - %head - %meta{charset: "utf-8"}/ - %meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}/ - %meta{content: "width=device-width, initial-scale=1", name: "viewport"}/ - %meta{content: "Full stack top-level domain (TLD) management.", name: "description"}/ - %meta{content: "Gitlab LTD", name: "author"}/ - - if content_for? :head_title - = yield :head_title - - else - %title= t(:admin_head_title) - = csrf_meta_tags - = stylesheet_link_tag 'admin-manifest', media: 'all', 'data-turbolinks-track' => true - = javascript_include_tag 'admin-manifest', 'data-turbolinks-track' => true - = favicon_link_tag 'favicon.ico' - %body{:style => env_style} - / Static navbar - .navbar.navbar-inverse.navbar-static-top{role: "navigation"} - .container - .navbar-header - %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} - %span.sr-only Toggle navigation - %span.icon-bar - %span.icon-bar - %span.icon-bar - = link_to admin_dashboard_path, class: 'navbar-brand' do - = ENV['app_name'] - - if unstable_env.present? - .text-center - %small{style: 'color: #0074B3;'}= unstable_env - - .navbar-collapse.collapse - %ul.nav.navbar-nav - - if can? :show, Domain - %li= link_to t(:domains), admin_domains_path - - if can? :show, Contact - %li= link_to t(:contacts), admin_contacts_path - - if can? :show, Registrar - %li= link_to t(:registrars), admin_registrars_path - - if can? :show, Keyrelay - %li= link_to t(:keyrelays), admin_keyrelays_path - - if can?(:access, :settings_menu) - %li.dropdown - %a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"} - = t(:settings) - %span.caret - %ul.dropdown-menu{role: "menu"} - %li.dropdown-header= t(:users) - %li= link_to t(:api_users), admin_api_users_path - %li= link_to t(:admin_users), admin_admin_users_path - %li.divider - %li.dropdown-header= t(:billing) - - if can? :view, Pricelist - %li= link_to t(:pricelists), admin_pricelists_path - %li= link_to t(:bank_statements), admin_bank_statements_path - %li= link_to t(:invoices), admin_invoices_path - %li= link_to t(:account_activities), admin_account_activities_path(created_after: 'today') - %li.divider - %li.dropdown-header= t(:archive) - %li= link_to t(:domains_history), admin_domain_versions_path - %li= link_to t(:contacts_history), admin_contact_versions_path - %li.divider - %li.dropdown-header= t(:system) - %li= link_to t(:settings), admin_settings_path - %li= link_to t(:zonefile), admin_zonefile_settings_path - %li= link_to t(:blocked_domains), admin_blocked_domains_path - %li= link_to t(:reserved_domains), admin_reserved_domains_path - %li= link_to t(:mail_templates), admin_mail_templates_path - -# %li= link_to t(:domains_history), admin_domain_versions_path - %li= link_to t(:epp_logs), admin_epp_logs_path(created_after: 'today') - %li= link_to t(:repp_logs), admin_repp_logs_path(created_after: 'today') - %li= link_to t(:que), '/admin/que' - - - if signed_in? - %ul.nav.navbar-nav.navbar-right - %li= link_to t(:log_out, user: current_user), '/admin/logout' - - .container - = render 'shared/flash' - = yield - - .footer.text-right - Version - = CURRENT_COMMIT_HASH From c8faa2a817c0aed014a628c0388f69f4294dd288 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 17 Jan 2017 03:32:11 +0200 Subject: [PATCH 05/28] Add domain force delete dialog #268 --- app/assets/javascripts/admin-manifest.coffee | 2 ++ .../javascripts/admin/domains/edit/init_force_delete_dialog.js | 1 + app/views/admin/domains/_force_delete_dialog.html.erb | 3 +++ app/views/admin/domains/edit.haml | 1 + 4 files changed, 7 insertions(+) create mode 100644 app/assets/javascripts/admin/domains/edit/init_force_delete_dialog.js create mode 100644 app/views/admin/domains/_force_delete_dialog.html.erb diff --git a/app/assets/javascripts/admin-manifest.coffee b/app/assets/javascripts/admin-manifest.coffee index c386c45e6..b5a67a44e 100644 --- a/app/assets/javascripts/admin-manifest.coffee +++ b/app/assets/javascripts/admin-manifest.coffee @@ -7,7 +7,9 @@ #= require selectize #= require shared/jquery.validate.bootstrap #= require jquery-ui/datepicker +#= require jquery-ui/dialog #= require select2 #= require jquery.doubleScroll #= require shared/general #= require admin/application +#= require admin/domains/edit/init_force_delete_dialog diff --git a/app/assets/javascripts/admin/domains/edit/init_force_delete_dialog.js b/app/assets/javascripts/admin/domains/edit/init_force_delete_dialog.js new file mode 100644 index 000000000..c85c65db1 --- /dev/null +++ b/app/assets/javascripts/admin/domains/edit/init_force_delete_dialog.js @@ -0,0 +1 @@ +$('.domain-edit-force-delete-dialog').dialog(); diff --git a/app/views/admin/domains/_force_delete_dialog.html.erb b/app/views/admin/domains/_force_delete_dialog.html.erb new file mode 100644 index 000000000..68deaac26 --- /dev/null +++ b/app/views/admin/domains/_force_delete_dialog.html.erb @@ -0,0 +1,3 @@ +
+ test +
diff --git a/app/views/admin/domains/edit.haml b/app/views/admin/domains/edit.haml index 70596d00e..11fd97f02 100644 --- a/app/views/admin/domains/edit.haml +++ b/app/views/admin/domains/edit.haml @@ -11,3 +11,4 @@ = render 'shared/title', name: "#{t(:edit)}: #{@domain.name}" = render 'form' += render 'force_delete_dialog' From 3cc218597eb8f3163cf3145e05117b9f04d741c1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 18 Jan 2017 08:54:30 +0200 Subject: [PATCH 06/28] Revert "Remove turbolinks, load js in async mode" This reverts commit fec7f82a96492ee615cf6b1402d21ffd3ff215a5. --- app/assets/javascripts/admin-manifest.coffee | 1 + .../javascripts/admin/application.coffee | 87 ++++++++++--------- app/views/layouts/admin.haml | 2 +- app/views/layouts/admin/application.haml | 85 ++++++++++++++++++ 4 files changed, 131 insertions(+), 44 deletions(-) create mode 100644 app/views/layouts/admin/application.haml diff --git a/app/assets/javascripts/admin-manifest.coffee b/app/assets/javascripts/admin-manifest.coffee index b5a67a44e..02cffe443 100644 --- a/app/assets/javascripts/admin-manifest.coffee +++ b/app/assets/javascripts/admin-manifest.coffee @@ -1,5 +1,6 @@ #= require jquery #= require jquery_ujs +#= require turbolinks #= require bootstrap-sprockets #= require typeahead.bundle.min #= require admin/autocomplete diff --git a/app/assets/javascripts/admin/application.coffee b/app/assets/javascripts/admin/application.coffee index 6a6c30bec..1b3335d63 100644 --- a/app/assets/javascripts/admin/application.coffee +++ b/app/assets/javascripts/admin/application.coffee @@ -1,52 +1,53 @@ -$('.selectize').selectize({ - allowEmptyOption: true -}) -$('.selectize_create').selectize({ - allowEmptyOption: true, create: true -}) +$(document).on 'page:change', -> + $('.selectize').selectize({ + allowEmptyOption: true + }) + $('.selectize_create').selectize({ + allowEmptyOption: true, create: true + }) -$('.js-datepicker').datepicker({ - showAnim: "", - autoclose: true, - dateFormat: "dd.mm.yy", - changeMonth: true, - changeYear: true -}) + $('.js-datepicker').datepicker({ + showAnim: "", + autoclose: true, + dateFormat: "dd.mm.yy", + changeMonth: true, + changeYear: true + }) -# client side validate all forms -$('form').each -> - $(this).validate() - -$('[data-toggle="popover"]').popover() + # client side validate all forms + $('form').each -> + $(this).validate() + + $('[data-toggle="popover"]').popover() -# doublescroll -$('[data-doublescroll]').doubleScroll({ - onlyIfScroll: false, - scrollCss: - 'overflow-x': 'auto' - 'overflow-y': 'hidden' - contentCss: - 'overflow-x': 'auto' - 'overflow-y': 'hidden' - resetOnWindowResize: true -}) + # doublescroll + $('[data-doublescroll]').doubleScroll({ + onlyIfScroll: false, + scrollCss: + 'overflow-x': 'auto' + 'overflow-y': 'hidden' + contentCss: + 'overflow-x': 'auto' + 'overflow-y': 'hidden' + resetOnWindowResize: true + }) -positionSlider = -> - for scroll in document.querySelectorAll('[data-doublescroll]') - wrapper = scroll.previousSibling - if $(scroll).offset().top < $(window).scrollTop() - wrapper.style.position = 'fixed' - wrapper.style.top = '-5px' - else - wrapper.style.position = 'relative' - wrapper.style.top = '0' - return + positionSlider = -> + for scroll in document.querySelectorAll('[data-doublescroll]') + wrapper = scroll.previousSibling + if $(scroll).offset().top < $(window).scrollTop() + wrapper.style.position = 'fixed' + wrapper.style.top = '-5px' + else + wrapper.style.position = 'relative' + wrapper.style.top = '0' + return -positionSlider() -$(window).scroll(positionSlider).resize positionSlider -#due .report-table width: auto top scrollbar appears after resize so we do fake resize action -$(window).resize(); + positionSlider() + $(window).scroll(positionSlider).resize positionSlider + #due .report-table width: auto top scrollbar appears after resize so we do fake resize action + $(window).resize() diff --git a/app/views/layouts/admin.haml b/app/views/layouts/admin.haml index 8e8e3230e..70ee14cfc 100644 --- a/app/views/layouts/admin.haml +++ b/app/views/layouts/admin.haml @@ -8,7 +8,7 @@ - else %title= t(:admin_head_title) = csrf_meta_tags - = stylesheet_link_tag 'admin-manifest', media: 'all' + = stylesheet_link_tag 'admin-manifest', media: 'all', 'data-turbolinks-track' => true = favicon_link_tag 'favicon.ico' %body{:style => env_style} .navbar.navbar-inverse.navbar-static-top{role: "navigation"} diff --git a/app/views/layouts/admin/application.haml b/app/views/layouts/admin/application.haml new file mode 100644 index 000000000..9937937e6 --- /dev/null +++ b/app/views/layouts/admin/application.haml @@ -0,0 +1,85 @@ +!!! 5 +%html{lang: I18n.locale.to_s} + %head + %meta{charset: "utf-8"}/ + %meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}/ + %meta{content: "width=device-width, initial-scale=1", name: "viewport"}/ + %meta{content: "Full stack top-level domain (TLD) management.", name: "description"}/ + %meta{content: "Gitlab LTD", name: "author"}/ + - if content_for? :head_title + = yield :head_title + - else + %title= t(:admin_head_title) + = csrf_meta_tags + = stylesheet_link_tag 'admin-manifest', media: 'all', 'data-turbolinks-track' => true + = javascript_include_tag 'admin-manifest', 'data-turbolinks-track' => true + = favicon_link_tag 'favicon.ico' + %body{:style => env_style} + / Static navbar + .navbar.navbar-inverse.navbar-static-top{role: "navigation"} + .container + .navbar-header + %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} + %span.sr-only Toggle navigation + %span.icon-bar + %span.icon-bar + %span.icon-bar + = link_to admin_dashboard_path, class: 'navbar-brand' do + = ENV['app_name'] + - if unstable_env.present? + .text-center + %small{style: 'color: #0074B3;'}= unstable_env + + .navbar-collapse.collapse + %ul.nav.navbar-nav + - if can? :show, Domain + %li= link_to t(:domains), admin_domains_path + - if can? :show, Contact + %li= link_to t(:contacts), admin_contacts_path + - if can? :show, Registrar + %li= link_to t(:registrars), admin_registrars_path + - if can? :show, Keyrelay + %li= link_to t(:keyrelays), admin_keyrelays_path + - if can?(:access, :settings_menu) + %li.dropdown + %a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"} + = t(:settings) + %span.caret + %ul.dropdown-menu{role: "menu"} + %li.dropdown-header= t(:users) + %li= link_to t(:api_users), admin_api_users_path + %li= link_to t(:admin_users), admin_admin_users_path + %li.divider + %li.dropdown-header= t(:billing) + - if can? :view, Pricelist + %li= link_to t(:pricelists), admin_pricelists_path + %li= link_to t(:bank_statements), admin_bank_statements_path + %li= link_to t(:invoices), admin_invoices_path + %li= link_to t(:account_activities), admin_account_activities_path(created_after: 'today') + %li.divider + %li.dropdown-header= t(:archive) + %li= link_to t(:domains_history), admin_domain_versions_path + %li= link_to t(:contacts_history), admin_contact_versions_path + %li.divider + %li.dropdown-header= t(:system) + %li= link_to t(:settings), admin_settings_path + %li= link_to t(:zonefile), admin_zonefile_settings_path + %li= link_to t(:blocked_domains), admin_blocked_domains_path + %li= link_to t(:reserved_domains), admin_reserved_domains_path + %li= link_to t(:mail_templates), admin_mail_templates_path + -# %li= link_to t(:domains_history), admin_domain_versions_path + %li= link_to t(:epp_logs), admin_epp_logs_path(created_after: 'today') + %li= link_to t(:repp_logs), admin_repp_logs_path(created_after: 'today') + %li= link_to t(:que), '/admin/que' + + - if signed_in? + %ul.nav.navbar-nav.navbar-right + %li= link_to t(:log_out, user: current_user), '/admin/logout' + + .container + = render 'shared/flash' + = yield + + .footer.text-right + Version + = CURRENT_COMMIT_HASH From 0820effe5d5a8b8eb7911fc516f2fdfffb63fec1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 18 Jan 2017 08:55:40 +0200 Subject: [PATCH 07/28] Revert "Use default layout path in admin area" This reverts commit 92c6279e462ab88d8ebb30a1712afe463d1fe694. --- app/controllers/admin/sessions_controller.rb | 1 + app/controllers/admin_controller.rb | 1 + app/views/admin/_menu.haml | 44 -------------------- app/views/layouts/admin.haml | 36 ---------------- app/views/layouts/devise.haml | 29 ------------- 5 files changed, 2 insertions(+), 109 deletions(-) delete mode 100644 app/views/admin/_menu.haml delete mode 100644 app/views/layouts/admin.haml delete mode 100644 app/views/layouts/devise.haml diff --git a/app/controllers/admin/sessions_controller.rb b/app/controllers/admin/sessions_controller.rb index d907fe1f3..5dc244398 100644 --- a/app/controllers/admin/sessions_controller.rb +++ b/app/controllers/admin/sessions_controller.rb @@ -1,5 +1,6 @@ class Admin::SessionsController < Devise::SessionsController skip_authorization_check only: :create + layout 'admin/application' def login @admin_user = AdminUser.new diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index ec335ae65..29b7be698 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,4 +1,5 @@ class AdminController < ApplicationController + layout 'admin/application' before_action :authenticate_user! helper_method :head_title_sufix diff --git a/app/views/admin/_menu.haml b/app/views/admin/_menu.haml deleted file mode 100644 index 4077e58f2..000000000 --- a/app/views/admin/_menu.haml +++ /dev/null @@ -1,44 +0,0 @@ -.navbar-collapse.collapse - %ul.nav.navbar-nav - - if can? :show, Domain - %li= link_to t(:domains), admin_domains_path - - if can? :show, Contact - %li= link_to t(:contacts), admin_contacts_path - - if can? :show, Registrar - %li= link_to t(:registrars), admin_registrars_path - - if can? :show, Keyrelay - %li= link_to t(:keyrelays), admin_keyrelays_path - - if can?(:access, :settings_menu) - %li.dropdown - %a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"} - = t(:settings) - %span.caret - %ul.dropdown-menu{role: "menu"} - %li.dropdown-header= t(:users) - %li= link_to t(:api_users), admin_api_users_path - %li= link_to t(:admin_users), admin_admin_users_path - %li.divider - %li.dropdown-header= t(:billing) - - if can? :view, Pricelist - %li= link_to t(:pricelists), admin_pricelists_path - %li= link_to t(:bank_statements), admin_bank_statements_path - %li= link_to t(:invoices), admin_invoices_path - %li= link_to t(:account_activities), admin_account_activities_path(created_after: 'today') - %li.divider - %li.dropdown-header= t(:archive) - %li= link_to t(:domains_history), admin_domain_versions_path - %li= link_to t(:contacts_history), admin_contact_versions_path - %li.divider - %li.dropdown-header= t(:system) - %li= link_to t(:settings), admin_settings_path - %li= link_to t(:zonefile), admin_zonefile_settings_path - %li= link_to t(:blocked_domains), admin_blocked_domains_path - %li= link_to t(:reserved_domains), admin_reserved_domains_path - %li= link_to t(:mail_templates), admin_mail_templates_path - %li= link_to t(:epp_logs), admin_epp_logs_path(created_after: 'today') - %li= link_to t(:repp_logs), admin_repp_logs_path(created_after: 'today') - %li= link_to t(:que), '/admin/que' - - - if signed_in? - %ul.nav.navbar-nav.navbar-right - %li= link_to t(:log_out, user: current_user), '/admin/logout' diff --git a/app/views/layouts/admin.haml b/app/views/layouts/admin.haml deleted file mode 100644 index 70ee14cfc..000000000 --- a/app/views/layouts/admin.haml +++ /dev/null @@ -1,36 +0,0 @@ -!!! 5 -%html{lang: I18n.locale.to_s} - %head - %meta{charset: "utf-8"}/ - %meta{content: "width=device-width, initial-scale=1", name: "viewport"}/ - - if content_for? :head_title - = yield :head_title - - else - %title= t(:admin_head_title) - = csrf_meta_tags - = stylesheet_link_tag 'admin-manifest', media: 'all', 'data-turbolinks-track' => true - = favicon_link_tag 'favicon.ico' - %body{:style => env_style} - .navbar.navbar-inverse.navbar-static-top{role: "navigation"} - .container - .navbar-header - %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} - %span.sr-only Toggle navigation - %span.icon-bar - %span.icon-bar - %span.icon-bar - = link_to admin_dashboard_path, class: 'navbar-brand' do - = ENV['app_name'] - - if unstable_env.present? - .text-center - %small{style: 'color: #0074B3;'}= unstable_env - - = render 'menu' - .container - = render 'shared/flash' - = yield - - .footer.text-right - Version - = CURRENT_COMMIT_HASH - = javascript_include_tag 'admin-manifest', async: true diff --git a/app/views/layouts/devise.haml b/app/views/layouts/devise.haml deleted file mode 100644 index 14534e374..000000000 --- a/app/views/layouts/devise.haml +++ /dev/null @@ -1,29 +0,0 @@ -!!! 5 -%html{lang: I18n.locale.to_s} - %head - %meta{charset: "utf-8"}/ - - if content_for? :head_title - = yield :head_title - - else - %title= t(:admin_head_title) - = csrf_meta_tags - = stylesheet_link_tag 'admin-manifest', media: 'all', 'data-turbolinks-track' => true - = favicon_link_tag 'favicon.ico' - %body{:style => env_style} - .navbar.navbar-inverse.navbar-static-top{role: "navigation"} - .container - .navbar-header - %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} - %span.sr-only Toggle navigation - %span.icon-bar - %span.icon-bar - %span.icon-bar - = link_to admin_dashboard_path, class: 'navbar-brand' do - = ENV['app_name'] - - if unstable_env.present? - .text-center - %small{style: 'color: #0074B3;'}= unstable_env - - .container - = render 'shared/flash' - = yield From 0042fc2d5a91cb1f52ef3a0e6fc93aa1c479cfe7 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 18 Jan 2017 11:43:57 +0200 Subject: [PATCH 08/28] Add missing translation #268 --- config/locales/admin/domains.en.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/locales/admin/domains.en.yml b/config/locales/admin/domains.en.yml index fcb0da578..ce37f7ea6 100644 --- a/config/locales/admin/domains.en.yml +++ b/config/locales/admin/domains.en.yml @@ -4,6 +4,9 @@ en: index: reset_btn: Reset + edit: + add_new_status_btn: Add new status + versions: time: Time admin_contact: Admin contact From e08afe0983a8894ddeaa9cbef4f3609b58b6632a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 18 Jan 2017 11:46:12 +0200 Subject: [PATCH 09/28] Return contact's id code if it is private entity #268 --- app/models/contact.rb | 5 +++++ spec/models/contact_spec.rb | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/app/models/contact.rb b/app/models/contact.rb index 99139e898..995fdc2a9 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -589,4 +589,9 @@ class Contact < ActiveRecord::Base return if priv? ident end + + def id_code + return unless priv? + ident + end end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index df4d8cfd3..4d49bc1e8 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -481,4 +481,18 @@ RSpec.describe Contact, db: false do specify { expect(reg_no).to be_nil } end end + + describe '#id_code' do + context 'when contact is private entity' do + let(:contact) { FactoryGirl.build_stubbed(:contact_private_entity, ident: '1234') } + + specify { expect(contact.id_code).to eq('1234') } + end + + context 'when contact is legal entity' do + let(:contact) { FactoryGirl.build_stubbed(:contact_legal_entity, ident: '1234') } + + specify { expect(contact.id_code).to be_nil } + end + end end From df54100710de90af2c7768abc6dbbbb2acfc9c73 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 18 Jan 2017 11:48:01 +0200 Subject: [PATCH 10/28] Add missing translation #268 --- app/views/admin/domains/edit.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/domains/edit.haml b/app/views/admin/domains/edit.haml index 11fd97f02..a3a7f364c 100644 --- a/app/views/admin/domains/edit.haml +++ b/app/views/admin/domains/edit.haml @@ -1,5 +1,5 @@ - content_for :actions do - = link_to(t(:add_new_status), '#', class: 'btn btn-primary js-add-status') + = link_to(t('.add_new_status_btn'), '#', class: 'btn btn-primary js-add-status') - if @domain.force_deletable? = link_to(t(:set_force_delete), set_force_delete_admin_domain_path(@domain), method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') From 117399af5ec5ebfaa9e1224b8d31d9f85855717a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 18 Jan 2017 11:52:56 +0200 Subject: [PATCH 11/28] Add admin sign in spec helper #268 --- spec/support/features/session_helpers.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/support/features/session_helpers.rb b/spec/support/features/session_helpers.rb index a23609891..63e8bd072 100644 --- a/spec/support/features/session_helpers.rb +++ b/spec/support/features/session_helpers.rb @@ -1,5 +1,14 @@ module Features module SessionHelpers + def sign_in_to_admin_area(user: FactoryGirl.create(:admin_user)) + visit admin_login_url + + fill_in 'admin_user[username]', with: user.username + fill_in 'admin_user[password]', with: user.password + + click_button 'Log in' + end + def sign_in_to_registrar_area(user: FactoryGirl.create(:api_user)) visit registrar_login_url From 664451c4170eb41a7aa56baaf1ef07a3f6a1948b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 18 Jan 2017 11:54:07 +0200 Subject: [PATCH 12/28] Add force domain delete "death" templates #268 --- .../forced/death.html.erb | 43 ++++++++++++++++++ .../forced/death.text.erb | 44 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 app/views/mailers/domain_delete_mailer/forced/death.html.erb create mode 100644 app/views/mailers/domain_delete_mailer/forced/death.text.erb diff --git a/app/views/mailers/domain_delete_mailer/forced/death.html.erb b/app/views/mailers/domain_delete_mailer/forced/death.html.erb new file mode 100644 index 000000000..36ef3693d --- /dev/null +++ b/app/views/mailers/domain_delete_mailer/forced/death.html.erb @@ -0,0 +1,43 @@ +

Lugupeetud domeeni <%= @domain.name %> kontaktisik
+.ee domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed:

+ +

Registreerija nimi: <%= @registrant.name %>
+Isikukood: <%= @registrant.id_code %>

+ +

Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et füüsiline isik isikukoodiga <%= @registrant.id_code %> on surnud ja sellest on möödunud vähemalt 6 kuud. + +Domeenireeglite punktist 6.6 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale [Registrars.name] domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada pärimisõiguse tõend, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale <%= @redemption_grace_period %> päeva jooksul. + +Kuna käesoleval hetkel domeenil registreerijat pole, on EIS algatanud <%= l(@force_delete_set_date, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.6 domeeni <%= @domain.name %> suhtes <%= @redemption_grace_period %> päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks ja selle aja jooksul on võimalik teostada domeeni üleandmine. + +Kui üleandmine ei ole <%= @redemption_grace_period %> päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= @domain.force_delete_date %> 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:

+ +<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %> + + + +

Dear contact of <%= @domain.name %> domain
+The following details for domain name <%= @domain.name %> have been entered into the Estonian Internet Foundation's (EIS) domain registry:

+ +

Registrant's name: <%= @registrant.name %>
+Identification code: <%= @registrant.id_code %>

+ +

EIS has learned that the natural person <%= @registrant.name %> with identification code <%= @registrant.id_code %> has been deceased and 6 months have passed from death. + +According to paragraph 6.6 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 [Registrars.name] in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with succession evidence 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 within <%= @redemption_grace_period %> day(s). + +As a deceased natural person is not the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(@force_delete_set_date, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the <%= @redemption_grace_period %>-day delete procedure. The domain will remain available on the Internet during the delete procedure and within this time can be transferred to new registrant. + +If the transfer has not been made in <%= @redemption_grace_period %> day(s), the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours on <%= @domain.force_delete_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:

+ +<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %> + +

Lugupidamisega,
+Best Regards,
+

+Eesti Interneti Sihtasutus
+Estonian Internet Foundation

diff --git a/app/views/mailers/domain_delete_mailer/forced/death.text.erb b/app/views/mailers/domain_delete_mailer/forced/death.text.erb new file mode 100644 index 000000000..96393d5f3 --- /dev/null +++ b/app/views/mailers/domain_delete_mailer/forced/death.text.erb @@ -0,0 +1,44 @@ +Lugupeetud domeeni <%= @domain.name %> kontaktisik +.ee domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed: + +Registreerija nimi: <%= @registrant.name %> +Isikukood: <%= @registrant.id_code %> + +Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et füüsiline isik isikukoodiga <%= @registrant.id_code %> on surnud ja sellest on möödunud vähemalt 6 kuud. + +Domeenireeglite punktist 6.6 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale [Registrars.name] domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada pärimisõiguse tõend, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale <%= @redemption_grace_period %> päeva jooksul. + +Kuna käesoleval hetkel domeenil registreerijat pole, on EIS algatanud <%= l(@force_delete_set_date, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.6 domeeni <%= @domain.name %> suhtes <%= @redemption_grace_period %> päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks ja selle aja jooksul on võimalik teostada domeeni üleandmine. + +Kui üleandmine ei ole <%= @redemption_grace_period %> päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= @domain.force_delete_date %> 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: + +<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %> + + + +Dear contact of <%= @domain.name %> domain + +The following details for domain name <%= @domain.name %> have been entered into the Estonian Internet Foundation's (EIS) domain registry: + +Registrant's name: <%= @registrant.name %> +Identification code: <%= @registrant.id_code %> + +EIS has learned that the natural person <%= @registrant.name %> with identification code <%= @registrant.id_code %> has been deceased and 6 months have passed from death. + +According to paragraph 6.6 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 [Registrars.name] in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with succession evidence 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 within <%= @redemption_grace_period %> day(s). + +As a deceased natural person is not the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(@force_delete_set_date, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the <%= @redemption_grace_period %>-day delete procedure. The domain will remain available on the Internet during the delete procedure and within this time can be transferred to new registrant. + +If the transfer has not been made in <%= @redemption_grace_period %> day(s), the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours on <%= @domain.force_delete_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: + +<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %> + +Lugupidamisega, +Best Regards, + +Eesti Interneti Sihtasutus +Estonian Internet Foundation From 11b65280ed3c861f27a5b46ce12373e6bd8d3c7e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 19 Jan 2017 13:47:01 +0200 Subject: [PATCH 13/28] Add jquery-ui dialog css #268 --- app/assets/stylesheets/admin-manifest.sass | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/admin-manifest.sass b/app/assets/stylesheets/admin-manifest.sass index b69267519..a36126241 100644 --- a/app/assets/stylesheets/admin-manifest.sass +++ b/app/assets/stylesheets/admin-manifest.sass @@ -1,6 +1,7 @@ //= require 'shared/general-manifest' //= require 'admin/admin-bootstrap' //= require 'jquery-ui/datepicker' +//= require 'jquery-ui/dialog' //= require 'select2' //= require 'select2-bootstrap' @import shared/fonts From df20dc814855e70639566a4462fc5675c53e3e4a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 19 Jan 2017 13:48:02 +0200 Subject: [PATCH 14/28] Remove progress bar css from admin area #268 --- app/assets/stylesheets/admin-manifest.sass | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/assets/stylesheets/admin-manifest.sass b/app/assets/stylesheets/admin-manifest.sass index a36126241..aeec40d95 100644 --- a/app/assets/stylesheets/admin-manifest.sass +++ b/app/assets/stylesheets/admin-manifest.sass @@ -6,8 +6,6 @@ //= require 'select2-bootstrap' @import shared/fonts @import shared/general -@import nprogress -@import nprogress-bootstrap @import typeaheadjs @import selectize @import selectize.bootstrap3 From 00a6b51383c492c7e93d82335a8d2f19658c7e25 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 19 Jan 2017 13:57:21 +0200 Subject: [PATCH 15/28] Require all js files in admin area automatically #268 --- app/assets/javascripts/admin-manifest.coffee | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/assets/javascripts/admin-manifest.coffee b/app/assets/javascripts/admin-manifest.coffee index 5bcf88338..ee2a829c9 100644 --- a/app/assets/javascripts/admin-manifest.coffee +++ b/app/assets/javascripts/admin-manifest.coffee @@ -11,6 +11,4 @@ #= require select2 #= require jquery.doubleScroll #= require admin/application -#= require admin/combobox -#= require admin/datepicker -#= require admin/domains/edit/init_force_delete_dialog +#= require_tree ./admin From 7bcc6f693f55f72d18e78b2f23a47cb6987d0bcd Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 19 Jan 2017 17:55:25 +0200 Subject: [PATCH 16/28] Add project namespace to admin js #268 --- app/assets/javascripts/admin-manifest.coffee | 1 + app/assets/javascripts/admin/app.js | 1 + 2 files changed, 2 insertions(+) create mode 100644 app/assets/javascripts/admin/app.js diff --git a/app/assets/javascripts/admin-manifest.coffee b/app/assets/javascripts/admin-manifest.coffee index ee2a829c9..a435ca7af 100644 --- a/app/assets/javascripts/admin-manifest.coffee +++ b/app/assets/javascripts/admin-manifest.coffee @@ -11,4 +11,5 @@ #= require select2 #= require jquery.doubleScroll #= require admin/application +#= require admin/app #= require_tree ./admin diff --git a/app/assets/javascripts/admin/app.js b/app/assets/javascripts/admin/app.js new file mode 100644 index 000000000..c091ff36d --- /dev/null +++ b/app/assets/javascripts/admin/app.js @@ -0,0 +1 @@ +var RegistryAdmin = {}; From d91d304e529fc942fc5cd9cfc1f4f8e71698a690 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 19 Jan 2017 18:10:04 +0200 Subject: [PATCH 17/28] Converr admin/domains#edit template from haml to html #268 --- app/views/admin/domains/edit.haml | 14 -------------- app/views/admin/domains/edit.html.erb | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) delete mode 100644 app/views/admin/domains/edit.haml create mode 100644 app/views/admin/domains/edit.html.erb diff --git a/app/views/admin/domains/edit.haml b/app/views/admin/domains/edit.haml deleted file mode 100644 index a3a7f364c..000000000 --- a/app/views/admin/domains/edit.haml +++ /dev/null @@ -1,14 +0,0 @@ -- content_for :actions do - = link_to(t('.add_new_status_btn'), '#', class: 'btn btn-primary js-add-status') - - if @domain.force_deletable? - = link_to(t(:set_force_delete), set_force_delete_admin_domain_path(@domain), - method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') - - else - = link_to(t(:unset_force_delete), unset_force_delete_admin_domain_path(@domain), - method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') - = link_to(t(:back_to_domain), [:admin, @domain], class: 'btn btn-default') - -= render 'shared/title', name: "#{t(:edit)}: #{@domain.name}" - -= render 'form' -= render 'force_delete_dialog' diff --git a/app/views/admin/domains/edit.html.erb b/app/views/admin/domains/edit.html.erb new file mode 100644 index 000000000..e1e9f639d --- /dev/null +++ b/app/views/admin/domains/edit.html.erb @@ -0,0 +1,15 @@ +<% content_for :actions do %> + <%= link_to t('.add_new_status_btn'), '#', class: 'btn btn-primary js-add-status' %> + + <% if @domain.force_deletable? %> + <%= link_to(t('.force_delete_btn'), force_delete_admin_domain_path(@domain), method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') %> + <% else %> + <%= link_to(t('.cancel_force_delete_btn'), cancel_force_delete_admin_domain_path(@domain), method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') %> + <% end %> + + <%= link_to t(:back_to_domain), [:admin, @domain], class: 'btn btn-default' %> +<% end %> + +<%= render 'shared/title', name: "#{t(:edit)}: #{@domain.name}" %> +<%= render 'form' %> +<%= render 'force_delete_dialog' %> From 8c4cfe957430fa8dd7bc96683ad50fd01766fe06 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 19 Jan 2017 18:13:01 +0200 Subject: [PATCH 18/28] Reformat admin/domains#edit template #268 --- app/views/admin/domains/edit.html.erb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/views/admin/domains/edit.html.erb b/app/views/admin/domains/edit.html.erb index e1e9f639d..809285e7e 100644 --- a/app/views/admin/domains/edit.html.erb +++ b/app/views/admin/domains/edit.html.erb @@ -1,13 +1,15 @@ <% content_for :actions do %> - <%= link_to t('.add_new_status_btn'), '#', class: 'btn btn-primary js-add-status' %> + <%= link_to t('.add_new_status_btn'), '#', class: 'btn btn-primary js-add-status' %> - <% if @domain.force_deletable? %> - <%= link_to(t('.force_delete_btn'), force_delete_admin_domain_path(@domain), method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') %> - <% else %> - <%= link_to(t('.cancel_force_delete_btn'), cancel_force_delete_admin_domain_path(@domain), method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') %> - <% end %> + <% if @domain.force_deletable? %> + <%= link_to(t('.force_delete_btn'), force_delete_admin_domain_path(@domain), + method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') %> + <% else %> + <%= link_to(t('.cancel_force_delete_btn'), cancel_force_delete_admin_domain_path(@domain), + method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') %> + <% end %> - <%= link_to t(:back_to_domain), [:admin, @domain], class: 'btn btn-default' %> + <%= link_to t(:back_to_domain), [:admin, @domain], class: 'btn btn-default' %> <% end %> <%= render 'shared/title', name: "#{t(:edit)}: #{@domain.name}" %> From a852984bfe17a0f87ef876a5b66568d4f3dc4a3a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 19 Jan 2017 19:06:00 +0200 Subject: [PATCH 19/28] Require all css files in admin area automatically #268 --- app/assets/stylesheets/admin-manifest.sass | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/admin-manifest.sass b/app/assets/stylesheets/admin-manifest.sass index aeec40d95..96207846c 100644 --- a/app/assets/stylesheets/admin-manifest.sass +++ b/app/assets/stylesheets/admin-manifest.sass @@ -11,3 +11,4 @@ @import selectize.bootstrap3 // @import bootstrap-datepicker3 @import admin/admin +//= require ./admin From e405cb80ae498b1d952fb002e29e2b9ef90b745b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 19 Jan 2017 19:06:34 +0200 Subject: [PATCH 20/28] Do not require jquery-ui dialog css in admin area #268 --- app/assets/stylesheets/admin-manifest.sass | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/admin-manifest.sass b/app/assets/stylesheets/admin-manifest.sass index 96207846c..3939e1460 100644 --- a/app/assets/stylesheets/admin-manifest.sass +++ b/app/assets/stylesheets/admin-manifest.sass @@ -1,7 +1,6 @@ //= require 'shared/general-manifest' //= require 'admin/admin-bootstrap' //= require 'jquery-ui/datepicker' -//= require 'jquery-ui/dialog' //= require 'select2' //= require 'select2-bootstrap' @import shared/fonts From d222e6c7811189625968878496cfdeed881db6d5 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 19 Jan 2017 19:06:52 +0200 Subject: [PATCH 21/28] Do not require jquery-ui dialog js in admin area #268 --- app/assets/javascripts/admin-manifest.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/admin-manifest.coffee b/app/assets/javascripts/admin-manifest.coffee index a435ca7af..7e7220b4c 100644 --- a/app/assets/javascripts/admin-manifest.coffee +++ b/app/assets/javascripts/admin-manifest.coffee @@ -7,7 +7,6 @@ #= require selectize #= require shared/jquery.validate.bootstrap #= require jquery-ui/datepicker -#= require jquery-ui/dialog #= require select2 #= require jquery.doubleScroll #= require admin/application From 612e282c49a3dd371cd007e318f9150b608da584 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 20 Jan 2017 01:03:55 +0200 Subject: [PATCH 22/28] Add bootstrap-dialog-fix to admin area #268 --- app/assets/stylesheets/admin-manifest.sass | 3 ++- app/assets/stylesheets/admin/bootstrap-dialog-fix.css | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/admin/bootstrap-dialog-fix.css diff --git a/app/assets/stylesheets/admin-manifest.sass b/app/assets/stylesheets/admin-manifest.sass index 3939e1460..0b7e9d8f7 100644 --- a/app/assets/stylesheets/admin-manifest.sass +++ b/app/assets/stylesheets/admin-manifest.sass @@ -10,4 +10,5 @@ @import selectize.bootstrap3 // @import bootstrap-datepicker3 @import admin/admin -//= require ./admin +@import admin/bootstrap-dialog-fix + diff --git a/app/assets/stylesheets/admin/bootstrap-dialog-fix.css b/app/assets/stylesheets/admin/bootstrap-dialog-fix.css new file mode 100644 index 000000000..741aea79e --- /dev/null +++ b/app/assets/stylesheets/admin/bootstrap-dialog-fix.css @@ -0,0 +1,7 @@ +.modal-open { + overflow: visible; +} + +.modal-open, .modal-open .navbar-fixed-top, .modal-open .navbar-fixed-bottom { + padding-right: 0px !important; +} From 5ed86d084bd4fa473d5ac5609c7941a9a0875885 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 21 Jan 2017 18:21:37 +0200 Subject: [PATCH 23/28] Remove unused template #268 --- app/views/registrar/shared/_flash_messages.haml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 app/views/registrar/shared/_flash_messages.haml diff --git a/app/views/registrar/shared/_flash_messages.haml b/app/views/registrar/shared/_flash_messages.haml deleted file mode 100644 index b1d850a0c..000000000 --- a/app/views/registrar/shared/_flash_messages.haml +++ /dev/null @@ -1,4 +0,0 @@ -- display = (flash.empty?) ? 'none' : 'block' -#flash{style: "display: #{display};"} - - type = (flash[:notice]) ? 'bg-success' : 'bg-danger' - .alert{class: type}= flash[:notice] || flash[:alert] From 95e3ac5d51c780dc209da235e14d6f1120dda922 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 21 Jan 2017 18:21:58 +0200 Subject: [PATCH 24/28] Remove unneeded js #268 --- .../javascripts/admin/domains/edit/init_force_delete_dialog.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 app/assets/javascripts/admin/domains/edit/init_force_delete_dialog.js diff --git a/app/assets/javascripts/admin/domains/edit/init_force_delete_dialog.js b/app/assets/javascripts/admin/domains/edit/init_force_delete_dialog.js deleted file mode 100644 index c85c65db1..000000000 --- a/app/assets/javascripts/admin/domains/edit/init_force_delete_dialog.js +++ /dev/null @@ -1 +0,0 @@ -$('.domain-edit-force-delete-dialog').dialog(); From ae5ae9c60b26aae42d72fd87af44e767509bd547 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 22 Jan 2017 23:45:04 +0200 Subject: [PATCH 25/28] Extract force_delete concern from domain #268 --- app/models/concerns/domain/force_delete.rb | 58 +++++++++++++++++++ app/models/concerns/statuses.rb | 7 --- app/models/domain.rb | 65 +--------------------- 3 files changed, 59 insertions(+), 71 deletions(-) create mode 100644 app/models/concerns/domain/force_delete.rb delete mode 100644 app/models/concerns/statuses.rb diff --git a/app/models/concerns/domain/force_delete.rb b/app/models/concerns/domain/force_delete.rb new file mode 100644 index 000000000..fa44bc589 --- /dev/null +++ b/app/models/concerns/domain/force_delete.rb @@ -0,0 +1,58 @@ +module Concerns::Domain::ForceDelete + extend ActiveSupport::Concern + + included do + alias_attribute :force_delete_time, :force_delete_at + end + + def force_deletable? + !statuses.include?(DomainStatus::FORCE_DELETE) + end + + def force_delete? + statuses.include?(DomainStatus::FORCE_DELETE) + end + + def set_force_delete + self.statuses_backup = statuses + statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED) + statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED) + statuses.delete(DomainStatus::PENDING_UPDATE) + statuses.delete(DomainStatus::PENDING_TRANSFER) + statuses.delete(DomainStatus::PENDING_RENEW) + statuses.delete(DomainStatus::PENDING_CREATE) + + statuses.delete(DomainStatus::FORCE_DELETE) + statuses.delete(DomainStatus::SERVER_RENEW_PROHIBITED) + statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED) + statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED) + statuses.delete(DomainStatus::SERVER_MANUAL_INZONE) + statuses.delete(DomainStatus::PENDING_DELETE) + + statuses << DomainStatus::FORCE_DELETE + statuses << DomainStatus::SERVER_RENEW_PROHIBITED + statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED + statuses << DomainStatus::SERVER_UPDATE_PROHIBITED + statuses << DomainStatus::PENDING_DELETE + + if (statuses & [DomainStatus::SERVER_HOLD, DomainStatus::CLIENT_HOLD]).empty? + statuses << DomainStatus::SERVER_MANUAL_INZONE + end + + self.force_delete_at = (Time.zone.now + (Setting.redemption_grace_period.days + 1.day)).utc.beginning_of_day unless force_delete_at + save!(validate: false) + end + + def unset_force_delete + s = [] + s << DomainStatus::EXPIRED if statuses.include?(DomainStatus::EXPIRED) + s << DomainStatus::SERVER_HOLD if statuses.include?(DomainStatus::SERVER_HOLD) + s << DomainStatus::DELETE_CANDIDATE if statuses.include?(DomainStatus::DELETE_CANDIDATE) + + self.statuses = (statuses_backup + s).uniq + + self.force_delete_at = nil + self.statuses_backup = [] + save(validate: false) + end +end diff --git a/app/models/concerns/statuses.rb b/app/models/concerns/statuses.rb deleted file mode 100644 index 454f43d94..000000000 --- a/app/models/concerns/statuses.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Statuses - extend ActiveSupport::Concern - - def force_delete? - statuses.include?(DomainStatus::FORCE_DELETE) - end -end diff --git a/app/models/domain.rb b/app/models/domain.rb index be450fb80..0117c16d1 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -2,9 +2,9 @@ class Domain < ActiveRecord::Base include UserEvents include Versions # version/domain_version.rb - include Statuses include Concerns::Domain::Expirable include Concerns::Domain::Activatable + include Concerns::Domain::ForceDelete has_paper_trail class_name: "DomainVersion", meta: { children: :children_log } @@ -13,7 +13,6 @@ class Domain < ActiveRecord::Base attr_accessor :legal_document_id alias_attribute :on_hold_time, :outzone_at - alias_attribute :force_delete_time, :force_delete_at alias_attribute :outzone_time, :outzone_at alias_attribute :delete_time, :delete_at @@ -422,10 +421,6 @@ class Domain < ActiveRecord::Base end # rubocop: enable Metrics/CyclomaticComplexity - def force_deletable? - !statuses.include?(DomainStatus::FORCE_DELETE) - end - def registrant_verification_asked? registrant_verification_asked_at.present? && registrant_verification_token.present? end @@ -538,64 +533,6 @@ class Domain < ActiveRecord::Base end # rubocop:enable Lint/Loop - # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/MethodLength - def set_force_delete - self.statuses_backup = statuses - statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED) - statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED) - statuses.delete(DomainStatus::PENDING_UPDATE) - statuses.delete(DomainStatus::PENDING_TRANSFER) - statuses.delete(DomainStatus::PENDING_RENEW) - statuses.delete(DomainStatus::PENDING_CREATE) - - statuses.delete(DomainStatus::FORCE_DELETE) - statuses.delete(DomainStatus::SERVER_RENEW_PROHIBITED) - statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED) - statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED) - statuses.delete(DomainStatus::SERVER_MANUAL_INZONE) - statuses.delete(DomainStatus::PENDING_DELETE) - - statuses << DomainStatus::FORCE_DELETE - statuses << DomainStatus::SERVER_RENEW_PROHIBITED - statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED - statuses << DomainStatus::SERVER_UPDATE_PROHIBITED - statuses << DomainStatus::PENDING_DELETE - - if (statuses & [DomainStatus::SERVER_HOLD, DomainStatus::CLIENT_HOLD]).empty? - statuses << DomainStatus::SERVER_MANUAL_INZONE - end - - self.force_delete_at = (Time.zone.now + (Setting.redemption_grace_period.days + 1.day)).utc.beginning_of_day unless force_delete_at - - transaction do - save!(validate: false) - registrar.messages.create!( - body: I18n.t('force_delete_set_on_domain', domain: name) - ) - - DomainDeleteForcedEmailJob.enqueue(id) - - return true - end - false - end - # rubocop: enable Metrics/MethodLength - # rubocop:enable Metrics/AbcSize - - def unset_force_delete - s = [] - s << DomainStatus::EXPIRED if statuses.include?(DomainStatus::EXPIRED) - s << DomainStatus::SERVER_HOLD if statuses.include?(DomainStatus::SERVER_HOLD) - s << DomainStatus::DELETE_CANDIDATE if statuses.include?(DomainStatus::DELETE_CANDIDATE) - - self.statuses = (statuses_backup + s).uniq - - self.force_delete_at = nil - self.statuses_backup = [] - save(validate: false) - end - def set_graceful_expired self.outzone_at = expire_time + self.class.expire_warning_period self.delete_at = outzone_at + self.class.redemption_grace_period From b7a999f53611764f1a993727aa578a89a8ac2ff0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 23 Jan 2017 04:16:59 +0200 Subject: [PATCH 26/28] Refactor domain force delete, add "death" force delete mailer template #268 --- app/controllers/admin/domains_controller.rb | 30 +++--- app/jobs/domain_delete_forced_email_job.rb | 5 +- app/mailers/domain_delete_mailer.rb | 9 +- app/models/concerns/domain/force_delete.rb | 10 +- app/models/domain.rb | 2 +- app/presenters/domain_presenter.rb | 18 ++++ app/presenters/registrant_presenter.rb | 2 +- .../domains/_force_delete_dialog.html.erb | 35 ++++++- app/views/admin/domains/edit.html.erb | 31 +++--- .../forced/death.html.erb | 54 ++++++---- .../forced/death.text.erb | 4 +- config/locales/admin/domains.en.yml | 18 ++++ config/locales/en.yml | 5 +- config/routes.rb | 5 +- spec/factories/domain.rb | 5 + .../admin/domains/force_delete_spec.rb | 33 +++++++ spec/mailers/domain_delete_mailer_spec.rb | 30 +++++- .../concerns/domain/force_delete_spec.rb | 98 +++++++++++++++++++ spec/models/domain_spec.rb | 97 +----------------- spec/presenters/domain_presenter_spec.rb | 34 +++++++ spec/presenters/registrant_presenter_spec.rb | 1 + spec/routing/admin/domains_routing_spec.rb | 13 +++ .../views/admin/domains/edit.html.erb_spec.rb | 22 +++++ 23 files changed, 395 insertions(+), 166 deletions(-) create mode 100644 spec/features/admin/domains/force_delete_spec.rb create mode 100644 spec/models/concerns/domain/force_delete_spec.rb create mode 100644 spec/routing/admin/domains_routing_spec.rb create mode 100644 spec/views/admin/domains/edit.html.erb_spec.rb diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index f7914353e..97d358f7b 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -1,6 +1,7 @@ class Admin::DomainsController < AdminController load_and_authorize_resource before_action :set_domain, only: [:show, :edit, :update, :zonefile] + helper_method :force_delete_templates # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/CyclomaticComplexity @@ -59,22 +60,26 @@ class Admin::DomainsController < AdminController end end - def set_force_delete - if @domain.set_force_delete - flash[:notice] = I18n.t('domain_updated') - else - flash.now[:alert] = I18n.t('failed_to_update_domain') + def schedule_force_delete + raise 'Template param cannot be empty' if params[:template_name].blank? + + @domain.transaction do + @domain.schedule_force_delete + @domain.registrar.messages.create!(body: I18n.t('force_delete_set_on_domain', domain_name: @domain.name)) + DomainDeleteForcedEmailJob.enqueue(@domain.id, params[:template_name]) end - redirect_to [:admin, @domain] + + redirect_to edit_admin_domain_path(@domain), notice: t('.scheduled') end - def unset_force_delete - if @domain.unset_force_delete - flash[:notice] = I18n.t('domain_updated') + def cancel_force_delete + if @domain.cancel_force_delete + flash[:notice] = t('.cancelled') else flash.now[:alert] = I18n.t('failed_to_update_domain') end - redirect_to [:admin, @domain] + + redirect_to edit_admin_domain_path(@domain) end def versions @@ -121,5 +126,8 @@ class Admin::DomainsController < AdminController params[:q][:valid_to_lteq] = ca_cache end -end + def force_delete_templates + %w(removed_company death) + end +end diff --git a/app/jobs/domain_delete_forced_email_job.rb b/app/jobs/domain_delete_forced_email_job.rb index 1ddd95bb9..c9ba13a6f 100644 --- a/app/jobs/domain_delete_forced_email_job.rb +++ b/app/jobs/domain_delete_forced_email_job.rb @@ -1,11 +1,12 @@ class DomainDeleteForcedEmailJob < Que::Job - def run(domain_id) + def run(domain_id, template_name) domain = Domain.find(domain_id) log(domain) DomainDeleteMailer.forced(domain: domain, registrar: domain.registrar, - registrant: domain.registrant).deliver_now + registrant: domain.registrant, + template_name: template_name).deliver_now end private diff --git a/app/mailers/domain_delete_mailer.rb b/app/mailers/domain_delete_mailer.rb index c8703e0ac..d6a1dac09 100644 --- a/app/mailers/domain_delete_mailer.rb +++ b/app/mailers/domain_delete_mailer.rb @@ -8,12 +8,17 @@ class DomainDeleteMailer < ApplicationMailer mail(to: registrant.email, subject: subject) end - def forced(domain:, registrar:, registrant:) + def forced(domain:, registrar:, registrant:, template_name:) @domain = DomainPresenter.new(domain: domain, view: view_context) @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context) @registrant = RegistrantPresenter.new(registrant: registrant, view: view_context) - mail(to: domain.primary_contact_emails) + @force_delete_set_date = Time.zone.now + @redemption_grace_period = Setting.redemption_grace_period + + mail(to: domain.primary_contact_emails, + template_path: 'mailers/domain_delete_mailer/forced', + template_name: template_name) end private diff --git a/app/models/concerns/domain/force_delete.rb b/app/models/concerns/domain/force_delete.rb index fa44bc589..96f1a94b3 100644 --- a/app/models/concerns/domain/force_delete.rb +++ b/app/models/concerns/domain/force_delete.rb @@ -5,15 +5,11 @@ module Concerns::Domain::ForceDelete alias_attribute :force_delete_time, :force_delete_at end - def force_deletable? - !statuses.include?(DomainStatus::FORCE_DELETE) - end - - def force_delete? + def force_delete_scheduled? statuses.include?(DomainStatus::FORCE_DELETE) end - def set_force_delete + def schedule_force_delete self.statuses_backup = statuses statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED) statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED) @@ -43,7 +39,7 @@ module Concerns::Domain::ForceDelete save!(validate: false) end - def unset_force_delete + def cancel_force_delete s = [] s << DomainStatus::EXPIRED if statuses.include?(DomainStatus::EXPIRED) s << DomainStatus::SERVER_HOLD if statuses.include?(DomainStatus::SERVER_HOLD) diff --git a/app/models/domain.rb b/app/models/domain.rb index 0117c16d1..bca5942ac 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -136,7 +136,7 @@ class Domain < ActiveRecord::Base validate :check_permissions, :unless => :is_admin def check_permissions - return unless force_delete? + return unless force_delete_scheduled? errors.add(:base, I18n.t(:object_status_prohibits_operation)) false end diff --git a/app/presenters/domain_presenter.rb b/app/presenters/domain_presenter.rb index 2d0cfd791..1836ef3b5 100644 --- a/app/presenters/domain_presenter.rb +++ b/app/presenters/domain_presenter.rb @@ -38,6 +38,24 @@ class DomainPresenter domain.nameserver_hostnames.join(', ') end + def force_delete_toggle_btn + if !domain.force_delete_scheduled? + view.content_tag(:a, view.t('admin.domains.force_delete_toggle_btn.schedule'), + class: 'btn btn-danger', + data: { + toggle: 'modal', + target: '.domain-edit-force-delete-dialog', + } + ) + else + view.link_to(view.t('admin.domains.force_delete_toggle_btn.cancel'), + view.cancel_force_delete_admin_domain_path(domain), + method: :patch, + data: { confirm: view.t('admin.domains.force_delete_toggle_btn.cancel_confim') }, + class: 'btn btn-primary') + end + end + private attr_reader :domain diff --git a/app/presenters/registrant_presenter.rb b/app/presenters/registrant_presenter.rb index f7fcb3094..37c640fc3 100644 --- a/app/presenters/registrant_presenter.rb +++ b/app/presenters/registrant_presenter.rb @@ -1,5 +1,5 @@ class RegistrantPresenter - delegate :name, :ident, :email, :priv?, :street, :city, to: :registrant + delegate :name, :ident, :email, :priv?, :street, :city, :id_code, to: :registrant def initialize(registrant:, view:) @registrant = registrant diff --git a/app/views/admin/domains/_force_delete_dialog.html.erb b/app/views/admin/domains/_force_delete_dialog.html.erb index 68deaac26..3452883f2 100644 --- a/app/views/admin/domains/_force_delete_dialog.html.erb +++ b/app/views/admin/domains/_force_delete_dialog.html.erb @@ -1,3 +1,34 @@ -
- test + diff --git a/app/views/admin/domains/edit.html.erb b/app/views/admin/domains/edit.html.erb index 809285e7e..9c65c33d3 100644 --- a/app/views/admin/domains/edit.html.erb +++ b/app/views/admin/domains/edit.html.erb @@ -1,17 +1,20 @@ -<% content_for :actions do %> - <%= link_to t('.add_new_status_btn'), '#', class: 'btn btn-primary js-add-status' %> +<% domain = DomainPresenter.new(domain: @domain, view: self) %> - <% if @domain.force_deletable? %> - <%= link_to(t('.force_delete_btn'), force_delete_admin_domain_path(@domain), - method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') %> - <% else %> - <%= link_to(t('.cancel_force_delete_btn'), cancel_force_delete_admin_domain_path(@domain), - method: :post, data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning') %> - <% end %> +
+
+

+ Edit: <%= domain.name %> +

+
+
+

+ <%= link_to t('.add_new_status_btn'), '#', class: 'btn btn-primary js-add-status' %> + <%= domain.force_delete_toggle_btn %> + <%= link_to t('.back_btn'), [:admin, @domain], class: 'btn btn-default' %> +

+
+
+
- <%= link_to t(:back_to_domain), [:admin, @domain], class: 'btn btn-default' %> -<% end %> - -<%= render 'shared/title', name: "#{t(:edit)}: #{@domain.name}" %> <%= render 'form' %> -<%= render 'force_delete_dialog' %> +<%= render 'force_delete_dialog', templates: force_delete_templates %> diff --git a/app/views/mailers/domain_delete_mailer/forced/death.html.erb b/app/views/mailers/domain_delete_mailer/forced/death.html.erb index 36ef3693d..aeb1583fe 100644 --- a/app/views/mailers/domain_delete_mailer/forced/death.html.erb +++ b/app/views/mailers/domain_delete_mailer/forced/death.html.erb @@ -1,43 +1,57 @@ -

Lugupeetud domeeni <%= @domain.name %> kontaktisik
-.ee domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed:

+ +
+ + +
+
+ +

Lugupeetud domeeni <%= @domain.name %> kontaktisik

+

.ee domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed:

Registreerija nimi: <%= @registrant.name %>
Isikukood: <%= @registrant.id_code %>

-

Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et füüsiline isik isikukoodiga <%= @registrant.id_code %> on surnud ja sellest on möödunud vähemalt 6 kuud. +

Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et füüsiline isik isikukoodiga <%= @registrant.id_code %> on surnud ja sellest on möödunud vähemalt 6 kuud.

-Domeenireeglite punktist 6.6 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale [Registrars.name] domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada pärimisõiguse tõend, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale <%= @redemption_grace_period %> päeva jooksul. +

Domeenireeglite punktist 6.6 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @registrar.name %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada pärimisõiguse tõend, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale <%= @redemption_grace_period %> päeva jooksul.

-Kuna käesoleval hetkel domeenil registreerijat pole, on EIS algatanud <%= l(@force_delete_set_date, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.6 domeeni <%= @domain.name %> suhtes <%= @redemption_grace_period %> päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks ja selle aja jooksul on võimalik teostada domeeni üleandmine. +

Kuna käesoleval hetkel domeenil registreerijat pole, on EIS algatanud <%= l(@force_delete_set_date, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.6 domeeni <%= @domain.name %> suhtes <%= @redemption_grace_period %> päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks ja selle aja jooksul on võimalik teostada domeeni üleandmine.

-Kui üleandmine ei ole <%= @redemption_grace_period %> päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= @domain.force_delete_date %> 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 <%= @redemption_grace_period %> päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= @domain.force_delete_date %> 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:

+

Lisaküsimuste korral võtke palun ühendust oma registripidajaga:

<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %> +
- -

Dear contact of <%= @domain.name %> domain
-The following details for domain name <%= @domain.name %> have been entered into the Estonian Internet Foundation's (EIS) domain registry:

+

Dear contact of <%= @domain.name %> domain
+The following details for domain name <%= @domain.name %> have been entered into the Estonian Internet Foundation's (EIS) domain registry:

Registrant's name: <%= @registrant.name %>
Identification code: <%= @registrant.id_code %>

-

EIS has learned that the natural person <%= @registrant.name %> with identification code <%= @registrant.id_code %> has been deceased and 6 months have passed from death. +

EIS has learned that the natural person <%= @registrant.name %> with identification code <%= @registrant.id_code %> has been deceased and 6 months have passed from death.

-According to paragraph 6.6 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 [Registrars.name] in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with succession evidence 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 within <%= @redemption_grace_period %> day(s). +

According to paragraph 6.6 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 <%= @registrar.name %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with succession evidence 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 within <%= @redemption_grace_period %> day(s).

-As a deceased natural person is not the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(@force_delete_set_date, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the <%= @redemption_grace_period %>-day delete procedure. The domain will remain available on the Internet during the delete procedure and within this time can be transferred to new registrant. +

As a deceased natural person is not the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(@force_delete_set_date, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the <%= @redemption_grace_period %>-day delete procedure. The domain will remain available on the Internet during the delete procedure and within this time can be transferred to new registrant.

-If the transfer has not been made in <%= @redemption_grace_period %> day(s), the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours on <%= @domain.force_delete_date %>. After deletion it is possible to reregister the domain on a "first come, first served" basis. +

If the transfer has not been made in <%= @redemption_grace_period %> day(s), the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours on <%= @domain.force_delete_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:

+

Should you have additional questions, please contact your registrar:

<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %> -

Lugupidamisega,
-Best Regards,
-

-Eesti Interneti Sihtasutus
-Estonian Internet Foundation

+

+ + + + +
+

Lugupidamisega,
+ Best Regards,

+

Eesti Interneti Sihtasutus
+ Estonian Internet Foundation

+
+
diff --git a/app/views/mailers/domain_delete_mailer/forced/death.text.erb b/app/views/mailers/domain_delete_mailer/forced/death.text.erb index 96393d5f3..58939070f 100644 --- a/app/views/mailers/domain_delete_mailer/forced/death.text.erb +++ b/app/views/mailers/domain_delete_mailer/forced/death.text.erb @@ -6,7 +6,7 @@ Isikukood: <%= @registrant.id_code %> Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et füüsiline isik isikukoodiga <%= @registrant.id_code %> on surnud ja sellest on möödunud vähemalt 6 kuud. -Domeenireeglite punktist 6.6 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale [Registrars.name] domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada pärimisõiguse tõend, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale <%= @redemption_grace_period %> päeva jooksul. +Domeenireeglite punktist 6.6 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @registrar.name %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada pärimisõiguse tõend, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale <%= @redemption_grace_period %> päeva jooksul. Kuna käesoleval hetkel domeenil registreerijat pole, on EIS algatanud <%= l(@force_delete_set_date, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.6 domeeni <%= @domain.name %> suhtes <%= @redemption_grace_period %> päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks ja selle aja jooksul on võimalik teostada domeeni üleandmine. @@ -27,7 +27,7 @@ Identification code: <%= @registrant.id_code %> EIS has learned that the natural person <%= @registrant.name %> with identification code <%= @registrant.id_code %> has been deceased and 6 months have passed from death. -According to paragraph 6.6 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 [Registrars.name] in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with succession evidence 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 within <%= @redemption_grace_period %> day(s). +According to paragraph 6.6 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 <%= @registrar.name %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with succession evidence 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 within <%= @redemption_grace_period %> day(s). As a deceased natural person is not the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(@force_delete_set_date, format: :date) %> according to the Domain Regulation (http://www.internet.ee/en/domains/), using the <%= @redemption_grace_period %>-day delete procedure. The domain will remain available on the Internet during the delete procedure and within this time can be transferred to new registrant. diff --git a/config/locales/admin/domains.en.yml b/config/locales/admin/domains.en.yml index ce37f7ea6..ae0626ffb 100644 --- a/config/locales/admin/domains.en.yml +++ b/config/locales/admin/domains.en.yml @@ -6,6 +6,19 @@ en: edit: add_new_status_btn: Add new status + back_btn: Back to domain + + force_delete_dialog: + title: Force delete + template: Template + close_btn: Close dialog + submit_btn: Force delete domain + + schedule_force_delete: + scheduled: Force delete procedure has been scheduled + + cancel_force_delete: + cancelled: Force delete procedure has been cancelled versions: time: Time @@ -16,3 +29,8 @@ en: outzone_time: Outzone time delete_time: Delete time force_delete_time: Force delete time + + force_delete_toggle_btn: + schedule: Schedule force delete + cancel: Cancel force delete + cancel_confim: Are you sure you want cancel force delete procedure? diff --git a/config/locales/en.yml b/config/locales/en.yml index f75324218..d266cdfdf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -602,7 +602,6 @@ en: new_domain: 'New domain' edit: 'Edit' delete: 'Delete' - are_you_sure: 'Are you sure?' renew: 'Renew' new: New renew_domain: 'Renew domain' @@ -844,8 +843,6 @@ en: valid: Valid category: Zone object_is_not_eligible_for_renewal: 'Object is not eligible for renewal' - set_force_delete: 'Set force delete' - unset_force_delete: 'Unset force delete' domain_expiring: 'Domain expiring' domain_validation_rules: 'Domain validation rules' bank_statement_desc: 'Import file row will match only when matching following attributes:
ref number
payment amount
invoice number (the first numerical value in comment field)
.' @@ -914,7 +911,7 @@ en: created_at_from: 'Created at from' created_at_until: 'Created at until' is_registrant: 'Is registrant' - force_delete_set_on_domain: 'Force delete set on domain %{domain}' + force_delete_set_on_domain: 'Force delete set on domain %{domain_name}' mail_templates: Mail Templates new_mail_template: New mail template failure: "It was not saved" diff --git a/config/routes.rb b/config/routes.rb index c4f1cf32c..8b52e7091 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -202,9 +202,10 @@ Rails.application.routes.draw do resources :domain_versions, controller: 'domains', action: 'versions' resources :pending_updates resources :pending_deletes + member do - post 'set_force_delete' - post 'unset_force_delete' + patch 'schedule_force_delete' + patch 'cancel_force_delete' end end diff --git a/spec/factories/domain.rb b/spec/factories/domain.rb index 534670ce0..edbd2274c 100644 --- a/spec/factories/domain.rb +++ b/spec/factories/domain.rb @@ -10,5 +10,10 @@ FactoryGirl.define do domain.admin_domain_contacts << FactoryGirl.build(:admin_domain_contact) domain.tech_domain_contacts << FactoryGirl.build(:tech_domain_contact) end + + factory :domain_without_force_delete do + force_delete_time nil + statuses [] + end end end diff --git a/spec/features/admin/domains/force_delete_spec.rb b/spec/features/admin/domains/force_delete_spec.rb new file mode 100644 index 000000000..1d3b926a6 --- /dev/null +++ b/spec/features/admin/domains/force_delete_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' + +RSpec.feature 'Force delete' do + context 'when domain has no force delete procedure' do + given!(:domain) { create(:domain_without_force_delete) } + + scenario 'schedule' do + sign_in_to_admin_area + + visit edit_admin_domain_url(domain) + click_link_or_button 'Force delete domain' + + expect(page).to have_text('Force delete procedure has been scheduled') + end + end + + context 'when domain has force delete procedure' do + given!(:domain) { create(:domain_without_force_delete) } + + background do + domain.schedule_force_delete + end + + scenario 'cancel' do + sign_in_to_admin_area + + visit edit_admin_domain_url(domain) + click_link_or_button 'Cancel force delete' + + expect(page).to have_text('Force delete procedure has been cancelled') + end + end +end diff --git a/spec/mailers/domain_delete_mailer_spec.rb b/spec/mailers/domain_delete_mailer_spec.rb index 5a2f775c1..ce4bbce93 100644 --- a/spec/mailers/domain_delete_mailer_spec.rb +++ b/spec/mailers/domain_delete_mailer_spec.rb @@ -48,12 +48,16 @@ RSpec.describe DomainDeleteMailer do describe '#forced' do let(:domain) { instance_spy(Domain, name: 'test.com') } + let(:registrant) { instance_spy(Registrant) } + let(:template_name) { 'removed_company' } + let(:domain_presenter) { instance_spy(DomainPresenter) } let(:registrar_presenter) { instance_spy(RegistrarPresenter) } let(:registrant_presenter) { instance_spy(RegistrantPresenter) } subject(:message) { described_class.forced(domain: domain, registrar: 'registrar', - registrant: 'registrant') + registrant: registrant, + template_name: template_name) } before :example do @@ -75,8 +79,28 @@ RSpec.describe DomainDeleteMailer do expect(message.subject).to eq('Kustutusmenetluse teade') end - it 'sends message' do - expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + context 'when template is :death' do + let(:template_name) { 'death' } + + it 'sends message' do + expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + + context 'when registrant is private entity' do + let(:registrant) { build_stubbed(:registrant_private_entity) } + + it 'sends message' do + expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + + context 'when registrant is legal entity' do + let(:registrant) { build_stubbed(:registrant_legal_entity) } + + it 'sends message' do + expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + end end end end diff --git a/spec/models/concerns/domain/force_delete_spec.rb b/spec/models/concerns/domain/force_delete_spec.rb new file mode 100644 index 000000000..3e0563366 --- /dev/null +++ b/spec/models/concerns/domain/force_delete_spec.rb @@ -0,0 +1,98 @@ +require 'rails_helper' + +RSpec.describe Domain do + it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) } + + before :example do + Fabricate(:zonefile_setting, origin: 'ee') + end + + it 'should set force delete time' do + domain = Fabricate(:domain) + domain.statuses = ['ok'] + domain.schedule_force_delete + + domain.statuses.should match_array([ + "serverForceDelete", + "pendingDelete", + "serverManualInzone", + "serverRenewProhibited", + "serverTransferProhibited", + "serverUpdateProhibited" + ]) + + domain.cancel_force_delete + + domain.statuses.should == ['ok'] + + domain.statuses = [ + DomainStatus::CLIENT_DELETE_PROHIBITED, + DomainStatus::SERVER_DELETE_PROHIBITED, + DomainStatus::PENDING_UPDATE, + DomainStatus::PENDING_TRANSFER, + DomainStatus::PENDING_RENEW, + DomainStatus::PENDING_CREATE, + DomainStatus::CLIENT_HOLD, + DomainStatus::EXPIRED, + DomainStatus::SERVER_HOLD, + DomainStatus::DELETE_CANDIDATE + ] + + domain.save + + domain.schedule_force_delete + + domain.statuses.should match_array([ + "clientHold", + "deleteCandidate", + "expired", + "serverForceDelete", + "pendingDelete", + "serverHold", + "serverRenewProhibited", + "serverTransferProhibited", + "serverUpdateProhibited" + ]) + + domain.cancel_force_delete + + domain.statuses.should match_array([ + "clientDeleteProhibited", + "clientHold", + "deleteCandidate", + "expired", + "pendingCreate", + "pendingRenew", + "pendingTransfer", + "pendingUpdate", + "serverDeleteProhibited", + "serverHold" + ]) + end + + it 'should should be manual in zone and held after force delete' do + domain = create(:domain) + Setting.redemption_grace_period = 1 + + domain.valid? + domain.outzone_at = Time.zone.now + 1.day # before redemption grace period + # what should this be? + # domain.server_holdable?.should be true + domain.statuses.include?(DomainStatus::SERVER_HOLD).should be false + domain.statuses.include?(DomainStatus::SERVER_MANUAL_INZONE).should be false + domain.schedule_force_delete + domain.server_holdable?.should be false + domain.statuses.include?(DomainStatus::SERVER_MANUAL_INZONE).should be true + domain.statuses.include?(DomainStatus::SERVER_HOLD).should be false + end + + it 'should not allow update after force delete' do + domain = create(:domain) + domain.valid? + domain.pending_update_prohibited?.should be false + domain.update_prohibited?.should be false + domain.schedule_force_delete + domain.pending_update_prohibited?.should be true + domain.update_prohibited?.should be true + end +end diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 555cf48e1..6e224080f 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -182,98 +182,6 @@ RSpec.describe Domain do domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false end - it 'should set force delete time' do - @domain.statuses = ['ok'] - @domain.set_force_delete - - @domain.statuses.should match_array([ - "serverForceDelete", - "pendingDelete", - "serverManualInzone", - "serverRenewProhibited", - "serverTransferProhibited", - "serverUpdateProhibited" - ]) - - fda = Time.zone.now + Setting.redemption_grace_period.days - - @domain.registrar.messages.count.should == 1 - m = @domain.registrar.messages.first - m.body.should == "Force delete set on domain #{@domain.name}" - - @domain.unset_force_delete - - @domain.statuses.should == ['ok'] - - @domain.statuses = [ - DomainStatus::CLIENT_DELETE_PROHIBITED, - DomainStatus::SERVER_DELETE_PROHIBITED, - DomainStatus::PENDING_UPDATE, - DomainStatus::PENDING_TRANSFER, - DomainStatus::PENDING_RENEW, - DomainStatus::PENDING_CREATE, - DomainStatus::CLIENT_HOLD, - DomainStatus::EXPIRED, - DomainStatus::SERVER_HOLD, - DomainStatus::DELETE_CANDIDATE - ] - - @domain.save - - @domain.set_force_delete - - @domain.statuses.should match_array([ - "clientHold", - "deleteCandidate", - "expired", - "serverForceDelete", - "pendingDelete", - "serverHold", - "serverRenewProhibited", - "serverTransferProhibited", - "serverUpdateProhibited" - ]) - - @domain.unset_force_delete - - @domain.statuses.should match_array([ - "clientDeleteProhibited", - "clientHold", - "deleteCandidate", - "expired", - "pendingCreate", - "pendingRenew", - "pendingTransfer", - "pendingUpdate", - "serverDeleteProhibited", - "serverHold" - ]) - end - - it 'should should be manual in zone and held after force delete' do - Setting.redemption_grace_period = 1 - - @domain.valid? - @domain.outzone_at = Time.zone.now + 1.day # before redemption grace period - # what should this be? - # @domain.server_holdable?.should be true - @domain.statuses.include?(DomainStatus::SERVER_HOLD).should be false - @domain.statuses.include?(DomainStatus::SERVER_MANUAL_INZONE).should be false - @domain.set_force_delete - @domain.server_holdable?.should be false - @domain.statuses.include?(DomainStatus::SERVER_MANUAL_INZONE).should be true - @domain.statuses.include?(DomainStatus::SERVER_HOLD).should be false - end - - it 'should not allow update after force delete' do - @domain.valid? - @domain.pending_update_prohibited?.should be false - @domain.update_prohibited?.should be false - @domain.set_force_delete - @domain.pending_update_prohibited?.should be true - @domain.update_prohibited?.should be true - end - context 'with time period settings' do before :example do @save_days_to_renew = Setting.days_to_renew_domain_before_expire @@ -302,7 +210,7 @@ RSpec.describe Domain do it 'should not allow to renew after force delete' do Setting.redemption_grace_period = 1 - @domain.set_force_delete + @domain.schedule_force_delete @domain.renewable?.should be false end end @@ -327,7 +235,7 @@ RSpec.describe Domain do it 'should not allow to renew after force delete' do Setting.redemption_grace_period = 1 - @domain.set_force_delete + @domain.schedule_force_delete @domain.renewable?.should be false end end @@ -700,7 +608,6 @@ end RSpec.describe Domain, db: false do it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) } it { is_expected.to alias_attribute(:delete_time, :delete_at) } - it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) } it { is_expected.to alias_attribute(:outzone_time, :outzone_at) } describe 'nameserver validation', db: true do diff --git a/spec/presenters/domain_presenter_spec.rb b/spec/presenters/domain_presenter_spec.rb index 2209c01aa..5b3a14e12 100644 --- a/spec/presenters/domain_presenter_spec.rb +++ b/spec/presenters/domain_presenter_spec.rb @@ -114,6 +114,40 @@ RSpec.describe DomainPresenter do end end + describe '#force_delete_toggle_btn' do + let(:domain) { build_stubbed(:domain) } + + context 'when force delete is not scheduled' do + before :example do + expect(domain).to receive(:force_delete_scheduled?).and_return(false) + end + + it 'returns schedule button' do + html = view.content_tag(:a, 'Schedule force delete', + class: 'btn btn-danger', + data: { + toggle: 'modal', + target: '.domain-edit-force-delete-dialog', + }) + expect(presenter.force_delete_toggle_btn).to eq(html) + end + end + + context 'when force delete is scheduled' do + before :example do + expect(domain).to receive(:force_delete_scheduled?).and_return(true) + end + + it 'returns cancel button' do + html = link_to('Cancel force delete', + view.cancel_force_delete_admin_domain_path(domain), + method: :patch, + data: { confirm: 'Are you sure you want cancel force delete procedure?' }, + class: 'btn btn-warning') + expect(presenter.force_delete_toggle_btn).to eq(html) + end + end + end domain_delegatable_attributes = %i( name diff --git a/spec/presenters/registrant_presenter_spec.rb b/spec/presenters/registrant_presenter_spec.rb index 894dd40d5..5db6cb0da 100644 --- a/spec/presenters/registrant_presenter_spec.rb +++ b/spec/presenters/registrant_presenter_spec.rb @@ -11,6 +11,7 @@ RSpec.describe RegistrantPresenter do priv? street city + id_code ) registrant_delegate_attributes.each do |attribute_name| diff --git a/spec/routing/admin/domains_routing_spec.rb b/spec/routing/admin/domains_routing_spec.rb new file mode 100644 index 000000000..ce1da8d57 --- /dev/null +++ b/spec/routing/admin/domains_routing_spec.rb @@ -0,0 +1,13 @@ +require 'rails_helper' + +RSpec.describe Admin::DomainsController do + describe 'routing' do + it 'routes to #schedule_force_delete' do + expect(patch: '/admin/domains/1/schedule_force_delete').to route_to('admin/domains#schedule_force_delete', id: '1') + end + + it 'routes to #cancel_force_delete' do + expect(patch: '/admin/domains/1/cancel_force_delete').to route_to('admin/domains#cancel_force_delete', id: '1') + end + end +end diff --git a/spec/views/admin/domains/edit.html.erb_spec.rb b/spec/views/admin/domains/edit.html.erb_spec.rb new file mode 100644 index 000000000..b3cc5d834 --- /dev/null +++ b/spec/views/admin/domains/edit.html.erb_spec.rb @@ -0,0 +1,22 @@ +require 'rails_helper' + +RSpec.describe 'admin/domains/edit' do + let(:domain) { build_stubbed(:domain) } + let(:domain_presenter) { DomainPresenter.new(domain: domain, view: view) } + + before :example do + allow(DomainPresenter).to receive(:new).and_return(domain_presenter) + allow(view).to receive(:force_delete_templates) + + assign(:domain, domain) + + stub_template '_form' => '' + stub_template '_force_delete_dialog' => '' + end + + it 'has force_delete_toggle_btn' do + expect(domain_presenter).to receive(:force_delete_toggle_btn).and_return('force_delete_toggle_btn') + render + expect(rendered).to have_content('force_delete_toggle_btn') + end +end From e56e27327bba20866c389d89a835b1effcaf758b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 23 Jan 2017 04:24:02 +0200 Subject: [PATCH 27/28] Add flash messages to admin area #268 --- app/views/admin/_flash_messages.html.erb | 20 ++++++++++++++++++++ app/views/layouts/admin.haml | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 app/views/admin/_flash_messages.html.erb diff --git a/app/views/admin/_flash_messages.html.erb b/app/views/admin/_flash_messages.html.erb new file mode 100644 index 000000000..4a10df304 --- /dev/null +++ b/app/views/admin/_flash_messages.html.erb @@ -0,0 +1,20 @@ +<% if flash[:notice] %> +
+ +

<%= flash[:notice] %>

+
+<% end %> + +<% if flash[:alert] %> +
+ +

<%= flash[:alert] %>

+
+<% end %> + +<% if flash[:info] %> +
+ +

<%= flash[:info] %>

+
+<% end %> diff --git a/app/views/layouts/admin.haml b/app/views/layouts/admin.haml index 8e8e3230e..717c5015c 100644 --- a/app/views/layouts/admin.haml +++ b/app/views/layouts/admin.haml @@ -27,7 +27,7 @@ = render 'menu' .container - = render 'shared/flash' + = render 'flash_messages' = yield .footer.text-right From 4a84157a8360448cb8588ff218e7f5805ef195b0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 23 Jan 2017 04:32:12 +0200 Subject: [PATCH 28/28] Fix domain specs #268 --- spec/jobs/domain_delete_forced_email_job_spec.rb | 6 ++++-- spec/presenters/domain_presenter_spec.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/jobs/domain_delete_forced_email_job_spec.rb b/spec/jobs/domain_delete_forced_email_job_spec.rb index 05dab987b..3d725b987 100644 --- a/spec/jobs/domain_delete_forced_email_job_spec.rb +++ b/spec/jobs/domain_delete_forced_email_job_spec.rb @@ -17,7 +17,8 @@ RSpec.describe DomainDeleteForcedEmailJob do after :example do domain_id = 1 - described_class.enqueue(domain_id) + template_name = 'removed_company' + described_class.enqueue(domain_id, template_name) end it 'creates log record' do @@ -32,7 +33,8 @@ RSpec.describe DomainDeleteForcedEmailJob do it 'sends email' do expect(DomainDeleteMailer).to receive(:forced).with(domain: domain, registrar: 'registrar', - registrant: 'registrant') + registrant: 'registrant', + template_name: 'removed_company') .and_return(message) expect(message).to receive(:deliver_now) end diff --git a/spec/presenters/domain_presenter_spec.rb b/spec/presenters/domain_presenter_spec.rb index 5b3a14e12..f32e6eb52 100644 --- a/spec/presenters/domain_presenter_spec.rb +++ b/spec/presenters/domain_presenter_spec.rb @@ -143,7 +143,7 @@ RSpec.describe DomainPresenter do view.cancel_force_delete_admin_domain_path(domain), method: :patch, data: { confirm: 'Are you sure you want cancel force delete procedure?' }, - class: 'btn btn-warning') + class: 'btn btn-primary') expect(presenter.force_delete_toggle_btn).to eq(html) end end