From 0a8acc72c92daa0251c0829456dd82a61e25f627 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 1 Jun 2018 14:43:44 +0300 Subject: [PATCH 01/64] Remove "spring" gem - Regenerate binstubs --- Gemfile | 2 -- Gemfile.lock | 8 +------ bin/rails | 7 +------ bin/rake | 5 ----- bin/rspec | 4 ---- bin/setup | 29 ++++++++++++++++++++++++++ bin/spring | 15 ------------- config/environments/test.rb | 2 +- config/initializers/001_paper_trail.rb | 2 +- config/spring.rb | 1 - 10 files changed, 33 insertions(+), 42 deletions(-) create mode 100644 bin/setup delete mode 100755 bin/spring delete mode 100644 config/spring.rb diff --git a/Gemfile b/Gemfile index 0af80fddf..a0efeacbc 100644 --- a/Gemfile +++ b/Gemfile @@ -101,8 +101,6 @@ gem 'jquery-ui-rails', '5.0.5' gem 'active_model-errors_details' # Backport from Rails 5, https://github.com/rails/rails/pull/18322 group :development do - gem 'spring' - gem 'spring-commands-rspec' gem 'rubocop' # deploy diff --git a/Gemfile.lock b/Gemfile.lock index b12b28a2d..fac725cfd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -423,10 +423,6 @@ GEM sixarm_ruby_unaccent (1.1.1) slop (3.6.0) socksify (1.7.1) - spring (2.0.2) - activesupport (>= 4.2) - spring-commands-rspec (1.0.4) - spring (>= 0.9.1) sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -534,12 +530,10 @@ DEPENDENCIES selectize-rails (= 0.12.1) simplecov simpleidn (= 0.0.7) - spring - spring-commands-rspec uuidtools (= 2.1.5) validates_email_format_of (= 1.6.3) webmock whenever (= 0.9.4) BUNDLED WITH - 1.16.1 + 1.16.2 diff --git a/bin/rails b/bin/rails index 284b01d72..5191e6927 100755 --- a/bin/rails +++ b/bin/rails @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError - 'no spring' -end -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 7b36ecbff..17240489f 100755 --- a/bin/rake +++ b/bin/rake @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError - 'no spring' -end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/rspec b/bin/rspec index 534d2bb5f..8bc84617e 100755 --- a/bin/rspec +++ b/bin/rspec @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path("../spring", __FILE__) -rescue LoadError -end # # This file was generated by Bundler. # diff --git a/bin/setup b/bin/setup new file mode 100644 index 000000000..acdb2c138 --- /dev/null +++ b/bin/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle check || bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/bin/spring b/bin/spring deleted file mode 100755 index 7b45d374f..000000000 --- a/bin/spring +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby - -# This file loads spring without using Bundler, in order to be fast. -# It gets overwritten when you run the `spring binstub` command. - -unless defined?(Spring) - require "rubygems" - require "bundler" - - if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m) - Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq } - gem "spring", match[1] - require "spring/binstub" - end -end diff --git a/config/environments/test.rb b/config/environments/test.rb index 9b22ad426..8e5d52a5b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,7 +10,7 @@ Rails.application.configure do # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. - config.eager_load = true + config.eager_load = false # Configure static asset server for tests with Cache-Control for performance. config.serve_static_files = true diff --git a/config/initializers/001_paper_trail.rb b/config/initializers/001_paper_trail.rb index 9dec5fb12..645e6535c 100644 --- a/config/initializers/001_paper_trail.rb +++ b/config/initializers/001_paper_trail.rb @@ -6,7 +6,7 @@ PaperTrail::Version.module_eval do end # Store console and rake changes in versions -if defined?(::Rails::Console) || File.basename($PROGRAM_NAME).split(' ').first == 'spring' +if defined?(::Rails::Console) PaperTrail.whodunnit = "console-#{`whoami`.strip}" elsif File.basename($PROGRAM_NAME) == "rake" # rake username does not work when spring enabled diff --git a/config/spring.rb b/config/spring.rb deleted file mode 100644 index 12c701147..000000000 --- a/config/spring.rb +++ /dev/null @@ -1 +0,0 @@ -Spring.watch 'config/application.yml' From af0415c94900ac37dacf6979d7eed64c75c63b9e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 5 Jun 2018 05:09:25 +0300 Subject: [PATCH 02/64] Remove "bundler-audit" gem --- Gemfile | 1 - Gemfile.lock | 4 ---- 2 files changed, 5 deletions(-) diff --git a/Gemfile b/Gemfile index 0af80fddf..c77fc212e 100644 --- a/Gemfile +++ b/Gemfile @@ -120,7 +120,6 @@ group :development, :test do gem 'pry', '0.10.1' gem 'bullet', '4.14.7' # for finding database optimizations - gem 'bundler-audit' gem 'brakeman', '3.6.1', require: false # for security audit' # tmp, otherwise conflics with breakman # gem 'html2haml', github: 'haml/html2haml', ref: '6984f50bdbbd6291535027726a5697f28778ee8d' diff --git a/Gemfile.lock b/Gemfile.lock index b12b28a2d..ae8676ede 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -128,9 +128,6 @@ GEM bullet (4.14.7) activesupport (>= 3.0.0) uniform_notifier (~> 1.9.0) - bundler-audit (0.5.0) - bundler (~> 1.2) - thor (~> 0.18) cancancan (1.11.0) capybara (2.14.0) addressable @@ -482,7 +479,6 @@ DEPENDENCIES bootstrap-sass (= 3.3.5.1) brakeman (= 3.6.1) bullet (= 4.14.7) - bundler-audit cancancan (= 1.11.0) capybara coderay (= 1.1.0) From 5441424e456a212004fa0b3bec0fcd7f84f3d8df Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 5 Jun 2018 05:11:06 +0300 Subject: [PATCH 03/64] Remove "brakeman" gem --- Gemfile | 3 --- Gemfile.lock | 2 -- 2 files changed, 5 deletions(-) diff --git a/Gemfile b/Gemfile index c77fc212e..2d10b744d 100644 --- a/Gemfile +++ b/Gemfile @@ -120,9 +120,6 @@ group :development, :test do gem 'pry', '0.10.1' gem 'bullet', '4.14.7' # for finding database optimizations - gem 'brakeman', '3.6.1', require: false # for security audit' - # tmp, otherwise conflics with breakman - # gem 'html2haml', github: 'haml/html2haml', ref: '6984f50bdbbd6291535027726a5697f28778ee8d' gem 'html2haml', '2.1.0' gem 'sdoc', '0.4.1' # bundle exec rake doc:rails generates the API under doc/api. gem 'railroady', '1.3.0' # to generate database diagrams diff --git a/Gemfile.lock b/Gemfile.lock index ae8676ede..0782f93f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -123,7 +123,6 @@ GEM bootstrap-sass (3.3.5.1) autoprefixer-rails (>= 5.0.0.1) sass (>= 3.3.0) - brakeman (3.6.1) builder (3.2.3) bullet (4.14.7) activesupport (>= 3.0.0) @@ -477,7 +476,6 @@ DEPENDENCIES airbrake autodoc bootstrap-sass (= 3.3.5.1) - brakeman (= 3.6.1) bullet (= 4.14.7) cancancan (= 1.11.0) capybara From 41cb23f22fe8b076328b62d8f8e2d74fccb73bda Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 9 Jun 2018 05:04:21 +0300 Subject: [PATCH 04/64] Backport Rails 5 API controller --- lib/action_controller/api.rb | 149 ++++++++++++++++++ lib/action_controller/api/api_rendering.rb | 16 ++ .../metal/basic_implicit_render.rb | 13 ++ lib/rails5_api_controller_backport.rb | 3 + 4 files changed, 181 insertions(+) create mode 100644 lib/action_controller/api.rb create mode 100644 lib/action_controller/api/api_rendering.rb create mode 100644 lib/action_controller/metal/basic_implicit_render.rb create mode 100644 lib/rails5_api_controller_backport.rb diff --git a/lib/action_controller/api.rb b/lib/action_controller/api.rb new file mode 100644 index 000000000..5a9fd4512 --- /dev/null +++ b/lib/action_controller/api.rb @@ -0,0 +1,149 @@ +# frozen_string_literal: true + +require "action_view" +require "action_controller" +require "action_controller/log_subscriber" + +module ActionController + # API Controller is a lightweight version of ActionController::Base, + # created for applications that don't require all functionalities that a complete + # \Rails controller provides, allowing you to create controllers with just the + # features that you need for API only applications. + # + # An API Controller is different from a normal controller in the sense that + # by default it doesn't include a number of features that are usually required + # by browser access only: layouts and templates rendering, cookies, sessions, + # flash, assets, and so on. This makes the entire controller stack thinner, + # suitable for API applications. It doesn't mean you won't have such + # features if you need them: they're all available for you to include in + # your application, they're just not part of the default API controller stack. + # + # Normally, +ApplicationController+ is the only controller that inherits from + # ActionController::API. All other controllers in turn inherit from + # +ApplicationController+. + # + # A sample controller could look like this: + # + # class PostsController < ApplicationController + # def index + # posts = Post.all + # render json: posts + # end + # end + # + # Request, response, and parameters objects all work the exact same way as + # ActionController::Base. + # + # == Renders + # + # The default API Controller stack includes all renderers, which means you + # can use render :json and brothers freely in your controllers. Keep + # in mind that templates are not going to be rendered, so you need to ensure + # your controller is calling either render or redirect_to in + # all actions, otherwise it will return 204 No Content. + # + # def show + # post = Post.find(params[:id]) + # render json: post + # end + # + # == Redirects + # + # Redirects are used to move from one action to another. You can use the + # redirect_to method in your controllers in the same way as in + # ActionController::Base. For example: + # + # def create + # redirect_to root_url and return if not_authorized? + # # do stuff here + # end + # + # == Adding New Behavior + # + # In some scenarios you may want to add back some functionality provided by + # ActionController::Base that is not present by default in + # ActionController::API, for instance MimeResponds. This + # module gives you the respond_to method. Adding it is quite simple, + # you just need to include the module in a specific controller or in + # +ApplicationController+ in case you want it available in your entire + # application: + # + # class ApplicationController < ActionController::API + # include ActionController::MimeResponds + # end + # + # class PostsController < ApplicationController + # def index + # posts = Post.all + # + # respond_to do |format| + # format.json { render json: posts } + # format.xml { render xml: posts } + # end + # end + # end + # + # Make sure to check the modules included in ActionController::Base + # if you want to use any other functionality that is not provided + # by ActionController::API out of the box. + class API < Metal + abstract! + + # Shortcut helper that returns all the ActionController::API modules except + # the ones passed as arguments: + # + # class MyAPIBaseController < ActionController::Metal + # ActionController::API.without_modules(:ForceSSL, :UrlFor).each do |left| + # include left + # end + # end + # + # This gives better control over what you want to exclude and makes it easier + # to create an API controller class, instead of listing the modules required + # manually. + def self.without_modules(*modules) + modules = modules.map do |m| + m.is_a?(Symbol) ? ActionController.const_get(m) : m + end + + MODULES - modules + end + + MODULES = [ + AbstractController::Rendering, + + UrlFor, + Redirecting, + ApiRendering, + Renderers::All, + ConditionalGet, + BasicImplicitRender, + StrongParameters, + + ForceSSL, + DataStreaming, + + # Before callbacks should also be executed as early as possible, so + # also include them at the bottom. + AbstractController::Callbacks, + + # Append rescue at the bottom to wrap as much as possible. + Rescue, + + # Add instrumentations hooks at the bottom, to ensure they instrument + # all the methods properly. + Instrumentation, + + # Params wrapper should come before instrumentation so they are + # properly showed in logs + ParamsWrapper + ] + + MODULES.each do |mod| + include mod + end + + ActiveSupport.run_load_hooks(:action_controller_api, self) + ActiveSupport.run_load_hooks(:action_controller, self) + end +end diff --git a/lib/action_controller/api/api_rendering.rb b/lib/action_controller/api/api_rendering.rb new file mode 100644 index 000000000..52e9f60fc --- /dev/null +++ b/lib/action_controller/api/api_rendering.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module ActionController + module ApiRendering + extend ActiveSupport::Concern + + included do + include Rendering + end + + def render_to_body(options = {}) + _process_options(options) + super + end + end +end \ No newline at end of file diff --git a/lib/action_controller/metal/basic_implicit_render.rb b/lib/action_controller/metal/basic_implicit_render.rb new file mode 100644 index 000000000..9030ea585 --- /dev/null +++ b/lib/action_controller/metal/basic_implicit_render.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module ActionController + module BasicImplicitRender # :nodoc: + def send_action(method, *args) + super.tap { default_render unless performed? } + end + + def default_render(*args) + head :no_content + end + end +end \ No newline at end of file diff --git a/lib/rails5_api_controller_backport.rb b/lib/rails5_api_controller_backport.rb new file mode 100644 index 000000000..252332488 --- /dev/null +++ b/lib/rails5_api_controller_backport.rb @@ -0,0 +1,3 @@ +require_relative 'action_controller/metal/basic_implicit_render' +require_relative 'action_controller/api/api_rendering' +require_relative 'action_controller/api' \ No newline at end of file From cd107916bc6d20ce4107965429202de9c4cfe566 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 9 Jun 2018 05:23:55 +0300 Subject: [PATCH 05/64] Update CodeClimate config --- .codeclimate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index 9df308022..be8f1df7a 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -23,6 +23,7 @@ exclude_patterns: - "bin/" - "config/" - "db/" + - "lib/" - "vendor/" - "test/" - "spec/" From 9b07db8fc96d2bbc67f957460164efceafcf72dd Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 11 Jun 2018 09:53:09 +0300 Subject: [PATCH 06/64] Remove `dev` rake task `db:fixtures:load` should be preferred instead --- lib/tasks/dev.rake | 183 --------------------------------------------- 1 file changed, 183 deletions(-) delete mode 100644 lib/tasks/dev.rake diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake deleted file mode 100644 index e4c120a8d..000000000 --- a/lib/tasks/dev.rake +++ /dev/null @@ -1,183 +0,0 @@ -namespace :dev do - desc 'Generates dummy data in development environment' \ - ' (options: [random] for random data generation - slowest)' - - task :prime, [:random] => :environment do |t, args| - abort 'Production environment is not supported' if Rails.env.production? - - include FactoryBot::Syntax::Methods - - PaperTrail.enabled = false - Domain.paper_trail_on! - Contact.paper_trail_on! - - with_random_data = args[:random].present? - - def create_domain(name:, registrar:, registrant:, account:, price:, reg_time:) - duration = price.duration.sub('mons', 'months').split("\s") - period = duration.first.to_i - period_unit = duration.second[0] - - create(:domain, - name: name, - period: period, - period_unit: period_unit, - registered_at: reg_time, - expire_time: reg_time + period.send(duration.second.to_sym), - created_at: reg_time, - updated_at: reg_time, - registrar: registrar, - registrant: registrant) - - create(:account_activity, - account: account, - sum: -price.price.amount, - activity_type: AccountActivity::CREATE, - created_at: reg_time, - updated_at: reg_time, - price: price) - end - - def generate_default_data - create(:admin_user, username: 'test', password: 'testtest', password_confirmation: 'testtest') - - zone = create(:zone, origin: 'test') - registrar = create(:registrar, name: 'test') - registrant = create(:registrant, name: 'test', registrar: registrar) - - account = create(:account, registrar: registrar, balance: 1_000_000) - api_user = create(:api_user, username: 'test', password: 'testtest', registrar: registrar) - - epp_session = EppSession.new - epp_session.session_id = 'test' - epp_session.user = api_user - epp_session.save! - - domain_counter = 1.step - - Billing::Price.durations.each do |duration| - Billing::Price.operation_categories.each do |operation_category| - price = create(:price, - price: Money.from_amount(duration.to_i * 10), - valid_from: Time.zone.now - rand(1).months, - valid_to: Time.zone.now + rand(1).months, - duration: duration, - operation_category: operation_category, - zone: zone) - - next if operation_category == 'renew' - - (rand(3) + 1).times do - create_domain(name: "test#{domain_counter.next}.test", - registrar: registrar, - registrant: registrant, - account: account, - price: price, - reg_time: 1.month.ago) - end - - (rand(3) + 1).times do - create_domain(name: "test#{domain_counter.next}.test", - registrar: registrar, - registrant: registrant, - account: account, - price: price, - reg_time: Time.zone.now) - end - end - end - - create_domain(name: 'test.test', - registrar: registrar, - registrant: registrant, - account: account, - price: Billing::Price.first, - reg_time: Time.zone.now) - end - - def generate_random_data - zone_count = 10 - admin_user_count = 5 - registrar_count = 50 - api_user_count = 10 - registrant_count = 50 - domain_count = 50 - registrars = [] - registrants = [] - zones = [] - registrant_names = [ - 'John Doe', - 'John Roe', - 'Jane Doe', - 'Jane Roe', - 'John Smith', - ] - - zone_count.times do - origin = SecureRandom.hex[0..(rand(5) + 1)] - zones << create(:zone, origin: origin) - end - - zone_origins = zones.collect { |zone| zone.origin } - - admin_user_count.times do - uid = SecureRandom.hex[0..(rand(5) + 1)] - create(:admin_user, username: "test#{uid}", password: 'testtest', password_confirmation: 'testtest') - end - - registrar_count.times do - uid = SecureRandom.hex[0..(rand(5) + 1)] - registrars << create(:registrar, name: "Acme Ltd. #{uid}") - end - - registrars.each do |registrar| - create(:account, registrar: registrar, balance: rand(99999)) - - api_user_count.times do |i| - create(:api_user, username: "test#{registrar.id}#{i}", password: 'testtest', registrar: registrar) - end - - registrant_count.times do |i| - registrants << create(:registrant, name: registrant_names.sample, registrar: registrar) - end - - domain_count.times do |i| - name = "test#{registrar.id}#{i}#{rand(99999)}.#{zone_origins.sample}" - period = rand(3) + 1 - - create(:domain, - name: name, - period: period, - period_unit: 'y', - registered_at: Time.zone.now, - expire_time: Time.zone.now + period.years, - registrar: registrar, - registrant: registrants.sample) - end - end - - zones.each do |zone| - Billing::Price.durations.each do |duration| - Billing::Price.operation_categories.each do |operation_category| - create(:price, - price: Money.from_amount(rand(10) + 1), - valid_from: Time.zone.now.beginning_of_day, - valid_to: Time.zone.now + (rand(10) + 1).years, - duration: duration, - operation_category: operation_category, - zone: zone) - end - end - end - end - - Setting.api_ip_whitelist_enabled = false - Setting.address_processing = false - Setting.registrar_ip_whitelist_enabled = false - - ActiveRecord::Base.transaction do - generate_default_data - generate_random_data if with_random_data - end - end -end From 81f923ab01d581c7a3f988e0012f0281f5cbfdbb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 11 Jun 2018 10:04:29 +0300 Subject: [PATCH 07/64] Update fixture --- test/fixtures/users.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index b20bd8a83..494cadd24 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -18,6 +18,7 @@ api_goodnames: admin: username: test + encrypted_password: <%= Devise::Encryptor.digest(AdminUser, 'testtest') %> type: AdminUser country_code: US roles: From 4b977dc195d529078bf814e50a7ccda842c20cdd Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 12 Jun 2018 07:25:39 +0300 Subject: [PATCH 08/64] Enable "pgcrypto" postgres engine --- db/migrate/20180612042234_enable_pgcrypto_ext.rb | 5 +++++ db/structure.sql | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 db/migrate/20180612042234_enable_pgcrypto_ext.rb diff --git a/db/migrate/20180612042234_enable_pgcrypto_ext.rb b/db/migrate/20180612042234_enable_pgcrypto_ext.rb new file mode 100644 index 000000000..4e8df65bf --- /dev/null +++ b/db/migrate/20180612042234_enable_pgcrypto_ext.rb @@ -0,0 +1,5 @@ +class EnablePgcryptoExt < ActiveRecord::Migration + def change + enable_extension 'pgcrypto' + end +end diff --git a/db/structure.sql b/db/structure.sql index 744ea9e19..de3c10c61 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -51,6 +51,20 @@ CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public; COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs'; +-- +-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; + + +-- +-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions'; + + SET search_path = public, pg_catalog; -- @@ -4716,3 +4730,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180327151906'); INSERT INTO schema_migrations (version) VALUES ('20180331200125'); +INSERT INTO schema_migrations (version) VALUES ('20180612042234'); + From 981c5642148c980aaee4ca6273e4a3abd548e016 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 12 Jun 2018 07:29:47 +0300 Subject: [PATCH 09/64] Add `contacts.uuid` DB column --- db/migrate/20180612042625_add_uuid_to_contacts.rb | 5 +++++ db/structure.sql | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180612042625_add_uuid_to_contacts.rb diff --git a/db/migrate/20180612042625_add_uuid_to_contacts.rb b/db/migrate/20180612042625_add_uuid_to_contacts.rb new file mode 100644 index 000000000..c80d60e71 --- /dev/null +++ b/db/migrate/20180612042625_add_uuid_to_contacts.rb @@ -0,0 +1,5 @@ +class AddUuidToContacts < ActiveRecord::Migration + def change + add_column :contacts, :uuid, :uuid, default: 'gen_random_uuid()' + end +end diff --git a/db/structure.sql b/db/structure.sql index de3c10c61..1332bccfb 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -639,7 +639,8 @@ CREATE TABLE contacts ( original_id integer, ident_updated_at timestamp without time zone, upid integer, - up_date timestamp without time zone + up_date timestamp without time zone, + uuid uuid DEFAULT gen_random_uuid() ); @@ -4732,3 +4733,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180331200125'); INSERT INTO schema_migrations (version) VALUES ('20180612042234'); +INSERT INTO schema_migrations (version) VALUES ('20180612042625'); + From 1eca44f32c0fcb175d446cedcae3e86a4873789c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 12 Jun 2018 07:34:40 +0300 Subject: [PATCH 10/64] Add `domains.uuid` DB column --- db/migrate/20180612042953_add_uuid_to_domains.rb | 5 +++++ db/structure.sql | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180612042953_add_uuid_to_domains.rb diff --git a/db/migrate/20180612042953_add_uuid_to_domains.rb b/db/migrate/20180612042953_add_uuid_to_domains.rb new file mode 100644 index 000000000..6ca609de3 --- /dev/null +++ b/db/migrate/20180612042953_add_uuid_to_domains.rb @@ -0,0 +1,5 @@ +class AddUuidToDomains < ActiveRecord::Migration + def change + add_column :domains, :uuid, :uuid, default: 'gen_random_uuid()' + end +end diff --git a/db/structure.sql b/db/structure.sql index 1332bccfb..cf2f858b4 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -912,7 +912,8 @@ CREATE TABLE domains ( status_notes hstore, statuses_backup character varying[] DEFAULT '{}'::character varying[], upid integer, - up_date timestamp without time zone + up_date timestamp without time zone, + uuid uuid DEFAULT gen_random_uuid() ); @@ -4735,3 +4736,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180612042234'); INSERT INTO schema_migrations (version) VALUES ('20180612042625'); +INSERT INTO schema_migrations (version) VALUES ('20180612042953'); + From 76f8a46faaf5be30bd70f672feb5559c50e0bb0b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 12 Jun 2018 08:31:41 +0300 Subject: [PATCH 11/64] Update fixtures --- test/fixtures/users.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 494cadd24..036f2183e 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,6 +1,7 @@ api_bestnames: username: test_bestnames password: testtest + encrypted_password: <%= Devise::Encryptor.digest(ApiUser, 'testtest') %> type: ApiUser registrar: bestnames active: true @@ -10,6 +11,7 @@ api_bestnames: api_goodnames: username: test_goodnames password: testtest + encrypted_password: <%= Devise::Encryptor.digest(ApiUser, 'testtest') %> type: ApiUser registrar: goodnames active: true From 5626c87e04c4fd1ac9ce4135ced23ba9dbbe5928 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 13 Jun 2018 07:27:29 +0300 Subject: [PATCH 12/64] Change `contacts.uuid` and `domains.uuid` to NOT NULL --- ...030330_change_contacts_and_domains_uuid_to_not_null.rb | 6 ++++++ db/structure.sql | 6 ++++-- test/fixtures/contacts.yml | 8 ++++++++ test/fixtures/domains.yml | 5 +++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20180613030330_change_contacts_and_domains_uuid_to_not_null.rb diff --git a/db/migrate/20180613030330_change_contacts_and_domains_uuid_to_not_null.rb b/db/migrate/20180613030330_change_contacts_and_domains_uuid_to_not_null.rb new file mode 100644 index 000000000..9d7641082 --- /dev/null +++ b/db/migrate/20180613030330_change_contacts_and_domains_uuid_to_not_null.rb @@ -0,0 +1,6 @@ +class ChangeContactsAndDomainsUuidToNotNull < ActiveRecord::Migration + def change + change_column_null :contacts, :uuid, false + change_column_null :domains, :uuid, false + end +end diff --git a/db/structure.sql b/db/structure.sql index cf2f858b4..9b53ad323 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -640,7 +640,7 @@ CREATE TABLE contacts ( ident_updated_at timestamp without time zone, upid integer, up_date timestamp without time zone, - uuid uuid DEFAULT gen_random_uuid() + uuid uuid DEFAULT gen_random_uuid() NOT NULL ); @@ -913,7 +913,7 @@ CREATE TABLE domains ( statuses_backup character varying[] DEFAULT '{}'::character varying[], upid integer, up_date timestamp without time zone, - uuid uuid DEFAULT gen_random_uuid() + uuid uuid DEFAULT gen_random_uuid() NOT NULL ); @@ -4738,3 +4738,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180612042625'); INSERT INTO schema_migrations (version) VALUES ('20180612042953'); +INSERT INTO schema_migrations (version) VALUES ('20180613030330'); + diff --git a/test/fixtures/contacts.yml b/test/fixtures/contacts.yml index b64dce039..1f2e4b8da 100644 --- a/test/fixtures/contacts.yml +++ b/test/fixtures/contacts.yml @@ -8,6 +8,7 @@ john: registrar: bestnames code: john-001 auth_info: cacb5b + uuid: eb2f2766-b44c-4e14-9f16-32ab1a7cb957 william: &william name: William @@ -27,6 +28,7 @@ william: &william country_code: US statuses: - ok + uuid: 0aa54704-d6f7-4ca9-b8ca-2827d9a4e4eb jane: name: Jane @@ -38,6 +40,7 @@ jane: registrar: bestnames code: jane-001 auth_info: 0aa09f + uuid: 9db3de62-2414-4487-bee2-d5c155567768 acme_ltd: name: Acme Ltd @@ -49,6 +52,7 @@ acme_ltd: ident_country_code: US code: acme-ltd-001 auth_info: 720b3c + uuid: f1dd365c-5be9-4b3d-a44e-3fa002465e4d jack: name: Jack @@ -60,12 +64,14 @@ jack: ident_country_code: US code: jack-001 auth_info: e2c440 + uuid: 28b65455-6f1a-49fd-961c-0758886dbd75 identical_to_william: <<: *william registrar: goodnames code: william-002 auth_info: 5ab865 + uuid: c0a191d5-3793-4f0b-8f85-491612d0293e not_in_use: name: Useless @@ -73,6 +79,7 @@ not_in_use: registrar: bestnames code: useless-001 auth_info: e75a2a + uuid: ca613cc5-a8dc-48c1-8d32-d3c6a0b6c952 invalid: name: any @@ -80,3 +87,4 @@ invalid: email: invalid@invalid.test auth_info: any registrar: bestnames + uuid: bd80c0f9-26ee-49e0-a2cb-2311d931c433 \ No newline at end of file diff --git a/test/fixtures/domains.yml b/test/fixtures/domains.yml index 53de2837b..59a1b8ea5 100644 --- a/test/fixtures/domains.yml +++ b/test/fixtures/domains.yml @@ -7,6 +7,7 @@ shop: valid_to: 2010-07-05 period: 1 period_unit: m + uuid: 1b3ee442-e8fe-4922-9492-8fcb9dccc69c airport: name: airport.test @@ -17,6 +18,7 @@ airport: valid_to: 2010-07-05 period: 1 period_unit: m + uuid: 2df2c1a1-8f6a-490a-81be-8bdf29866880 library: name: library.test @@ -27,6 +29,7 @@ library: valid_to: 2010-07-05 period: 1 period_unit: m + uuid: 647bcc48-8d5e-4a04-8ce5-2a3cd17b6eab metro: name: metro.test @@ -37,6 +40,7 @@ metro: valid_to: 2010-07-05 period: 1 period_unit: m + uuid: ef97cb80-333b-4893-b9df-163f2b452798 invalid: name: invalid.test @@ -44,3 +48,4 @@ invalid: valid_to: <%= Time.zone.parse('2010-07-05').utc.to_s(:db) %> registrar: bestnames registrant: invalid + uuid: 3c430ead-bb17-4b5b-aaa1-caa7dde7e138 \ No newline at end of file From 183eca884e5010233b9472d63c0809182d7af486 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 13 Jun 2018 08:03:19 +0300 Subject: [PATCH 13/64] Add `contacts.uuid` and `domains.uuid` uniq constraints --- ...ontacts_and_domains_uuid_uniq_constraint.rb | 15 +++++++++++++++ db/structure.sql | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 db/migrate/20180613045614_add_contacts_and_domains_uuid_uniq_constraint.rb diff --git a/db/migrate/20180613045614_add_contacts_and_domains_uuid_uniq_constraint.rb b/db/migrate/20180613045614_add_contacts_and_domains_uuid_uniq_constraint.rb new file mode 100644 index 000000000..99e9b823d --- /dev/null +++ b/db/migrate/20180613045614_add_contacts_and_domains_uuid_uniq_constraint.rb @@ -0,0 +1,15 @@ +class AddContactsAndDomainsUuidUniqConstraint < ActiveRecord::Migration + def up + execute <<-SQL + ALTER TABLE contacts ADD CONSTRAINT uniq_contact_uuid UNIQUE (uuid); + ALTER TABLE domains ADD CONSTRAINT uniq_domain_uuid UNIQUE (uuid); + SQL + end + + def down + execute <<-SQL + ALTER TABLE contacts DROP CONSTRAINT uniq_contact_uuid; + ALTER TABLE domains DROP CONSTRAINT uniq_domain_uuid; + SQL + end +end diff --git a/db/structure.sql b/db/structure.sql index 9b53ad323..b491b6f5a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -3258,6 +3258,22 @@ ALTER TABLE ONLY settings ADD CONSTRAINT settings_pkey PRIMARY KEY (id); +-- +-- Name: uniq_contact_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY contacts + ADD CONSTRAINT uniq_contact_uuid UNIQUE (uuid); + + +-- +-- Name: uniq_domain_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY domains + ADD CONSTRAINT uniq_domain_uuid UNIQUE (uuid); + + -- -- Name: unique_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -4740,3 +4756,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180612042953'); INSERT INTO schema_migrations (version) VALUES ('20180613030330'); +INSERT INTO schema_migrations (version) VALUES ('20180613045614'); + From fc3c70c5ee14e2b92b4c5b5237a35d2be3779904 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 13 Jun 2018 08:08:14 +0300 Subject: [PATCH 14/64] Add clarifying comment --- ...180613045614_add_contacts_and_domains_uuid_uniq_constraint.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/migrate/20180613045614_add_contacts_and_domains_uuid_uniq_constraint.rb b/db/migrate/20180613045614_add_contacts_and_domains_uuid_uniq_constraint.rb index 99e9b823d..32b8fb090 100644 --- a/db/migrate/20180613045614_add_contacts_and_domains_uuid_uniq_constraint.rb +++ b/db/migrate/20180613045614_add_contacts_and_domains_uuid_uniq_constraint.rb @@ -1,3 +1,4 @@ +# Unique constraint is needed to prevent accidental duplicate values in fixtures to appear in DB class AddContactsAndDomainsUuidUniqConstraint < ActiveRecord::Migration def up execute <<-SQL From bf53ca5947774c9558d13d070bf493b9cf0d9c22 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 13 Jun 2018 10:35:18 +0300 Subject: [PATCH 15/64] Nullify contact's uuid when transferring It will be generated on DB level --- app/models/concerns/contact/transferable.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index 14c1cac3c..3f151251a 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -16,6 +16,7 @@ module Concerns::Contact::Transferable new_contact.regenerate_code new_contact.regenerate_auth_info new_contact.remove_address unless self.class.address_processing? + new_contact.uuid = nil new_contact.save(validate: false) new_contact end From 2f44dac144382f11754b5dc4fb354819b4264c29 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 14 Jun 2018 09:52:04 +0300 Subject: [PATCH 16/64] Remove code climate issue count badge --- README.md | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a8a85a3d8..5beca0a87 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ Domain Registry =============== [![Build Status](https://travis-ci.org/internetee/registry.svg?branch=master)](https://travis-ci.org/internetee/registry) [![Code Climate](https://codeclimate.com/github/internetee/registry/badges/gpa.svg)](https://codeclimate.com/github/internetee/registry) -[![Issue Count](https://codeclimate.com/github/internetee/registry/badges/issue_count.svg)](https://codeclimate.com/github/internetee/registry) [![Test Coverage](https://codeclimate.com/github/internetee/registry/badges/coverage.svg)](https://codeclimate.com/github/internetee/registry/coverage) [![Documentation Status](https://readthedocs.org/projects/eeregistry/badge/?version=latest)](http://docs.internet.ee/en/latest/?badge=latest) @@ -31,7 +30,7 @@ Documentation Installation ------------ -### Registry app +### Registry app Registry based on Rails 4 installation (rbenv install is under Debian build doc) @@ -57,7 +56,7 @@ Manual demo install and database setup: tar -xzvf mod_epp-1.10.tar.gz cd mod_epp-1.10 -Patch mod_epp for Rack. Beacause Rack multipart parser expects specifically +Patch mod_epp for Rack. Beacause Rack multipart parser expects specifically formatted content boundaries, the mod_epp needs to be modified before building: wget https://github.com/internetee/registry/raw/master/doc/patches/mod_epp_1.10-rack-friendly.patch @@ -136,7 +135,7 @@ For Apache, registry admin goes to port 443 in production, /etc/apache2/sites-en ``` -Registrar configuration (/etc/apache2/sites-enabled/registrar.conf) is as follows: +Registrar configuration (/etc/apache2/sites-enabled/registrar.conf) is as follows: ``` ServerName your-registrar-domain @@ -179,7 +178,7 @@ Registrar configuration (/etc/apache2/sites-enabled/registrar.conf) is as follow # for Apache verison 2.4 or newer # Require all granted - + Options -MultiViews @@ -220,7 +219,7 @@ Registrar configuration (/etc/apache2/sites-enabled/registrar.conf) is as follow ``` -Registrant configuration (/etc/apache2/sites-enabled/registrant.conf) is as follows: +Registrant configuration (/etc/apache2/sites-enabled/registrant.conf) is as follows: ``` ServerName your-registrant-domain @@ -263,7 +262,7 @@ Registrant configuration (/etc/apache2/sites-enabled/registrant.conf) is as foll # for Apache verison 2.4 or newer # Require all granted - + Options -MultiViews @@ -271,11 +270,11 @@ Registrant configuration (/etc/apache2/sites-enabled/registrant.conf) is as foll Allow from none Deny from all - + Allow from all - + Allow from all @@ -342,8 +341,8 @@ For Apache, REPP goes to port 443 in production, /etc/apache2/sites-enabled/repp ``` -For Apache, epp goes to port 700. -Be sure to update paths to match your system configuration. +For Apache, epp goes to port 700. +Be sure to update paths to match your system configuration. /etc/apache2/sites-enabled/epp.conf short example: ```apache @@ -405,7 +404,7 @@ Be sure to update paths to match your system configuration. EPPSessionRoot /proxy/session EPPErrorRoot /proxy/error EPPRawFrame raw_frame - + ProxyPass /proxy/ http://localhost:8080/epp/ EPPAuthURI implicit @@ -421,7 +420,7 @@ Enable epp_ssl and restart apache Now you should see registry admin at https://your-domain -All registry demo data can be found at: +All registry demo data can be found at: db/seeds.rb @@ -464,4 +463,3 @@ Please follow EPP web client readme: Please follow WHOIS server readme: https://github.com/internetee/whois - From 435147ca464042b1cdbe9b08dc7612f71c6e8848 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 14 Jun 2018 13:42:23 +0300 Subject: [PATCH 17/64] Fix country drop-down UI --- app/models/sorted_country.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/sorted_country.rb b/app/models/sorted_country.rb index 19ad5f4f3..7b27adacb 100644 --- a/app/models/sorted_country.rb +++ b/app/models/sorted_country.rb @@ -18,7 +18,7 @@ class SortedCountry def quick_list @quick_list ||= [ - %w[Estonia' EE], + %w[Estonia EE], %w[Finland FI], %w[Latvia LV], %w[Lithuania LT], From afa275c80512cf343e62760764f9d97cbcb4b957 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Fri, 15 Jun 2018 11:02:27 +0300 Subject: [PATCH 18/64] Move docker configuration to https://github.com/internetee/docker-images --- Dockerfile | 18 ++---------------- docker-compose.yml | 33 --------------------------------- docker/docker_dev.sh | 6 ------ docker/docker_test.sh | 8 -------- docker/nginx.template | 29 ----------------------------- 5 files changed, 2 insertions(+), 92 deletions(-) delete mode 100644 docker-compose.yml delete mode 100755 docker/docker_dev.sh delete mode 100755 docker/docker_test.sh delete mode 100644 docker/nginx.template diff --git a/Dockerfile b/Dockerfile index 480231fc2..bd0cbc07b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,9 @@ -FROM ruby:2.3 +FROM internetee/ruby:2.3 MAINTAINER maciej.szlosarczyk@internet.ee -RUN apt-get update > /dev/null && apt-get install -y > /dev/null \ - build-essential \ - nodejs \ - imagemagick \ - postgresql-client - -RUN apt-get install -y > /dev/null \ - qt5-default \ - libqt5webkit5-dev \ - gstreamer1.0-plugins-base \ - gstreamer1.0-tools \ - qtdeclarative5-dev \ - gstreamer1.0-x - RUN mkdir -p /opt/webapps/app/tmp/pids WORKDIR /opt/webapps/app - COPY Gemfile Gemfile.lock ./ RUN gem install bundler && bundle install --jobs 20 --retry 5 + EXPOSE 3000 diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 5c5f523de..000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: "3.2" - -services: - app: - tty: true - stdin_open: true - build: - context: . - dockerfile: Dockerfile - links: - - db - environment: - - APP_DBHOST=db - volumes: - - .:/opt/webapps/app - ports: - - "3000:3000" - command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails server -p 3000 -b '0.0.0.0'" - - web: - image: nginx - volumes: - - ./docker/nginx.template:/etc/nginx/conf.d/nginx.template - ports: - - "80:80" - links: - - app - environment: - APP: 'app' - command: /bin/bash -c "envsubst '$$APP' < /etc/nginx/conf.d/nginx.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" - - db: - image: postgres:9.4 diff --git a/docker/docker_dev.sh b/docker/docker_dev.sh deleted file mode 100755 index f5592517f..000000000 --- a/docker/docker_dev.sh +++ /dev/null @@ -1,6 +0,0 @@ -# /bin/sh -docker-compose down -docker-compose build -docker-compose run app rake db:setup:all -docker-compose run app rake db:migrate -docker-compose run app rake dev:prime diff --git a/docker/docker_test.sh b/docker/docker_test.sh deleted file mode 100755 index 7239f78a9..000000000 --- a/docker/docker_test.sh +++ /dev/null @@ -1,8 +0,0 @@ -# /bin/sh -docker-compose down -docker-compose build - -# Setup test database -docker-compose run app rake db:setup:all test -# Finally run tests to check if everything is in order -docker-compose run app rspec diff --git a/docker/nginx.template b/docker/nginx.template deleted file mode 100644 index 50f6e8548..000000000 --- a/docker/nginx.template +++ /dev/null @@ -1,29 +0,0 @@ -log_format le_json '{ "time": "$time_iso8601", ' - '"remote_addr": "$remote_addr", ' - '"remote_user": "$remote_user", ' - '"body_bytes_sent": "$body_bytes_sent", ' - '"request_time": "$request_time", ' - '"status": "$status", ' - '"request": "$request", ' - '"request_method": "$request_method", ' - '"http_referrer": "$http_referer", ' - '"http_user_agent": "$http_user_agent" }'; - -upstream app { - server ${APP}:3000; -} - -server { - listen 80; - - access_log /var/log/nginx/access.log le_json; - - location / { - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - proxy_pass http://app; - break; - } -} From e1db29f5232402dbcf94bb1cc947289e33a9de19 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 15 Jun 2018 15:37:47 +0300 Subject: [PATCH 19/64] Remove unused code --- app/mailers/domain_mailer.rb | 16 +---- app/models/domain.rb | 4 -- app/models/domain_mail_model.rb | 117 -------------------------------- 3 files changed, 1 insertion(+), 136 deletions(-) delete mode 100644 app/models/domain_mail_model.rb diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index f14f4b4a7..d92e79ac0 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -45,18 +45,4 @@ class DomainMailer < ApplicationMailer subject: "#{I18n.t(:delete_confirmation_subject, name: @domain.name)} [#{@domain.name}]") end - - private - # app/models/DomainMailModel provides the data for mail that can be composed_from - # which ensures that values of objects are captured when they are valid, not later when this method is executed - def compose_from(params) - @params = params - return if delivery_off?(params, params[:deliver_emails]) - return if whitelist_blocked?(params[:recipient]) - params[:errors].map do |error| - logger.warn error - return - end - mail(to: params[:recipient], subject: params[:subject]) - end -end +end \ No newline at end of file diff --git a/app/models/domain.rb b/app/models/domain.rb index 3fc3bf0d6..0f3afed90 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -581,10 +581,6 @@ class Domain < ActiveRecord::Base end end - def send_mail(action) - DomainMailer.send(action, DomainMailModel.new(self).send(action)).deliver - end - def admin_contact_names admin_contacts.names end diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb deleted file mode 100644 index 3f92a3138..000000000 --- a/app/models/domain_mail_model.rb +++ /dev/null @@ -1,117 +0,0 @@ -class DomainMailModel - # Capture current values used in app/views/mailers/domain_mailer/* and app/mailers/domain_mailer will send later - - def initialize(domain) - @domain = domain - @params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id} - end - - def pending_delete_rejected_notification - registrant - subject(:pending_delete_rejected_notification_subject) - compose - end - - def pending_delete_expired_notification - registrant - subject(:pending_delete_expired_notification_subject) - compose - end - - def delete_confirmation - registrant - subject(:delete_confirmation_subject) - compose - end - - def force_delete - admins - subject(:force_delete_subject) - compose - end - - private - - def registrant_old - @params[:recipient] = format Registrant.find(@domain.registrant_id_was).email - end - - def registrant - @params[:recipient] = format @domain.registrant.email - end - - def registrant_pending - @params[:recipient] = format @domain.pending_json['new_registrant_email'] - @params[:new_registrant_name] = @domain.pending_json['new_registrant_name'] - @params[:old_registrant_name] = @domain.registrant.name - end - - # registrant and domain admin contacts - def admins - emails = ([@domain.registrant.email] + @domain.admin_contacts.map { |x| format(x.email) }) - @params[:recipient] = emails.uniq.map { |x| format(x) } - end - - # puny internet domain name, TODO: username - def format(email) - return warn_no_email if email.nil? - user, host = email.split('@') - host = SimpleIDN.to_ascii(host) - "#{user}@#{host}" - end - - def subject(subject) - @params[:name] = @domain.name - @params[:subject] = "#{I18n.t(subject, name: @domain.name)}, [#{@domain.name}]" - end - - def confirm_update - verification_url('domain_update_confirms') - end - - def compose - @params - end - - def verification_url(path) - token = verification_token or return - @params[:verification_url] = "#{ENV['registrant_url']}/registrant/#{path}/#{@domain.id}?token=#{token}" - end - - def verification_token - return warn_missing(:registrant_verification_token) if @domain.registrant_verification_token.blank? - return warn_missing(:registrant_verification_asked_at) if @domain.registrant_verification_asked_at.blank? - @domain.registrant_verification_token - end - - def domain_info - [:name, :registrar_name, - :registrant_name, :registrant_ident, :registrant_email, - :registrant_street,:registrant_city - ].each do |attr| - @params.store attr, @domain.send(attr) - end - @params.store :registrant_country, @domain.registrant_country.name - @params.store :registrant_priv, @domain.registrant.priv? - @params.store :old_registrant_name, Registrant.find(@domain.registrant_id_was).name - @params - end - - def warn_no_email(item = 'email') - warn_missing item - nil - end - - def warn_missing(item) - warn_not_delivered "#{item.to_s} is missing for #{@domain.name}" - end - - def warn_not_delivered(reason) - message = "EMAIL NOT DELIVERED: #{reason}" - @params[:errors] << message -# Rails.logger.warn message - nil - end - -end - From eeeb806564f6fac905c15add8b3c4b670bcf5a1b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 17 Jun 2018 18:55:37 +0300 Subject: [PATCH 20/64] Convert HAML to ERB --- .../contacts/partials/_address.haml | 23 ------- .../contacts/partials/_address.html.erb | 35 +++++++++++ .../contacts/partials/_domains.haml | 30 --------- .../contacts/partials/_domains.html.erb | 60 ++++++++++++++++++ .../contacts/partials/_general.haml | 48 -------------- .../contacts/partials/_general.html.erb | 63 +++++++++++++++++++ .../registrant/contacts/partials/_search.haml | 6 -- .../contacts/partials/_search.html.erb | 6 ++ .../contacts/partials/_statuses.haml | 21 ------- .../contacts/partials/_statuses.html.erb | 36 +++++++++++ app/views/registrant/contacts/show.haml | 11 ---- app/views/registrant/contacts/show.html.erb | 23 +++++++ 12 files changed, 223 insertions(+), 139 deletions(-) delete mode 100644 app/views/registrant/contacts/partials/_address.haml create mode 100644 app/views/registrant/contacts/partials/_address.html.erb delete mode 100644 app/views/registrant/contacts/partials/_domains.haml create mode 100644 app/views/registrant/contacts/partials/_domains.html.erb delete mode 100644 app/views/registrant/contacts/partials/_general.haml create mode 100644 app/views/registrant/contacts/partials/_general.html.erb delete mode 100644 app/views/registrant/contacts/partials/_search.haml create mode 100644 app/views/registrant/contacts/partials/_search.html.erb delete mode 100644 app/views/registrant/contacts/partials/_statuses.haml create mode 100644 app/views/registrant/contacts/partials/_statuses.html.erb delete mode 100644 app/views/registrant/contacts/show.haml create mode 100644 app/views/registrant/contacts/show.html.erb diff --git a/app/views/registrant/contacts/partials/_address.haml b/app/views/registrant/contacts/partials/_address.haml deleted file mode 100644 index fe57bd393..000000000 --- a/app/views/registrant/contacts/partials/_address.haml +++ /dev/null @@ -1,23 +0,0 @@ -.panel.panel-default - .panel-heading - %h3.panel-title= t(:address) - .panel-body - %dl.dl-horizontal - - if @contact.org_name.present? - %dt= t(:org_name) - %dd= @contact.org_name - - %dt= t(:street) - %dd= @contact.street - - %dt= t(:city) - %dd= @contact.city - - %dt= t(:zip) - %dd= @contact.zip - - %dt= t(:state) - %dd= @contact.state - - %dt= t(:country) - %dd= @contact.country diff --git a/app/views/registrant/contacts/partials/_address.html.erb b/app/views/registrant/contacts/partials/_address.html.erb new file mode 100644 index 000000000..5804f89e9 --- /dev/null +++ b/app/views/registrant/contacts/partials/_address.html.erb @@ -0,0 +1,35 @@ +
+
+

+ <%= t(:address) %> +

+
+ +
+
+ <% if @contact.org_name.present? %> +
+ <%= t(:org_name) %> +
+
+ <%= @contact.org_name %> +
+ <% end %> + +
<%= t(:street) %>
+
<%= @contact.street %>
+ +
<%= t(:city) %>
+
<%= @contact.city %>
+ +
<%= t(:zip) %>
+
<%= @contact.zip %>
+ +
<%= t(:state) %>
+
<%= @contact.state %>
+ +
<%= t(:country) %>
+
<%= @contact.country %>
+
+
+
\ No newline at end of file diff --git a/app/views/registrant/contacts/partials/_domains.haml b/app/views/registrant/contacts/partials/_domains.haml deleted file mode 100644 index 011b9c404..000000000 --- a/app/views/registrant/contacts/partials/_domains.haml +++ /dev/null @@ -1,30 +0,0 @@ -- domains = contact.all_domains(page: params[:domain_page], per: 20, params: params.merge(leave_domains: domain_ids)) -#contacts.panel.panel-default - .panel-heading - .pull-left - = t(:domains) - .pull-right - = form_tag request.path, method: :get do - = select_tag :domain_filter, options_for_select(%w(Registrant AdminDomainContact TechDomainContact), selected: params[:domain_filter]), - include_blank: true, class: 'form-control2 selectize2' - %button.btn.btn-primary - %span.glyphicon.glyphicon-search - .clearfix - - .table-responsive - %table.table.table-hover.table-bordered.table-condensed - %thead - %tr - %th{class: 'col-xs-3'}=custom_sort_link t(:domain_name), :name - %th{class: 'col-xs-3'}=custom_sort_link t(:registrar_name), :registrar_name - %th{class: 'col-xs-3'}=custom_sort_link t(:valid_to), :valid_to - %th{class: 'col-xs-3'}=custom_sort_link Domain.human_attribute_name(:roles), :roles - %tbody - - domains.each do |x| - %tr - %td= link_to(x.name, [:registrant, x]) - %td= link_to(x.registrar, [:registrant, x.registrar]) - %td= l(x.valid_to, format: :short) - %td= x.roles.join(", ") - -= paginate domains, param_name: :domain_page diff --git a/app/views/registrant/contacts/partials/_domains.html.erb b/app/views/registrant/contacts/partials/_domains.html.erb new file mode 100644 index 000000000..ce1cc271d --- /dev/null +++ b/app/views/registrant/contacts/partials/_domains.html.erb @@ -0,0 +1,60 @@ +<% domains = contact.all_domains(page: params[:domain_page], per: 20, params: + params.merge(leave_domains: domain_ids)) %> + +
+
+
+ <%= t(:domains) %> +
+ +
+ <%= form_tag request.path, method: :get do %> + <%= select_tag :domain_filter, + options_for_select(%w(Registrant AdminDomainContact TechDomainContact), + selected: params[:domain_filter]), + include_blank: true, + class: 'form-control2 selectize2' %> + + <% end %> +
+
+
+ +
+ + + + + + + + + + + <% domains.each do |x| %> + + + + + + + <% end %> + +
<%= custom_sort_link t(:domain_name), :name %> + <%= custom_sort_link t(:registrar_name), :registrar_name %> + <%= custom_sort_link t(:valid_to), :valid_to %> + <%= custom_sort_link Domain.human_attribute_name(:roles), :roles %> +
+ <%= link_to(x.name, [:registrant, x]) %> + + <%= link_to(x.registrar, [:registrant, x.registrar]) %> + + <%= l(x.valid_to, format: :short) %> + + <%= x.roles.join(", ") %> +
+
+
+<%= paginate domains, param_name: :domain_page %> \ No newline at end of file diff --git a/app/views/registrant/contacts/partials/_general.haml b/app/views/registrant/contacts/partials/_general.haml deleted file mode 100644 index 6a59cdfef..000000000 --- a/app/views/registrant/contacts/partials/_general.haml +++ /dev/null @@ -1,48 +0,0 @@ -.panel.panel-default - .panel-heading - %h3.panel-title= t(:general) - .panel-body - %dl.dl-horizontal - %dt= t(:id) - %dd= @contact.code - - %dt= t(:name) - %dd= @contact.name - - %dt= t(:password) - %dd - = text_field_tag :auth_info, @contact.auth_info, readonly: true, class: 'partially-hidden' - - %br - - %dt= t(:ident) - %dd= ident_for(@contact) - - %dt= t(:email) - %dd= @contact.email - - %dt= t(:phone) - %dd= @contact.phone - - - if @contact.fax - %dt= t(:fax) - %dd= @contact.fax - - %br - - %dt= Contact.human_attribute_name :created_at - %dd - = l(@contact.created_at, format: :short) - by - = @contact.name - - %dt= Contact.human_attribute_name :updated_at - %dd - = l(@contact.updated_at, format: :short) - by - = @contact.name - - %dt= t(:registrar_name) - %dd - - if @contact.registrar.present? - = link_to(@contact.registrar, registrant_registrar_path(@contact.registrar)) diff --git a/app/views/registrant/contacts/partials/_general.html.erb b/app/views/registrant/contacts/partials/_general.html.erb new file mode 100644 index 000000000..db57f1b65 --- /dev/null +++ b/app/views/registrant/contacts/partials/_general.html.erb @@ -0,0 +1,63 @@ +
+
+

+ <%= t(:general) %> +

+
+ +
+
+
<%= t(:id) %>
+
<%= @contact.code %>
+ +
<%= t(:name) %>
+
<%= @contact.name %>
+ +
<%= t(:password) %>
+
<%= text_field_tag :auth_info, @contact.auth_info, readonly: true, + class: 'partially-hidden' %>
+
+ +
<%= t(:ident) %>
+
<%= ident_for(@contact) %>
+ +
<%= t(:email) %>
+
<%= @contact.email %>
+ +
<%= t(:phone) %>
+
<%= @contact.phone %>
+ + <% if @contact.fax %> +
+ <%= t(:fax) %> +
+
+ <%= @contact.fax %> +
+ <% end %> + +
+ +
<%= Contact.human_attribute_name :created_at %>
+
+ <%= l(@contact.created_at, format: :short) %> + by + <%= @contact.name %> +
+ +
<%= Contact.human_attribute_name :updated_at %>
+
+ <%= l(@contact.updated_at, format: :short) %> + by + <%= @contact.name %> +
+ +
<%= t(:registrar_name) %>
+
+ <% if @contact.registrar.present? %> + <%= link_to @contact.registrar, registrant_registrar_path(@contact.registrar) %> + <% end %> +
+
+
+
\ No newline at end of file diff --git a/app/views/registrant/contacts/partials/_search.haml b/app/views/registrant/contacts/partials/_search.haml deleted file mode 100644 index 4a723bf6b..000000000 --- a/app/views/registrant/contacts/partials/_search.haml +++ /dev/null @@ -1,6 +0,0 @@ -= search_form_for [:registrant, @q] do |f| - = f.search_field :name_cont - = f.submit do - %span.glyphicon.glyphicon-search - - diff --git a/app/views/registrant/contacts/partials/_search.html.erb b/app/views/registrant/contacts/partials/_search.html.erb new file mode 100644 index 000000000..f44fa322f --- /dev/null +++ b/app/views/registrant/contacts/partials/_search.html.erb @@ -0,0 +1,6 @@ +<%= search_form_for [:registrant, @q] do |f| %> + <%= f.search_field :name_cont %> + <%= f.submit do %> + + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/registrant/contacts/partials/_statuses.haml b/app/views/registrant/contacts/partials/_statuses.haml deleted file mode 100644 index c39075754..000000000 --- a/app/views/registrant/contacts/partials/_statuses.haml +++ /dev/null @@ -1,21 +0,0 @@ -- panel_class = contact.errors.messages[:statuses] ? 'panel-danger' : 'panel-default' -#contact_statuses.panel{class: panel_class} - .panel-heading.clearfix - = t(:statuses) - .table-responsive - %table.table.table-hover.table-bordered.table-condensed - %thead - %tr - %th{class: 'col-xs-6'}= t(:status) - %th{class: 'col-xs-6'}= t(:notes) - %tbody - - contact.statuses.each do |status| - %tr - %td= status - %td= contact.status_notes[status] - - - if contact.errors.messages[:statuses] - %tfoot - - @domain.errors.messages[:statuses].each do |s| - %tr - %td{colspan: 4}= s diff --git a/app/views/registrant/contacts/partials/_statuses.html.erb b/app/views/registrant/contacts/partials/_statuses.html.erb new file mode 100644 index 000000000..e3bbab10d --- /dev/null +++ b/app/views/registrant/contacts/partials/_statuses.html.erb @@ -0,0 +1,36 @@ +<% panel_class = contact.errors.messages[:statuses] ? 'panel-danger' : 'panel-default' %> +
+
+ <%= t(:statuses) %> +
+ +
+ + + + + + + + + + <% contact.statuses.each do |status| %> + + + + + <% end %> + + + <% if contact.errors.messages[:statuses] %> + + <% @domain.errors.messages[:statuses].each do |s| %> + + + + <% end %> + + <% end %> +
<%= t(:status) %><%= t(:notes) %>
<%= status %><%= contact.status_notes[status] %>
<%= s %>
+
+
\ No newline at end of file diff --git a/app/views/registrant/contacts/show.haml b/app/views/registrant/contacts/show.haml deleted file mode 100644 index 521a8d549..000000000 --- a/app/views/registrant/contacts/show.haml +++ /dev/null @@ -1,11 +0,0 @@ -= render 'shared/title', name: @contact.name - -.row - .col-md-6= render 'registrant/contacts/partials/general' - .col-md-6= render 'registrant/contacts/partials/address' -.row - .col-md-12= render 'registrant/contacts/partials/statuses', contact: @contact -.row - .col-md-12= render 'registrant/contacts/partials/domains', contact: @contact - - diff --git a/app/views/registrant/contacts/show.html.erb b/app/views/registrant/contacts/show.html.erb new file mode 100644 index 000000000..7ead6b0e3 --- /dev/null +++ b/app/views/registrant/contacts/show.html.erb @@ -0,0 +1,23 @@ +<%= render 'shared/title', name: @contact.name %> + +
+
+ <%= render 'registrant/contacts/partials/general' %> +
+ +
+ <%= render 'registrant/contacts/partials/address' %> +
+
+ +
+
+ <%= render 'registrant/contacts/partials/statuses', contact: @contact %> +
+
+ +
+
+ <%= render 'registrant/contacts/partials/domains', contact: @contact %> +
+
\ No newline at end of file From 05e5138a35060e7552cadf6e55a051dc75d789ec Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 17 Jun 2018 18:57:48 +0300 Subject: [PATCH 21/64] Use standard header --- app/views/registrant/contacts/show.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/registrant/contacts/show.html.erb b/app/views/registrant/contacts/show.html.erb index 7ead6b0e3..9fdf41e02 100644 --- a/app/views/registrant/contacts/show.html.erb +++ b/app/views/registrant/contacts/show.html.erb @@ -1,4 +1,6 @@ -<%= render 'shared/title', name: @contact.name %> +
From 08bcdfc5d45ebc5bcabad37c1af0cc214e1131ec Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 17 Jun 2018 19:01:29 +0300 Subject: [PATCH 22/64] Improve naming --- app/views/registrant/contacts/show.html.erb | 8 ++++---- .../contacts/{partials => show}/_address.html.erb | 0 .../contacts/{partials => show}/_domains.html.erb | 0 .../contacts/{partials => show}/_general.html.erb | 0 .../contacts/{partials => show}/_search.html.erb | 0 .../contacts/{partials => show}/_statuses.html.erb | 0 6 files changed, 4 insertions(+), 4 deletions(-) rename app/views/registrant/contacts/{partials => show}/_address.html.erb (100%) rename app/views/registrant/contacts/{partials => show}/_domains.html.erb (100%) rename app/views/registrant/contacts/{partials => show}/_general.html.erb (100%) rename app/views/registrant/contacts/{partials => show}/_search.html.erb (100%) rename app/views/registrant/contacts/{partials => show}/_statuses.html.erb (100%) diff --git a/app/views/registrant/contacts/show.html.erb b/app/views/registrant/contacts/show.html.erb index 9fdf41e02..6d08feccc 100644 --- a/app/views/registrant/contacts/show.html.erb +++ b/app/views/registrant/contacts/show.html.erb @@ -4,22 +4,22 @@
- <%= render 'registrant/contacts/partials/general' %> + <%= render 'registrant/contacts/show/general' %>
- <%= render 'registrant/contacts/partials/address' %> + <%= render 'registrant/contacts/show/address' %>
- <%= render 'registrant/contacts/partials/statuses', contact: @contact %> + <%= render 'registrant/contacts/show/statuses', contact: @contact %>
- <%= render 'registrant/contacts/partials/domains', contact: @contact %> + <%= render 'registrant/contacts/show/domains', contact: @contact %>
\ No newline at end of file diff --git a/app/views/registrant/contacts/partials/_address.html.erb b/app/views/registrant/contacts/show/_address.html.erb similarity index 100% rename from app/views/registrant/contacts/partials/_address.html.erb rename to app/views/registrant/contacts/show/_address.html.erb diff --git a/app/views/registrant/contacts/partials/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb similarity index 100% rename from app/views/registrant/contacts/partials/_domains.html.erb rename to app/views/registrant/contacts/show/_domains.html.erb diff --git a/app/views/registrant/contacts/partials/_general.html.erb b/app/views/registrant/contacts/show/_general.html.erb similarity index 100% rename from app/views/registrant/contacts/partials/_general.html.erb rename to app/views/registrant/contacts/show/_general.html.erb diff --git a/app/views/registrant/contacts/partials/_search.html.erb b/app/views/registrant/contacts/show/_search.html.erb similarity index 100% rename from app/views/registrant/contacts/partials/_search.html.erb rename to app/views/registrant/contacts/show/_search.html.erb diff --git a/app/views/registrant/contacts/partials/_statuses.html.erb b/app/views/registrant/contacts/show/_statuses.html.erb similarity index 100% rename from app/views/registrant/contacts/partials/_statuses.html.erb rename to app/views/registrant/contacts/show/_statuses.html.erb From 42b01512afa2e847d3ae2d2c9806b5fe2ce6615a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 17 Jun 2018 19:28:01 +0300 Subject: [PATCH 23/64] Improve translations --- .../contacts/show/_address.html.erb | 20 +++++++--------- .../contacts/show/_domains.html.erb | 12 ++++++---- .../contacts/show/_general.html.erb | 24 ++++++++----------- .../contacts/show/_statuses.html.erb | 6 ++--- config/locales/registrant/contacts.en.yml | 17 +++++++++++++ 5 files changed, 46 insertions(+), 33 deletions(-) create mode 100644 config/locales/registrant/contacts.en.yml diff --git a/app/views/registrant/contacts/show/_address.html.erb b/app/views/registrant/contacts/show/_address.html.erb index 5804f89e9..c9bc80150 100644 --- a/app/views/registrant/contacts/show/_address.html.erb +++ b/app/views/registrant/contacts/show/_address.html.erb @@ -1,34 +1,30 @@

- <%= t(:address) %> + <%= t '.header' %>

<% if @contact.org_name.present? %> -
- <%= t(:org_name) %> -
-
- <%= @contact.org_name %> -
+
<%= Contact.human_attribute_name :org_name %>
+
<%= @contact.org_name %>
<% end %> -
<%= t(:street) %>
+
<%= Contact.human_attribute_name :street %>
<%= @contact.street %>
-
<%= t(:city) %>
+
<%= Contact.human_attribute_name :city %>
<%= @contact.city %>
-
<%= t(:zip) %>
+
<%= Contact.human_attribute_name :zip %>
<%= @contact.zip %>
-
<%= t(:state) %>
+
<%= Contact.human_attribute_name :state %>
<%= @contact.state %>
-
<%= t(:country) %>
+
<%= Contact.human_attribute_name :country %>
<%= @contact.country %>
diff --git a/app/views/registrant/contacts/show/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb index ce1cc271d..dbdb7d0fd 100644 --- a/app/views/registrant/contacts/show/_domains.html.erb +++ b/app/views/registrant/contacts/show/_domains.html.erb @@ -4,7 +4,7 @@
- <%= t(:domains) %> + <%= t '.header'%>
@@ -26,11 +26,15 @@ - + + - diff --git a/app/views/registrant/contacts/show/_general.html.erb b/app/views/registrant/contacts/show/_general.html.erb index db57f1b65..109d6316a 100644 --- a/app/views/registrant/contacts/show/_general.html.erb +++ b/app/views/registrant/contacts/show/_general.html.erb @@ -1,39 +1,35 @@

- <%= t(:general) %> + <%= t '.header' %>

-
<%= t(:id) %>
+
<%= Contact.human_attribute_name :code %>
<%= @contact.code %>
-
<%= t(:name) %>
+
<%= Contact.human_attribute_name :name %>
<%= @contact.name %>
-
<%= t(:password) %>
+
<%= Contact.human_attribute_name :auth_info %>
<%= text_field_tag :auth_info, @contact.auth_info, readonly: true, class: 'partially-hidden' %>

-
<%= t(:ident) %>
+
<%= Contact.human_attribute_name :ident %>
<%= ident_for(@contact) %>
-
<%= t(:email) %>
+
<%= Contact.human_attribute_name :email %>
<%= @contact.email %>
-
<%= t(:phone) %>
+
<%= Contact.human_attribute_name :phone %>
<%= @contact.phone %>
<% if @contact.fax %> -
- <%= t(:fax) %> -
-
- <%= @contact.fax %> -
+
<%= Contact.human_attribute_name :fax %>
+
<%= @contact.fax %>
<% end %>
@@ -52,7 +48,7 @@ <%= @contact.name %> -
<%= t(:registrar_name) %>
+
<%= Registrar.model_name.human %>
<% if @contact.registrar.present? %> <%= link_to @contact.registrar, registrant_registrar_path(@contact.registrar) %> diff --git a/app/views/registrant/contacts/show/_statuses.html.erb b/app/views/registrant/contacts/show/_statuses.html.erb index e3bbab10d..90fb7cc73 100644 --- a/app/views/registrant/contacts/show/_statuses.html.erb +++ b/app/views/registrant/contacts/show/_statuses.html.erb @@ -1,15 +1,15 @@ <% panel_class = contact.errors.messages[:statuses] ? 'panel-danger' : 'panel-default' %>
- <%= t(:statuses) %> + <%= t '.header' %>
<%= custom_sort_link t(:domain_name), :name %> - <%= custom_sort_link t(:registrar_name), :registrar_name %> + <%= custom_sort_link Domain.human_attribute_name(:name), :name %> + + <%= custom_sort_link Registrar.model_name.human, :registrar_name %> + + <%= custom_sort_link Domain.human_attribute_name(:valid_to), :valid_to %> <%= custom_sort_link t(:valid_to), :valid_to %> <%= custom_sort_link Domain.human_attribute_name(:roles), :roles %>
- - + + diff --git a/config/locales/registrant/contacts.en.yml b/config/locales/registrant/contacts.en.yml new file mode 100644 index 000000000..0cb49130c --- /dev/null +++ b/config/locales/registrant/contacts.en.yml @@ -0,0 +1,17 @@ +en: + registrant: + contacts: + show: + general: + header: General + + address: + header: Address + + statuses: + header: Statuses + status: Status + notes: Note + + domains: + header: Domains \ No newline at end of file From 0107c6480928d10c68866fa395d15f0f4e1606d0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 17 Jun 2018 19:30:24 +0300 Subject: [PATCH 24/64] Reformat --- .../contacts/show/_domains.html.erb | 25 +++++++------------ .../contacts/show/_general.html.erb | 6 +++-- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/views/registrant/contacts/show/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb index dbdb7d0fd..7c6a5462f 100644 --- a/app/views/registrant/contacts/show/_domains.html.erb +++ b/app/views/registrant/contacts/show/_domains.html.erb @@ -41,24 +41,17 @@ - <% domains.each do |x| %> - - - - - - - <% end %> + <% domains.each do |x| %> + + + + + + + <% end %>
<%= t(:status) %><%= t(:notes) %><%= t '.status' %><%= t '.notes' %>
- <%= link_to(x.name, [:registrant, x]) %> - - <%= link_to(x.registrar, [:registrant, x.registrar]) %> - - <%= l(x.valid_to, format: :short) %> - - <%= x.roles.join(", ") %> -
<%= link_to(x.name, [:registrant, x]) %><%= link_to(x.registrar, [:registrant, x.registrar]) %><%= l(x.valid_to, format: :short) %><%= x.roles.join(", ") %>
+ <%= paginate domains, param_name: :domain_page %> \ No newline at end of file diff --git a/app/views/registrant/contacts/show/_general.html.erb b/app/views/registrant/contacts/show/_general.html.erb index 109d6316a..3f12b45c3 100644 --- a/app/views/registrant/contacts/show/_general.html.erb +++ b/app/views/registrant/contacts/show/_general.html.erb @@ -14,8 +14,10 @@
<%= @contact.name %>
<%= Contact.human_attribute_name :auth_info %>
-
<%= text_field_tag :auth_info, @contact.auth_info, readonly: true, - class: 'partially-hidden' %>
+
+ <%= text_field_tag :auth_info, @contact.auth_info, readonly: true, + class: 'partially-hidden' %> +

<%= Contact.human_attribute_name :ident %>
From a785e6cd99a7d94b80c696cf77ebd953c5304d3a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 17 Jun 2018 19:31:32 +0300 Subject: [PATCH 25/64] Remove unused HTML --- app/views/registrant/contacts/show/_domains.html.erb | 2 +- app/views/registrant/contacts/show/_general.html.erb | 3 --- app/views/registrant/contacts/show/_statuses.html.erb | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/views/registrant/contacts/show/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb index 7c6a5462f..8cc2e111e 100644 --- a/app/views/registrant/contacts/show/_domains.html.erb +++ b/app/views/registrant/contacts/show/_domains.html.erb @@ -1,7 +1,7 @@ <% domains = contact.all_domains(page: params[:domain_page], per: 20, params: params.merge(leave_domains: domain_ids)) %> -
+
<%= t '.header'%> diff --git a/app/views/registrant/contacts/show/_general.html.erb b/app/views/registrant/contacts/show/_general.html.erb index 3f12b45c3..e02e0573c 100644 --- a/app/views/registrant/contacts/show/_general.html.erb +++ b/app/views/registrant/contacts/show/_general.html.erb @@ -18,7 +18,6 @@ <%= text_field_tag :auth_info, @contact.auth_info, readonly: true, class: 'partially-hidden' %> -
<%= Contact.human_attribute_name :ident %>
<%= ident_for(@contact) %>
@@ -34,8 +33,6 @@
<%= @contact.fax %>
<% end %> -
-
<%= Contact.human_attribute_name :created_at %>
<%= l(@contact.created_at, format: :short) %> diff --git a/app/views/registrant/contacts/show/_statuses.html.erb b/app/views/registrant/contacts/show/_statuses.html.erb index 90fb7cc73..975669cde 100644 --- a/app/views/registrant/contacts/show/_statuses.html.erb +++ b/app/views/registrant/contacts/show/_statuses.html.erb @@ -1,6 +1,6 @@ <% panel_class = contact.errors.messages[:statuses] ? 'panel-danger' : 'panel-default' %> -
-
+
+
<%= t '.header' %>
From 82cef0401a5f4456102ebc4ebede577e9390e338 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 00:08:59 +0300 Subject: [PATCH 26/64] Remove unneeded condition Contact's registrar is always present --- app/views/registrant/contacts/show/_general.html.erb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/registrant/contacts/show/_general.html.erb b/app/views/registrant/contacts/show/_general.html.erb index e02e0573c..33f467085 100644 --- a/app/views/registrant/contacts/show/_general.html.erb +++ b/app/views/registrant/contacts/show/_general.html.erb @@ -49,9 +49,7 @@
<%= Registrar.model_name.human %>
- <% if @contact.registrar.present? %> - <%= link_to @contact.registrar, registrant_registrar_path(@contact.registrar) %> - <% end %> + <%= link_to @contact.registrar, registrant_registrar_path(@contact.registrar) %>
From 0b6e89dbca67d69f70e091d8469a43dd84600436 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 00:22:40 +0300 Subject: [PATCH 27/64] Hide methods --- app/controllers/registrant/contacts_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/registrant/contacts_controller.rb b/app/controllers/registrant/contacts_controller.rb index db6c279eb..9c2c63aeb 100644 --- a/app/controllers/registrant/contacts_controller.rb +++ b/app/controllers/registrant/contacts_controller.rb @@ -7,6 +7,8 @@ class Registrant::ContactsController < RegistrantController authorize! :read, @contact end + private + def contacts begin DomainContact.where(domain_id: domain_ids).pluck(:contact_id) | Domain.where(id: domain_ids).pluck(:registrant_id) From 67ec7b1256732b60483e0783d1862d6952a7fc3d Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 00:30:48 +0300 Subject: [PATCH 28/64] Reformat --- app/controllers/registrant/contacts_controller.rb | 3 ++- app/controllers/registrant/registrars_controller.rb | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/registrant/contacts_controller.rb b/app/controllers/registrant/contacts_controller.rb index 9c2c63aeb..f73650de2 100644 --- a/app/controllers/registrant/contacts_controller.rb +++ b/app/controllers/registrant/contacts_controller.rb @@ -1,7 +1,8 @@ class Registrant::ContactsController < RegistrantController helper_method :domain_ids + def show - @contact = Contact.where(id: contacts).find_by(id: params[:id]) + @contact = Contact.where(id: contacts).find_by(id: params[:id]) @current_user = current_user authorize! :read, @contact diff --git a/app/controllers/registrant/registrars_controller.rb b/app/controllers/registrant/registrars_controller.rb index d0630b73a..7bb101bb9 100644 --- a/app/controllers/registrant/registrars_controller.rb +++ b/app/controllers/registrant/registrars_controller.rb @@ -1,7 +1,6 @@ class Registrant::RegistrarsController < RegistrantController - def show @registrar = Registrar.find(params[:id]) authorize! :read, @registrar end -end +end \ No newline at end of file From 152759ab73d92b70c4029903fe05e3e80b9e6800 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 00:31:11 +0300 Subject: [PATCH 29/64] Remove unused routes --- config/routes.rb | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index ecb054409..7dbb988cf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -111,8 +111,8 @@ Rails.application.routes.draw do end end - resources :domain_update_confirms - resources :domain_delete_confirms + resources :domain_update_confirms, only: %i[show update] + resources :domain_delete_confirms, only: %i[show update] devise_scope :user do get 'login' => 'sessions#login' @@ -126,25 +126,8 @@ Rails.application.routes.draw do get 'logout' => '/devise/sessions#destroy' end - resources :domains do - resources :registrant_verifications - collection do - post 'update', as: 'update' - post 'destroy', as: 'destroy' - get 'renew' - get 'edit' - get 'info' - get 'delete' - end - end - - resources :registrars do - collection do - get :search - end - end - - resources :contacts + resources :registrars, only: :show + resources :contacts, only: :show end From 288db24ab1f206647bdaf03fd0321e9bc5b9c469 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 00:37:10 +0300 Subject: [PATCH 30/64] Reformat --- config/routes.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 7dbb988cf..8f50d5587 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -101,6 +101,8 @@ Rails.application.routes.draw do namespace :registrant do root 'domains#index' + resources :registrars, only: :show + resources :contacts, only: :show resources :domains, only: %i[index show] do collection do get :download_list @@ -125,12 +127,8 @@ Rails.application.routes.draw do post 'id' => 'sessions#id' get 'logout' => '/devise/sessions#destroy' end - - resources :registrars, only: :show - resources :contacts, only: :show end - # ADMIN ROUTES namespace :admin do resources :keyrelays From 452caffc7dd7879ab618c7c2f37a1eab985fc9ff Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 00:49:35 +0300 Subject: [PATCH 31/64] Improve UI --- .../contacts/show/_domains.html.erb | 31 ++++++++++--------- config/locales/registrant/contacts.en.yml | 3 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app/views/registrant/contacts/show/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb index 8cc2e111e..e88ef0c63 100644 --- a/app/views/registrant/contacts/show/_domains.html.erb +++ b/app/views/registrant/contacts/show/_domains.html.erb @@ -3,23 +3,24 @@
-
- <%= t '.header'%> -
+
+
+ <%= t '.header' %> +
-
- <%= form_tag request.path, method: :get do %> - <%= select_tag :domain_filter, - options_for_select(%w(Registrant AdminDomainContact TechDomainContact), - selected: params[:domain_filter]), - include_blank: true, - class: 'form-control2 selectize2' %> - - <% end %> +
+ <%= form_tag request.path, method: :get, class: 'form-inline' do %> + <%= select_tag :domain_filter, + options_for_select(%w(Registrant AdminDomainContact TechDomainContact), + selected: params[:domain_filter]), + include_blank: t('.all'), + class: 'form-control' %> + + <% end %> +
-
diff --git a/config/locales/registrant/contacts.en.yml b/config/locales/registrant/contacts.en.yml index 0cb49130c..ef6ea173f 100644 --- a/config/locales/registrant/contacts.en.yml +++ b/config/locales/registrant/contacts.en.yml @@ -14,4 +14,5 @@ en: notes: Note domains: - header: Domains \ No newline at end of file + header: Domains + all: All roles \ No newline at end of file From ca09833bb7e82b75dff83689e36277d1c4259b78 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 01:20:55 +0300 Subject: [PATCH 32/64] Remove dead code `Contact#statuses` is never validated --- .../registrant/contacts/show/_statuses.html.erb | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/app/views/registrant/contacts/show/_statuses.html.erb b/app/views/registrant/contacts/show/_statuses.html.erb index 975669cde..07db6bc87 100644 --- a/app/views/registrant/contacts/show/_statuses.html.erb +++ b/app/views/registrant/contacts/show/_statuses.html.erb @@ -1,5 +1,4 @@ -<% panel_class = contact.errors.messages[:statuses] ? 'panel-danger' : 'panel-default' %> -
+
<%= t '.header' %>
@@ -21,16 +20,6 @@ <% end %> - - <% if contact.errors.messages[:statuses] %> - - <% @domain.errors.messages[:statuses].each do |s| %> - - <%= s %> - - <% end %> - - <% end %>
\ No newline at end of file From 7792a78f22296e9c5378291c8b66d29f4c9e7ae7 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 01:25:18 +0300 Subject: [PATCH 33/64] Improve readability --- app/views/registrant/contacts/show/_domains.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/registrant/contacts/show/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb index e88ef0c63..a55aca786 100644 --- a/app/views/registrant/contacts/show/_domains.html.erb +++ b/app/views/registrant/contacts/show/_domains.html.erb @@ -42,12 +42,12 @@ - <% domains.each do |x| %> + <% domains.each do |domain| %> - <%= link_to(x.name, [:registrant, x]) %> - <%= link_to(x.registrar, [:registrant, x.registrar]) %> - <%= l(x.valid_to, format: :short) %> - <%= x.roles.join(", ") %> + <%= link_to(domain.name, [:registrant, domain]) %> + <%= link_to(domain.registrar, [:registrant, domain.registrar]) %> + <%= l(domain.valid_to, format: :short) %> + <%= domain.roles.join(", ") %> <% end %> From 36b95973c8a54209702f2b93adb1cfb7cbb8f6ef Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 12:03:59 +0300 Subject: [PATCH 34/64] Use standard datetime format --- app/views/registrant/contacts/show/_domains.html.erb | 2 +- app/views/registrant/contacts/show/_general.html.erb | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/views/registrant/contacts/show/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb index a55aca786..67ec68022 100644 --- a/app/views/registrant/contacts/show/_domains.html.erb +++ b/app/views/registrant/contacts/show/_domains.html.erb @@ -46,7 +46,7 @@ <%= link_to(domain.name, [:registrant, domain]) %> <%= link_to(domain.registrar, [:registrant, domain.registrar]) %> - <%= l(domain.valid_to, format: :short) %> + <%= l domain.valid_to %> <%= domain.roles.join(", ") %> <% end %> diff --git a/app/views/registrant/contacts/show/_general.html.erb b/app/views/registrant/contacts/show/_general.html.erb index 33f467085..0ebf5da21 100644 --- a/app/views/registrant/contacts/show/_general.html.erb +++ b/app/views/registrant/contacts/show/_general.html.erb @@ -34,18 +34,10 @@ <% end %>
<%= Contact.human_attribute_name :created_at %>
-
- <%= l(@contact.created_at, format: :short) %> - by - <%= @contact.name %> -
+
<%= l @contact.created_at %> by <%= @contact.name %>
<%= Contact.human_attribute_name :updated_at %>
-
- <%= l(@contact.updated_at, format: :short) %> - by - <%= @contact.name %> -
+
<%= l @contact.updated_at %> by <%= @contact.name %>
<%= Registrar.model_name.human %>
From d403fdb5af7f06077d52634028671a4f9ba19d4f Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 12:05:01 +0300 Subject: [PATCH 35/64] Remove useless data from UI --- app/views/registrant/contacts/show/_general.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/registrant/contacts/show/_general.html.erb b/app/views/registrant/contacts/show/_general.html.erb index 0ebf5da21..025aacd14 100644 --- a/app/views/registrant/contacts/show/_general.html.erb +++ b/app/views/registrant/contacts/show/_general.html.erb @@ -34,10 +34,10 @@ <% end %>
<%= Contact.human_attribute_name :created_at %>
-
<%= l @contact.created_at %> by <%= @contact.name %>
+
<%= l @contact.created_at %>
<%= Contact.human_attribute_name :updated_at %>
-
<%= l @contact.updated_at %> by <%= @contact.name %>
+
<%= l @contact.updated_at %>
<%= Registrar.model_name.human %>
From 80237429647e6c5e8098e840527040a7556c03de Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 12:26:41 +0300 Subject: [PATCH 36/64] Use the named route helpers --- app/views/registrant/contacts/show/_domains.html.erb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/registrant/contacts/show/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb index 67ec68022..dab0b93cb 100644 --- a/app/views/registrant/contacts/show/_domains.html.erb +++ b/app/views/registrant/contacts/show/_domains.html.erb @@ -41,11 +41,13 @@ + <% domains.each do |domain| %> - <%= link_to(domain.name, [:registrant, domain]) %> - <%= link_to(domain.registrar, [:registrant, domain.registrar]) %> + <%= link_to domain.name, registrant_domain_path(domain) %> + <%= link_to domain.registrar, + registrant_registrar_path(domain.registrar) %> <%= l domain.valid_to %> <%= domain.roles.join(", ") %> From 4e2d32a6ce47f01c171de5a41b2751c211958e88 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 13:30:57 +0300 Subject: [PATCH 37/64] Unify `contact.auth_info` look and feel --- app/assets/stylesheets/shared/general.sass | 5 ----- app/views/admin/contacts/partials/_general.haml | 5 +++-- app/views/registrant/contacts/show/_general.html.erb | 4 ++-- app/views/registrar/contacts/partials/_general.haml | 5 +++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/shared/general.sass b/app/assets/stylesheets/shared/general.sass index fd8bc2905..07b92cdbe 100644 --- a/app/assets/stylesheets/shared/general.sass +++ b/app/assets/stylesheets/shared/general.sass @@ -52,10 +52,5 @@ body > .container .text-grey color: grey -.partially-hidden - border: 1px solid #dddddd - padding-left: 4px - padding-right: 4px - .disabled-value padding-top: 8px diff --git a/app/views/admin/contacts/partials/_general.haml b/app/views/admin/contacts/partials/_general.haml index db1eaf412..029f89509 100644 --- a/app/views/admin/contacts/partials/_general.haml +++ b/app/views/admin/contacts/partials/_general.haml @@ -6,9 +6,10 @@ %dt= t(:id) %dd= @contact.code - %dt= t(:authinfo_pw) + %dt= Contact.human_attribute_name :auth_info %dd - = text_field_tag :auth_info, @contact.auth_info, readonly: true, class: 'partially-hidden' + = tag :input, type: 'text', value: @contact.auth_info, readonly: true, + class: 'form-control input-sm' %br diff --git a/app/views/registrant/contacts/show/_general.html.erb b/app/views/registrant/contacts/show/_general.html.erb index 025aacd14..b61d2f50e 100644 --- a/app/views/registrant/contacts/show/_general.html.erb +++ b/app/views/registrant/contacts/show/_general.html.erb @@ -15,8 +15,8 @@
<%= Contact.human_attribute_name :auth_info %>
- <%= text_field_tag :auth_info, @contact.auth_info, readonly: true, - class: 'partially-hidden' %> + <%= tag :input, type: 'text', value: @contact.auth_info, readonly: true, + class: 'form-control input-sm' %>
<%= Contact.human_attribute_name :ident %>
diff --git a/app/views/registrar/contacts/partials/_general.haml b/app/views/registrar/contacts/partials/_general.haml index 462bf35a0..5fc8ec027 100644 --- a/app/views/registrar/contacts/partials/_general.haml +++ b/app/views/registrar/contacts/partials/_general.haml @@ -6,9 +6,10 @@ %dt= t(:id) %dd= @contact.id - %dt= t(:authinfo_pw) + %dt= Contact.human_attribute_name :auth_info %dd - = text_field_tag :password, @contact.password, readonly: true, class: 'partially-hidden' + = tag :input, type: 'text', value: @contact.password, readonly: true, + class: 'form-control input-sm' %br From 457c142f619b6f20c63d560b1e41bb48f1d6eaa5 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 13:45:03 +0300 Subject: [PATCH 38/64] Extract partial --- app/views/registrant/contacts/show/_domain.html.erb | 6 ++++++ app/views/registrant/contacts/show/_domains.html.erb | 10 +--------- 2 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 app/views/registrant/contacts/show/_domain.html.erb diff --git a/app/views/registrant/contacts/show/_domain.html.erb b/app/views/registrant/contacts/show/_domain.html.erb new file mode 100644 index 000000000..83b7f49d5 --- /dev/null +++ b/app/views/registrant/contacts/show/_domain.html.erb @@ -0,0 +1,6 @@ + + <%= link_to domain.name, registrant_domain_path(domain) %> + <%= link_to domain.registrar, registrant_registrar_path(domain.registrar) %> + <%= l domain.valid_to %> + <%= domain.roles.join(", ") %> + \ No newline at end of file diff --git a/app/views/registrant/contacts/show/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb index dab0b93cb..e99ff3053 100644 --- a/app/views/registrant/contacts/show/_domains.html.erb +++ b/app/views/registrant/contacts/show/_domains.html.erb @@ -43,15 +43,7 @@ - <% domains.each do |domain| %> - - <%= link_to domain.name, registrant_domain_path(domain) %> - <%= link_to domain.registrar, - registrant_registrar_path(domain.registrar) %> - <%= l domain.valid_to %> - <%= domain.roles.join(", ") %> - - <% end %> + <%= render partial: 'registrant/contacts/show/domain', collection: domains %>
From 80de7dd4eddc5dca3600033e5ca316cc58ef10a3 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 13:50:39 +0300 Subject: [PATCH 39/64] Improve UI --- app/views/registrant/contacts/show/_domains.html.erb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/registrant/contacts/show/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb index e99ff3053..1bd282987 100644 --- a/app/views/registrant/contacts/show/_domains.html.erb +++ b/app/views/registrant/contacts/show/_domains.html.erb @@ -47,6 +47,8 @@
-
-<%= paginate domains, param_name: :domain_page %> \ No newline at end of file + +
\ No newline at end of file From 4934a0c8e635e67b8f96bc6193a71776dc59e466 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 15:05:02 +0300 Subject: [PATCH 40/64] Remove unused method --- app/models/contact.rb | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 24dc2b4f2..088ec0b59 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -447,31 +447,6 @@ class Contact < ActiveRecord::Base domains end - def all_registrant_domains(page: nil, per: nil, params: {}, registrant: nil) - - if registrant - sorts = params.fetch(:sort, {}).first || [] - sort = Domain.column_names.include?(sorts.first) ? sorts.first : "valid_to" - order = {"asc"=>"desc", "desc"=>"asc"}[sorts.second] || "desc" - - domain_ids = DomainContact.distinct.where(contact_id: registrant.id).pluck(:domain_id) - - domains = Domain.where(id: domain_ids).includes(:registrar).page(page).per(per) - if sorts.first == "registrar_name".freeze - domains = domains.includes(:registrar).where.not(registrars: {id: nil}).order("registrars.name #{order} NULLS LAST") - else - domains = domains.order("#{sort} #{order} NULLS LAST") - end - - domain_c = Hash.new([]) - registrant_domains.where(id: domains.map(&:id)).each{|d| domain_c[d.id] |= ["Registrant".freeze] } - DomainContact.where(contact_id: id, domain_id: domains.map(&:id)).each{|d| domain_c[d.domain_id] |= [d.type] } - domains.each{|d| d.roles = domain_c[d.id].uniq} - domains - end - end - - def update_prohibited? (statuses & [ CLIENT_UPDATE_PROHIBITED, From 58effbb7c38a4311bff97cf76758980c2bb13180 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 16:46:49 +0300 Subject: [PATCH 41/64] Pull up Devise module --- app/models/admin_user.rb | 2 +- app/models/user.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb index d76c42dec..c29375d38 100644 --- a/app/models/admin_user.rb +++ b/app/models/admin_user.rb @@ -9,7 +9,7 @@ class AdminUser < User ROLES = %w(user customer_service admin) # should not match to api_users roles - devise :database_authenticatable, :rememberable, :trackable, :validatable, :lockable + devise :rememberable, :validatable, :lockable def self.min_password_length Devise.password_length.min diff --git a/app/models/user.rb b/app/models/user.rb index b69e0250c..150311e90 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,6 @@ class User < ActiveRecord::Base include Versions # version/user_version.rb - devise :trackable, :timeoutable + devise :database_authenticatable, :trackable, :timeoutable attr_accessor :phone From 3b996a5636598545495151626e1e784dd144d840 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 16:49:51 +0300 Subject: [PATCH 42/64] Update CodeClimate config --- .codeclimate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index be8f1df7a..f527cd0e3 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -20,6 +20,7 @@ plugins: rubocop: enabled: true exclude_patterns: + - "app/models/legacy/" - "bin/" - "config/" - "db/" From 70cc25e3a8ed5a6365cfba390c691a59956962d1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 17:08:59 +0300 Subject: [PATCH 43/64] Revert "Update CodeClimate config" This reverts commit 3b996a5636598545495151626e1e784dd144d840. --- .codeclimate.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index f527cd0e3..be8f1df7a 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -20,7 +20,6 @@ plugins: rubocop: enabled: true exclude_patterns: - - "app/models/legacy/" - "bin/" - "config/" - "db/" From 20c99bd53a4b4986c013e6e91942a5141000a41e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 17:44:36 +0300 Subject: [PATCH 44/64] Revert "Pull up Devise module" This reverts commit 58effbb --- app/models/admin_user.rb | 2 +- app/models/user.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb index c29375d38..d76c42dec 100644 --- a/app/models/admin_user.rb +++ b/app/models/admin_user.rb @@ -9,7 +9,7 @@ class AdminUser < User ROLES = %w(user customer_service admin) # should not match to api_users roles - devise :rememberable, :validatable, :lockable + devise :database_authenticatable, :rememberable, :trackable, :validatable, :lockable def self.min_password_length Devise.password_length.min diff --git a/app/models/user.rb b/app/models/user.rb index 150311e90..b69e0250c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,6 @@ class User < ActiveRecord::Base include Versions # version/user_version.rb - devise :database_authenticatable, :trackable, :timeoutable + devise :trackable, :timeoutable attr_accessor :phone From e418ec68258c0038e02d453aa7f7582e9b034bd4 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 18:01:14 +0300 Subject: [PATCH 45/64] Revert "Update fixture" This reverts commit 81f923a --- test/fixtures/users.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 036f2183e..155197b58 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -20,7 +20,6 @@ api_goodnames: admin: username: test - encrypted_password: <%= Devise::Encryptor.digest(AdminUser, 'testtest') %> type: AdminUser country_code: US roles: From 3b3c8e6a2d1820ae77b24cea46921a0c2045ceaf Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 18 Jun 2018 18:01:29 +0300 Subject: [PATCH 46/64] Revert "Update fixtures" This reverts commit 76f8a46 --- test/fixtures/users.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 155197b58..b20bd8a83 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,7 +1,6 @@ api_bestnames: username: test_bestnames password: testtest - encrypted_password: <%= Devise::Encryptor.digest(ApiUser, 'testtest') %> type: ApiUser registrar: bestnames active: true @@ -11,7 +10,6 @@ api_bestnames: api_goodnames: username: test_goodnames password: testtest - encrypted_password: <%= Devise::Encryptor.digest(ApiUser, 'testtest') %> type: ApiUser registrar: goodnames active: true From 1091fe710967b59c8fceb2d0bb26ff6da01d9043 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 20 Jun 2018 14:44:34 +0300 Subject: [PATCH 47/64] Change date format --- app/models/directo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index 1269e7033..3fc51bb40 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -26,7 +26,7 @@ class Directo < ActiveRecord::Base xml.invoice( "SalesAgent" => Setting.directo_sales_agent, "Number" => num, - "InvoiceDate" => invoice.created_at.strftime("%Y-%m-%dT%H:%M:%S"), + "InvoiceDate" => invoice.created_at.strftime("%Y-%m-%d"), "PaymentTerm" => Setting.directo_receipt_payment_term, "Currency" => invoice.currency, "CustomerCode"=> invoice.buyer.accounting_customer_code From 53796d091afdb5fecacc9572897796ef1f4c9854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Wed, 20 Jun 2018 16:13:10 +0300 Subject: [PATCH 48/64] Changelog update 180620 --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fe8f891a..4e75d8157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +20.06.2018 +* Bulk change function for technical contact replacement [#662](https://github.com/internetee/registry/issues/662) +* Removed vatcode and totalvat elements from directo request in attempt to fix invoice sending issue [#844](https://github.com/internetee/registry/issues/844) +* Regsitrar: added credit card payment option - disabled at the moment due to contractual reaons [#419](https://github.com/internetee/registry/issues/419) +* Registrant: enabled WHOIS requests over RestWHOIS API [#852](https://github.com/internetee/registry/issues/852) +* Fixed rspec configuration that caused test failures [#858](https://github.com/internetee/registry/issues/858) +* Admin: refactored date selection in pricelist [#869](https://github.com/internetee/registry/issues/869) +* Added uglifier gem for es6 compression [#864](https://github.com/internetee/registry/issues/864) +* Removed lib folder from autoload path [#859](https://github.com/internetee/registry/issues/859) +* test environment config improvements [#860](https://github.com/internetee/registry/issues/860) +* translation fixes [#865](https://github.com/internetee/registry/issues/865) +* removed obsolete .agignore [#866](https://github.com/internetee/registry/issues/866) +* removed rubocop gem [#857](https://github.com/internetee/registry/issues/857) +* new invoice payment test fix [#863](https://github.com/internetee/registry/issues/863) +* get puma gem config from Rails 5 [#867](https://github.com/internetee/registry/issues/867) +* Rails5 API controller temporary backport [#868](https://github.com/internetee/registry/issues/868) + 25.05.2018 * GDPR: updated whois templates with configurable disclaimer [#795](https://github.com/internetee/registry/issues/795) * GDPR: email forwarding solution to contact private domain registrants without revealing their email addresses [#824](https://github.com/internetee/registry/issues/824) From bb183466746050a6949fae14f403d8c89f9f14e1 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 21 Jun 2018 14:39:08 +0300 Subject: [PATCH 49/64] Update sprockets dependency --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e108bde8f..9a88e782b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -293,7 +293,7 @@ GEM erubis que (~> 0.8) sinatra - rack (1.6.9) + rack (1.6.10) rack-accept (0.4.5) rack (>= 0.4) rack-mount (0.8.3) @@ -404,7 +404,7 @@ GEM sixarm_ruby_unaccent (1.1.1) slop (3.6.0) socksify (1.7.1) - sprockets (3.7.1) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) From c3c1619238cee5f259f79001c5113cbc713d9d74 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Fri, 15 Jun 2018 14:45:30 +0300 Subject: [PATCH 50/64] Fix rubocop array issue --- .../registrant/domain_update_confirms_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/registrant/domain_update_confirms_controller.rb b/app/controllers/registrant/domain_update_confirms_controller.rb index ca91f0192..0d23943c9 100644 --- a/app/controllers/registrant/domain_update_confirms_controller.rb +++ b/app/controllers/registrant/domain_update_confirms_controller.rb @@ -1,6 +1,6 @@ class Registrant::DomainUpdateConfirmsController < RegistrantController - skip_before_action :authenticate_user!, only: [:show, :update] - skip_authorization_check only: [:show, :update] + skip_before_action :authenticate_user!, only: %i[show update] + skip_authorization_check only: %i[show update] def show return if params[:confirmed] || params[:rejected] From 657affb68d7949ed68fecffd57d62d22ab91a5d3 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 18 Jun 2018 10:54:05 +0300 Subject: [PATCH 51/64] Add whois record fixture and fix invoices fixture --- test/fixtures/invoices.yml | 1 - test/fixtures/whois_records.yml | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/whois_records.yml diff --git a/test/fixtures/invoices.yml b/test/fixtures/invoices.yml index 71189f6b6..6b9359343 100644 --- a/test/fixtures/invoices.yml +++ b/test/fixtures/invoices.yml @@ -35,5 +35,4 @@ overdue: for_payments_test: <<: *DEFAULTS total: 12.00 - id: 1 number: 1 diff --git a/test/fixtures/whois_records.yml b/test/fixtures/whois_records.yml new file mode 100644 index 000000000..0cdd25431 --- /dev/null +++ b/test/fixtures/whois_records.yml @@ -0,0 +1,6 @@ +shop: + name: shop.test + domain: shop + body: WHOIS text + json: + name: shop.test From 934404036f6c0948543ce32263a0cc9db3ccee4c Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Fri, 22 Jun 2018 13:38:47 +0300 Subject: [PATCH 52/64] Add tests for DomainUpdateConfirmJob --- test/jobs/domain_update_confirm_job_test.rb | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/jobs/domain_update_confirm_job_test.rb diff --git a/test/jobs/domain_update_confirm_job_test.rb b/test/jobs/domain_update_confirm_job_test.rb new file mode 100644 index 000000000..c507e2c98 --- /dev/null +++ b/test/jobs/domain_update_confirm_job_test.rb @@ -0,0 +1,36 @@ +require "test_helper" + +class DomainUpdateConfirmJobTest < ActiveSupport::TestCase + def setup + super + + @domain = domains(:shop) + @new_registrant = contacts(:william) + @user = users(:api_bestnames) + + @domain.update!(pending_json: { new_registrant_id: @new_registrant.id, + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id }) + end + + def teardown + super + end + + def test_rejected_registrant_verification_polls_a_message + DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED) + + last_registrar_message = @domain.registrar.messages.last + assert_equal(last_registrar_message.attached_obj_id, @domain.id) + assert_equal(last_registrar_message.body, 'Registrant rejected domain update: shop.test') + end + + def test_accepted_registrant_verification_polls_a_message + DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED) + + last_registrar_message = @domain.registrar.messages.last + assert_equal(last_registrar_message.attached_obj_id, @domain.id) + assert_equal(last_registrar_message.body, 'Registrant confirmed domain update: shop.test') + end +end From 417a390ff7298da0c617a78f7e662ef5198420e4 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 25 Jun 2018 16:14:36 +0300 Subject: [PATCH 53/64] Add tests for DomainDeleteConfirmJob --- test/jobs/domain_delete_confirm_job_test.rb | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/jobs/domain_delete_confirm_job_test.rb diff --git a/test/jobs/domain_delete_confirm_job_test.rb b/test/jobs/domain_delete_confirm_job_test.rb new file mode 100644 index 000000000..9127ca628 --- /dev/null +++ b/test/jobs/domain_delete_confirm_job_test.rb @@ -0,0 +1,36 @@ +require "test_helper" + +class DomainDeleteConfirmJobTest < ActiveSupport::TestCase + def setup + super + + @domain = domains(:shop) + @new_registrant = contacts(:william) + @user = users(:api_bestnames) + + @domain.update!(pending_json: { new_registrant_id: @new_registrant.id, + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id }) + end + + def teardown + super + end + + def test_rejected_registrant_verification_polls_a_message + DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED) + + last_registrar_message = @domain.registrar.messages.last + assert_equal(last_registrar_message.attached_obj_id, @domain.id) + assert_equal(last_registrar_message.body, 'Registrant rejected domain deletion: shop.test') + end + + def test_accepted_registrant_verification_polls_a_message + DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED) + + last_registrar_message = @domain.registrar.messages.last + assert_equal(last_registrar_message.attached_obj_id, @domain.id) + assert_equal(last_registrar_message.body, 'Registrant confirmed domain deletion: shop.test') + end +end From a8884b0545f41460643a4ce5acd794a676c60e47 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Tue, 26 Jun 2018 10:03:17 +0300 Subject: [PATCH 54/64] Remove duplicate rspec tests --- .../domain_delete_confirm_email_job_spec.rb | 40 ------------------- spec/jobs/domain_update_confirm_job_spec.rb | 18 --------- 2 files changed, 58 deletions(-) delete mode 100644 spec/jobs/domain_delete_confirm_email_job_spec.rb delete mode 100644 spec/jobs/domain_update_confirm_job_spec.rb diff --git a/spec/jobs/domain_delete_confirm_email_job_spec.rb b/spec/jobs/domain_delete_confirm_email_job_spec.rb deleted file mode 100644 index 0b2a0a6b7..000000000 --- a/spec/jobs/domain_delete_confirm_email_job_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'rails_helper' - -RSpec.describe DomainDeleteConfirmEmailJob do - describe '#run' do - let(:domain) { instance_double(Domain) } - let(:message) { instance_double(ActionMailer::MessageDelivery) } - - before :example do - expect(Domain).to receive(:find).and_return(domain) - allow(domain).to receive_messages( - id: 1, - name: 'test.com', - registrant_email: 'registrant@test.com', - registrar: 'registrar', - registrant: 'registrant') - end - - after :example do - domain_id = 1 - described_class.enqueue(domain_id) - end - - it 'creates log record' do - log_message = 'Send DomainDeleteMailer#confirm email for domain test.com (#1) to registrant@test.com' - - allow(DomainDeleteMailer).to receive(:confirm).and_return(message) - allow(message).to receive(:deliver_now) - - expect(Rails.logger).to receive(:info).with(log_message) - end - - it 'sends email' do - expect(DomainDeleteMailer).to receive(:confirm).with(domain: domain, - registrar: 'registrar', - registrant: 'registrant') - .and_return(message) - expect(message).to receive(:deliver_now) - end - end -end diff --git a/spec/jobs/domain_update_confirm_job_spec.rb b/spec/jobs/domain_update_confirm_job_spec.rb deleted file mode 100644 index 4748ca021..000000000 --- a/spec/jobs/domain_update_confirm_job_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.describe DomainUpdateConfirmJob do - let(:domain) { instance_spy(Epp::Domain, registrant: registrant, errors: []) } - let(:registrant) { instance_double(Registrant) } - let(:registrant_change) { instance_spy(RegistrantChange) } - - it 'confirms registrant change' do - expect(Epp::Domain).to receive(:find).and_return(domain) - expect(RegistrantChange).to receive(:new) - .with(domain: domain, old_registrant: registrant) - .and_return(registrant_change) - - described_class.enqueue(domain_id = nil, action = RegistrantVerification::CONFIRMED) - - expect(registrant_change).to have_received(:confirm) - end -end From 8fb3d511c27791cb9f8c343817fb7820013a9d18 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Tue, 26 Jun 2018 11:37:31 +0300 Subject: [PATCH 55/64] Remove clean_pendings_lowlevel method --- app/jobs/domain_update_confirm_job.rb | 4 +++- app/models/domain.rb | 30 --------------------------- app/models/domain_cron.rb | 5 ++++- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index b4d2a9f57..c661c7b6b 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -23,7 +23,9 @@ class DomainUpdateConfirmJob < Que::Job registrant: domain.registrant).deliver_now domain.poll_message!(:poll_pending_update_rejected_by_registrant) - domain.clean_pendings_lowlevel + + domain.preclean_pendings + domain.clean_pendings! end destroy # it's best to destroy the job in the same transaction end diff --git a/app/models/domain.rb b/app/models/domain.rb index 0f3afed90..30ed0b580 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -294,36 +294,6 @@ class Domain < ActiveRecord::Base save end - - # state changes may be done low-level - no validation - # in this metod we still save PaperTrail log. - def clean_pendings_lowlevel - statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) - statuses.delete(DomainStatus::PENDING_UPDATE) - statuses.delete(DomainStatus::PENDING_DELETE) - - status_notes[DomainStatus::PENDING_UPDATE] = '' - status_notes[DomainStatus::PENDING_DELETE] = '' - - hash = { - registrant_verification_token: nil, - registrant_verification_asked_at: nil, - pending_json: {}, - status_notes: status_notes, - statuses: statuses.presence || [DomainStatus::OK], - # need this column in order to update PaperTrail version properly - updated_at: Time.now.utc - } - - # PaperTrail - self.attributes = hash - record_update - clear_version_instance! - reset_transaction_id - - update_columns(hash) - end - def pending_update! return true if pending_update? self.epp_pending_update = true # for epp diff --git a/app/models/domain_cron.rb b/app/models/domain_cron.rb index 80bf32c5a..8de52b226 100644 --- a/app/models/domain_cron.rb +++ b/app/models/domain_cron.rb @@ -21,7 +21,10 @@ class DomainCron if domain.pending_delete? || domain.pending_delete_confirmation? DomainMailer.pending_delete_expired_notification(domain.id, true).deliver end - domain.clean_pendings_lowlevel + + domain.preclean_pendings + domain.clean_pendings! + unless Rails.env.test? STDOUT << "#{Time.zone.now.utc} DomainCron.clean_expired_pendings: ##{domain.id} (#{domain.name})\n" end From 3c44472ea81701ccc7a7761be281990c09197cf1 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Tue, 26 Jun 2018 15:44:34 +0300 Subject: [PATCH 56/64] Revert flash_messages to shared/flash --- .../registrar/sessions_controller.rb | 2 +- app/views/layouts/registrar/base.html.erb | 112 +++++++++--------- app/views/layouts/registrar/sessions.html.erb | 4 +- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index 1a8b195ee..11841481d 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -91,7 +91,7 @@ class Registrar @user = find_user_by_idc_and_allowed(response.user_id_code) else @user = find_user_by_idc(response.user_id_code) - end + end if @user.persisted? session[:user_id_code] = response.user_id_code diff --git a/app/views/layouts/registrar/base.html.erb b/app/views/layouts/registrar/base.html.erb index 3bc1c5b0f..c218a4e03 100644 --- a/app/views/layouts/registrar/base.html.erb +++ b/app/views/layouts/registrar/base.html.erb @@ -1,63 +1,63 @@ - - - - <% if content_for? :head_title %> - <%= yield :head_title %> - <% else %> - - <%= t(:registrar_head_title) %> - - <% end %> - <%= csrf_meta_tags %> - <%= stylesheet_link_tag 'registrar-manifest', media: 'all' %> - <%= favicon_link_tag 'favicon.ico' %> - - - -
- <%= render 'flash_messages' %> - <% if depp_controller? %> - <%= render 'registrar/shared/epp_results' %> - <% end %> - <%= yield %> -
-
-
-
-
- <%= image_tag 'eis-logo-et.png' %> +
+
+
+
+ <%= image_tag 'eis-logo-et.png' %> +
+
+ Version + <%= CURRENT_COMMIT_HASH %> +
+
-
- Version - <%= CURRENT_COMMIT_HASH %> -
-
-
-
-<%= javascript_include_tag 'registrar-manifest', async: true %> - + + <%= javascript_include_tag 'registrar-manifest', async: true %> + diff --git a/app/views/layouts/registrar/sessions.html.erb b/app/views/layouts/registrar/sessions.html.erb index 904388155..7c60ba762 100644 --- a/app/views/layouts/registrar/sessions.html.erb +++ b/app/views/layouts/registrar/sessions.html.erb @@ -33,7 +33,7 @@
- <%= render 'flash_messages' %> + <%= render 'shared/flash' %> <%= yield %>
@@ -51,4 +51,4 @@
- \ No newline at end of file + From 278522cfc37b65bf240b805407022d5121b8d38d Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Tue, 26 Jun 2018 15:52:46 +0300 Subject: [PATCH 57/64] Revert to old flash behavior --- .../application/_flash_messages.html.erb | 30 +++++-------------- .../layouts/registrant/application.html.erb | 2 +- app/views/layouts/registrar/base.html.erb | 2 +- app/views/layouts/registrar/sessions.html.erb | 2 +- 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/app/views/application/_flash_messages.html.erb b/app/views/application/_flash_messages.html.erb index 9b31f0d3f..364e3e5ca 100644 --- a/app/views/application/_flash_messages.html.erb +++ b/app/views/application/_flash_messages.html.erb @@ -1,24 +1,8 @@ -<% if flash[:notice] %> -
- - <% if flash[:notice].respond_to?(:join) %> -

<%= flash[:notice].join('
').html_safe %>

- <% else %> -

<%= flash[:notice] %>

- <% end %> +<% display = (flash[:notice] || flash[:alert] || flash[:warning]) ? 'block' : 'none' %> +
+ <% type = (flash[:notice]) ? 'bg-success' : 'bg-danger' %> + <% type = 'bg-warning' if flash[:warning] %> +
+ <%= flash[:notice] || flash[:alert] || flash[:warning] %>
-<% end %> - -<% if flash[:alert] %> -
- -

<%= flash[:alert] %>

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

<%= flash[:info] %>

-
-<% end %> +
diff --git a/app/views/layouts/registrant/application.html.erb b/app/views/layouts/registrant/application.html.erb index 075ac4652..b5ddb5f0f 100644 --- a/app/views/layouts/registrant/application.html.erb +++ b/app/views/layouts/registrant/application.html.erb @@ -65,7 +65,7 @@
- <%= render 'shared/flash' %> + <%= render 'flash_messages' %> <%= yield %>
diff --git a/app/views/layouts/registrar/base.html.erb b/app/views/layouts/registrar/base.html.erb index c218a4e03..c14899418 100644 --- a/app/views/layouts/registrar/base.html.erb +++ b/app/views/layouts/registrar/base.html.erb @@ -39,7 +39,7 @@
- <%= render 'shared/flash' %> + <%= render 'flash_messages' %> <% if depp_controller? %> <%= render 'registrar/shared/epp_results' %> <% end %> diff --git a/app/views/layouts/registrar/sessions.html.erb b/app/views/layouts/registrar/sessions.html.erb index 7c60ba762..4632e477c 100644 --- a/app/views/layouts/registrar/sessions.html.erb +++ b/app/views/layouts/registrar/sessions.html.erb @@ -33,7 +33,7 @@
- <%= render 'shared/flash' %> + <%= render 'flash_messages' %> <%= yield %>
From 2a6540d475392b577a434f5fe9965630d0fe709c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 26 Jun 2018 16:16:50 +0300 Subject: [PATCH 58/64] Changelog update 180626 --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e75d8157..62915c8c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +26.06.2018 +* Whois data is updated now on pendingUpdate status removal [#757](https://github.com/internetee/registry/issues/757) +* Changed date format in Directo invoice XML [#890](https://github.com/internetee/registry/pull/890) +* Registrant portal UI improvements [#888](https://github.com/internetee/registry/issues/888) +* Removed unused mailer code [#882](https://github.com/internetee/registry/pull/882) +* Sprocets gem update to 3.7.2 [#892](https://github.com/internetee/registry/issues/892) +* Replased Warden test helpers with Devise [#889](https://github.com/internetee/registry/issues/889) +* Removed dev rake task [#872](https://github.com/internetee/registry/pull/872) +* Spring gem removed [#856](https://github.com/internetee/registry/issues/856) +* Dcker conf changes [#881](https://github.com/internetee/registry/pull/881) +* Fixed Estonia in the country drop-down [#877](https://github.com/internetee/registry/issues/877) +* Codeclimate conf improvements [#854](https://github.com/internetee/registry/pull/854) +* Removed codeclimate badge from README [#876](https://github.com/internetee/registry/issues/876) +* added UUID for contact objects [#873](https://github.com/internetee/registry/pull/873) +* backported Rails 5 API [#868](https://github.com/internetee/registry/issues/868) + 20.06.2018 * Bulk change function for technical contact replacement [#662](https://github.com/internetee/registry/issues/662) * Removed vatcode and totalvat elements from directo request in attempt to fix invoice sending issue [#844](https://github.com/internetee/registry/issues/844) From 6922276be0e829184a0b43a002c68409ae01bf76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 26 Jun 2018 17:59:30 +0300 Subject: [PATCH 59/64] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62915c8c8..5bb6ed19e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ 26.06.2018 * Whois data is updated now on pendingUpdate status removal [#757](https://github.com/internetee/registry/issues/757) +* Portal for registrars displays control code for MID authentication [#893](https://github.com/internetee/registry/issues/893) * Changed date format in Directo invoice XML [#890](https://github.com/internetee/registry/pull/890) * Registrant portal UI improvements [#888](https://github.com/internetee/registry/issues/888) * Removed unused mailer code [#882](https://github.com/internetee/registry/pull/882) From b5f07682f43b8eaa61a8825eab73a013cbbfaffe Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 5 Jul 2018 16:15:32 +0300 Subject: [PATCH 60/64] Make replace_nameservers return an array of domain names --- app/models/registrar.rb | 6 +++++ .../registrar/replace_nameservers_test.rb | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/models/registrar/replace_nameservers_test.rb diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 05a5ad380..54e007133 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -132,14 +132,20 @@ class Registrar < ActiveRecord::Base # Audit log is needed, therefore no raw SQL def replace_nameservers(hostname, new_attributes) transaction do + domain_list = [] + nameservers.where(hostname: hostname).find_each do |original_nameserver| new_nameserver = Nameserver.new new_nameserver.domain = original_nameserver.domain new_nameserver.attributes = new_attributes new_nameserver.save! + domain_list << original_nameserver.domain.name + original_nameserver.destroy! end + + domain_list end end diff --git a/test/models/registrar/replace_nameservers_test.rb b/test/models/registrar/replace_nameservers_test.rb new file mode 100644 index 000000000..c247b2860 --- /dev/null +++ b/test/models/registrar/replace_nameservers_test.rb @@ -0,0 +1,23 @@ +require 'test_helper' + +class ReplaceNameserversTest < ActiveSupport::TestCase + def setup + @registrar = registrars(:bestnames) + end + + def test_replace_nameservers_in_bulk_returns_domain_names + new_attributes = { hostname: 'ns-updated1.bestnames.test', ipv4: '192.0.3.1', + ipv6: '2001:db8::2' } + result = @registrar.replace_nameservers('ns1.bestnames.test', new_attributes) + + assert_equal(["airport.test", "shop.test"], result) + end + + def test_replace_nameservers_in_bulk_returns_empty_array_for_non_existent_base_nameserver + new_attributes = { hostname: 'ns-updated1.bestnames.test', ipv4: '192.0.3.1', + ipv6: '2001:db8::2' } + result = @registrar.replace_nameservers('ns3.bestnames.test', new_attributes) + + assert_equal([], result) + end +end From 3e81366cfc80ea8f33dbb8805eaeb0bbe2130078 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 5 Jul 2018 17:24:32 +0300 Subject: [PATCH 61/64] Add affected domain parameter to REST API response --- app/api/repp/nameservers_v1.rb | 5 +++-- app/models/registrar.rb | 2 +- doc/repp/v1/nameservers.md | 1 + test/integration/api/nameservers/put_test.rb | 6 ++++-- test/integration/registrar/bulk_change/nameserver_test.rb | 3 ++- test/models/registrar/replace_nameservers_test.rb | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/api/repp/nameservers_v1.rb b/app/api/repp/nameservers_v1.rb index d653adf7f..71fde5aba 100644 --- a/app/api/repp/nameservers_v1.rb +++ b/app/api/repp/nameservers_v1.rb @@ -29,7 +29,7 @@ module Repp } begin - current_user.registrar.replace_nameservers(hostname, new_attributes) + affected_domains = current_user.registrar.replace_nameservers(hostname, new_attributes) rescue ActiveRecord::RecordInvalid => e error!({ errors: e.record.errors.full_messages.map { |error| { title: error } } }, 400) end @@ -37,7 +37,8 @@ module Repp status 200 @response = { data: { type: 'nameserver', id: params[:data][:attributes][:hostname], - attributes: params[:data][:attributes] } } + attributes: params[:data][:attributes], + affected_domains: affected_domains } } end end end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 54e007133..de02d42a7 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -145,7 +145,7 @@ class Registrar < ActiveRecord::Base original_nameserver.destroy! end - domain_list + domain_list.uniq.sort end end diff --git a/doc/repp/v1/nameservers.md b/doc/repp/v1/nameservers.md index 702a0c186..c1269f92a 100644 --- a/doc/repp/v1/nameservers.md +++ b/doc/repp/v1/nameservers.md @@ -35,6 +35,7 @@ Content-Type: application/json "ipv4": ["192.0.2.1", "192.0.2.2"], "ipv6": ["2001:db8::1", "2001:db8::2"] }, + "affected_domains": ["example.com", "example.org"] } } ``` diff --git a/test/integration/api/nameservers/put_test.rb b/test/integration/api/nameservers/put_test.rb index 416510541..e840cfcfc 100644 --- a/test/integration/api/nameservers/put_test.rb +++ b/test/integration/api/nameservers/put_test.rb @@ -41,11 +41,12 @@ class APINameserversPutTest < ActionDispatch::IntegrationTest assert_equal nameserver_hash, nameservers(:metro_ns1).reload.attributes end - def test_returns_new_nameserver_record + def test_returns_new_nameserver_record_and_affected_domain request_params = { format: :json, data: { type: 'nameserver', id: 'ns1.bestnames.test', attributes: { hostname: 'ns55.bestnames.test', ipv4: ['192.0.2.55'], ipv6: ['2001:db8::55'] } } } + put '/repp/v1/registrar/nameservers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response 200 @@ -53,7 +54,8 @@ class APINameserversPutTest < ActionDispatch::IntegrationTest id: 'ns55.bestnames.test', attributes: { hostname: 'ns55.bestnames.test', ipv4: ['192.0.2.55'], - ipv6: ['2001:db8::55'] } } }), + ipv6: ['2001:db8::55'] }, + affected_domains: ["airport.test", "shop.test"] } }), JSON.parse(response.body, symbolize_names: true) end diff --git a/test/integration/registrar/bulk_change/nameserver_test.rb b/test/integration/registrar/bulk_change/nameserver_test.rb index 20fd6617d..d1dbfc012 100644 --- a/test/integration/registrar/bulk_change/nameserver_test.rb +++ b/test/integration/registrar/bulk_change/nameserver_test.rb @@ -16,7 +16,8 @@ class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest basic_auth: ['test_goodnames', 'testtest']) .to_return(body: { data: [{ type: 'nameserver', - id: 'new-ns.bestnames.test' + id: 'new-ns.bestnames.test', + affected_domains: ["airport.test", "shop.test"] }] }.to_json, status: 200) visit registrar_domains_url diff --git a/test/models/registrar/replace_nameservers_test.rb b/test/models/registrar/replace_nameservers_test.rb index c247b2860..5bcbb83d1 100644 --- a/test/models/registrar/replace_nameservers_test.rb +++ b/test/models/registrar/replace_nameservers_test.rb @@ -5,7 +5,7 @@ class ReplaceNameserversTest < ActiveSupport::TestCase @registrar = registrars(:bestnames) end - def test_replace_nameservers_in_bulk_returns_domain_names + def test_replace_nameservers_in_bulk_returns_sorted_domain_names new_attributes = { hostname: 'ns-updated1.bestnames.test', ipv4: '192.0.3.1', ipv6: '2001:db8::2' } result = @registrar.replace_nameservers('ns1.bestnames.test', new_attributes) From 6fb1e44ccaac9fa872b01183bf41b4898c637dd0 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 5 Jul 2018 17:53:03 +0300 Subject: [PATCH 62/64] Move affected domains to the top of the hash, update integration test --- app/api/repp/nameservers_v1.rb | 4 ++-- app/controllers/registrar/nameservers_controller.rb | 5 ++++- config/locales/registrar/nameservers.en.yml | 1 + doc/repp/v1/nameservers.md | 6 +++--- test/integration/api/nameservers/put_test.rb | 4 ++-- test/integration/registrar/bulk_change/nameserver_test.rb | 6 +++--- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/api/repp/nameservers_v1.rb b/app/api/repp/nameservers_v1.rb index 71fde5aba..41a735b09 100644 --- a/app/api/repp/nameservers_v1.rb +++ b/app/api/repp/nameservers_v1.rb @@ -37,8 +37,8 @@ module Repp status 200 @response = { data: { type: 'nameserver', id: params[:data][:attributes][:hostname], - attributes: params[:data][:attributes], - affected_domains: affected_domains } } + attributes: params[:data][:attributes]}, + affected_domains: affected_domains } end end end diff --git a/app/controllers/registrar/nameservers_controller.rb b/app/controllers/registrar/nameservers_controller.rb index b6f7af829..3b70059a2 100644 --- a/app/controllers/registrar/nameservers_controller.rb +++ b/app/controllers/registrar/nameservers_controller.rb @@ -44,7 +44,10 @@ class Registrar parsed_response = JSON.parse(response.body, symbolize_names: true) if response.code == '200' - flash[:notice] = t '.replaced' + notices = [t('.replaced')] + notices << "#{t('.affected_domains')}: #{parsed_response[:affected_domains].join(', ')}" + + flash[:notice] = notices redirect_to registrar_domains_url else @api_errors = parsed_response[:errors] diff --git a/config/locales/registrar/nameservers.en.yml b/config/locales/registrar/nameservers.en.yml index fbe4c387e..6cc08f0ab 100644 --- a/config/locales/registrar/nameservers.en.yml +++ b/config/locales/registrar/nameservers.en.yml @@ -3,3 +3,4 @@ en: nameservers: update: replaced: Nameserver have been successfully replaced + affected_domains: Affected domains diff --git a/doc/repp/v1/nameservers.md b/doc/repp/v1/nameservers.md index c1269f92a..8190530d7 100644 --- a/doc/repp/v1/nameservers.md +++ b/doc/repp/v1/nameservers.md @@ -34,9 +34,9 @@ Content-Type: application/json "hostname": "new-ns1.example.com", "ipv4": ["192.0.2.1", "192.0.2.2"], "ipv6": ["2001:db8::1", "2001:db8::2"] - }, - "affected_domains": ["example.com", "example.org"] - } + } + }, + "affected_domains": ["example.com", "example.org"] } ``` diff --git a/test/integration/api/nameservers/put_test.rb b/test/integration/api/nameservers/put_test.rb index e840cfcfc..0967a1169 100644 --- a/test/integration/api/nameservers/put_test.rb +++ b/test/integration/api/nameservers/put_test.rb @@ -54,8 +54,8 @@ class APINameserversPutTest < ActionDispatch::IntegrationTest id: 'ns55.bestnames.test', attributes: { hostname: 'ns55.bestnames.test', ipv4: ['192.0.2.55'], - ipv6: ['2001:db8::55'] }, - affected_domains: ["airport.test", "shop.test"] } }), + ipv6: ['2001:db8::55'] }}, + affected_domains: ["airport.test", "shop.test"] }), JSON.parse(response.body, symbolize_names: true) end diff --git a/test/integration/registrar/bulk_change/nameserver_test.rb b/test/integration/registrar/bulk_change/nameserver_test.rb index d1dbfc012..841e68db5 100644 --- a/test/integration/registrar/bulk_change/nameserver_test.rb +++ b/test/integration/registrar/bulk_change/nameserver_test.rb @@ -16,9 +16,8 @@ class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest basic_auth: ['test_goodnames', 'testtest']) .to_return(body: { data: [{ type: 'nameserver', - id: 'new-ns.bestnames.test', - affected_domains: ["airport.test", "shop.test"] - }] }.to_json, status: 200) + id: 'new-ns.bestnames.test'}], + affected_domains: ["airport.test", "shop.test"]}.to_json, status: 200) visit registrar_domains_url click_link 'Bulk change' @@ -33,6 +32,7 @@ class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest assert_requested request_stub assert_current_path registrar_domains_path assert_text 'Nameserver have been successfully replaced' + assert_text 'Affected domains: airport.test, shop.test' end def test_fails_gracefully From 4d5dd1dae795b2da9b53f094defd07963e6041ae Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 5 Jul 2018 17:58:22 +0300 Subject: [PATCH 63/64] Fix rubocop issues --- app/api/repp/nameservers_v1.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/repp/nameservers_v1.rb b/app/api/repp/nameservers_v1.rb index 41a735b09..04d7d4f6a 100644 --- a/app/api/repp/nameservers_v1.rb +++ b/app/api/repp/nameservers_v1.rb @@ -37,7 +37,7 @@ module Repp status 200 @response = { data: { type: 'nameserver', id: params[:data][:attributes][:hostname], - attributes: params[:data][:attributes]}, + attributes: params[:data][:attributes] }, affected_domains: affected_domains } end end From f1c7d9415dcb85db0823a7c7b233ac04203f497d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Mon, 9 Jul 2018 14:58:49 +0300 Subject: [PATCH 64/64] Changelog update 180710 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bb6ed19e..838ff6ea4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +10.07.2018 +* Nameserver bulk change returns list of affected doamins [#835](https://github.com/internetee/registry/issues/835) + 26.06.2018 * Whois data is updated now on pendingUpdate status removal [#757](https://github.com/internetee/registry/issues/757) * Portal for registrars displays control code for MID authentication [#893](https://github.com/internetee/registry/issues/893)