diff --git a/.codeclimate.yml b/.codeclimate.yml index 4f803baf1..ffcd2856c 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -48,7 +48,6 @@ exclude_patterns: - "config/" - "db/" - "lib/core_monkey_patches/" - - "lib/daemons/" - "lib/gem_monkey_patches/" - "lib/tasks/api_log.rake" - "lib/tasks/bootstrap.rake" diff --git a/Gemfile b/Gemfile index f38931c70..4ba187b94 100644 --- a/Gemfile +++ b/Gemfile @@ -62,13 +62,10 @@ gem 'omniauth-tara', github: 'internetee/omniauth-tara' # gem 'omniauth-tara', path: 'vendor/gems/omniauth-tara' gem 'airbrake' -gem 'daemons-rails', '1.2.1' gem 'epp', github: 'internetee/epp', branch: :master gem 'epp-xml', '1.2.0', github: 'internetee/epp-xml', branch: :master gem 'jquery-ui-rails', '6.0.1' gem 'pdfkit' -gem 'que' -gem 'que-web' gem 'sidekiq', '>= 6.4.1' gem 'company_register', github: 'internetee/company_register', diff --git a/Gemfile.lock b/Gemfile.lock index 158e97986..f1908d37c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -202,10 +202,6 @@ GEM crack (0.4.5) rexml crass (1.0.6) - daemons (1.3.1) - daemons-rails (1.2.1) - daemons - multi_json (~> 1.0) data_migrate (8.0.0) activerecord (>= 5.0) railties (>= 5.0) @@ -227,7 +223,6 @@ GEM domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) erubi (1.10.0) - erubis (2.7.0) execjs (2.7.0) ffi (1.15.0) figaro (1.2.0) @@ -318,9 +313,6 @@ GEM money (~> 6.13.2) railties (>= 3.0) msgpack (1.4.2) - multi_json (1.15.0) - mustermann (1.1.1) - ruby2_keywords (~> 0.0.1) netrc (0.11.0) newrelic-infinite_tracing (8.1.0) grpc (~> 1.34) @@ -353,7 +345,7 @@ GEM paper_trail (12.1.0) activerecord (>= 5.2) request_store (~> 1.1) - pdfkit (0.8.5) + pdfkit (0.8.7) pg (1.4.3) pg_query (2.1.2) google-protobuf (>= 3.17.1) @@ -365,11 +357,6 @@ GEM public_suffix (4.0.6) puma (5.6.4) nio4r (~> 2.0) - que (0.14.3) - que-web (0.7.2) - erubis - que (~> 0.8) - sinatra racc (1.6.0) rack (2.2.4) rack-oauth2 (1.16.0) @@ -378,8 +365,6 @@ GEM httpclient json-jwt (>= 1.11.0) rack (>= 2.1.0) - rack-protection (2.2.0) - rack rack-test (1.1.0) rack (>= 1.0, < 3) rails (6.1.4.1) @@ -427,7 +412,6 @@ GEM mime-types (>= 1.16, < 4.0) netrc (~> 0.8) rexml (3.2.5) - ruby2_keywords (0.0.5) rubyzip (2.3.2) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) @@ -463,11 +447,6 @@ GEM simplecov-html (0.10.2) simpleidn (0.2.1) unf (~> 0.1.4) - sinatra (2.2.0) - mustermann (~> 1.0) - rack (~> 2.2) - rack-protection (= 2.2.0) - tilt (~> 2.0) sixarm_ruby_unaccent (1.2.0) socksify (1.7.1) sprockets (4.0.2) @@ -546,7 +525,6 @@ DEPENDENCIES coffee-rails (>= 5.0) company_register! countries - daemons-rails (= 1.2.1) data_migrate (~> 8.0) database_cleaner devise (~> 4.8) @@ -582,8 +560,6 @@ DEPENDENCIES pghero pry (= 0.14.1) puma - que - que-web rails (~> 6.1.4) ransack (~> 2.6.0) rest-client diff --git a/README.md b/README.md index 2d5b058cc..5fcce9e91 100644 --- a/README.md +++ b/README.md @@ -390,7 +390,6 @@ sudo apt-get install libxext-dev libxrender1 fontconfig ### Deployment * [Application build and update](/doc/application_build_doc.md) -* [Registry que server](/doc/que/README.md) ### Autotesting diff --git a/app/controllers/admin/api_users_controller.rb b/app/controllers/admin/api_users_controller.rb index cbef7def2..9e4111c9f 100644 --- a/app/controllers/admin/api_users_controller.rb +++ b/app/controllers/admin/api_users_controller.rb @@ -17,8 +17,7 @@ module Admin if @api_user.valid? @api_user.save! - redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), - notice: t('.created') + redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), notice: t('.created') else render 'new' end @@ -35,8 +34,7 @@ module Admin if @api_user.valid? @api_user.save! - redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), - notice: t('.updated') + redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), notice: t('.updated') else render 'edit' end @@ -47,8 +45,45 @@ module Admin redirect_to admin_registrar_path(@api_user.registrar), notice: t('.deleted') end + def set_test_date_to_api_user + user_api = User.find(params[:user_api_id]) + + uri = URI.parse((ENV['registry_demo_registrar_api_user_url']) + "?username=#{user_api.username}&identity_code=#{user_api.identity_code}") + + response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port']) + + if response.code == "200" + result = JSON.parse(response.body) + demo_user_api = result['user_api'] + + Actions::RecordDateOfTest.record_result_to_api_user(api_user:user_api, + date: demo_user_api['accreditation_date']) unless demo_user_api.empty? + return redirect_to request.referrer, notice: 'User Api found' + else + return redirect_to request.referrer, notice: 'User Api no found or not accriditated yet' + end + + redirect_to request.referrer, notice: 'Something goes wrong' + end + + def remove_test_date_to_api_user + user_api = User.find(params[:user_api_id]) + user_api.accreditation_date = nil + user_api.accreditation_expire_date = nil + user_api.save + + redirect_to request.referrer + end + private + def base_get_request(uri:, port:) + http = Net::HTTP.new(uri.host, port) + req = Net::HTTP::Get.new(uri.request_uri) + + http.request(req) + end + def api_user_params params.require(:api_user).permit(:username, :plain_text_password, :active, :identity_code, { roles: [] }) diff --git a/app/controllers/admin/auctions_controller.rb b/app/controllers/admin/auctions_controller.rb index c1023b705..05bfc239f 100644 --- a/app/controllers/admin/auctions_controller.rb +++ b/app/controllers/admin/auctions_controller.rb @@ -44,7 +44,7 @@ module Admin if auction.save reserved_domain = auction.domain if remove_from_reserved(auction) - flash[:notice] = "Auction #{params[:domain]} created. + flash[:notice] = "Auction #{params[:domain]} created. #{reserved_domain.present? ? 'These domain will be removed from reserved list: ' + reserved_domain : ' '}" else flash[:alert] = 'Something goes wrong' @@ -53,6 +53,18 @@ module Admin redirect_to admin_auctions_path end + def destroy + auction = Auction.find(params[:id]) + + if auction.destroy + flash[:notice] = I18n.t('record_deleted') + else + flash.now[:alert] = I18n.t('failed_to_delete_record') + end + + redirect_to admin_auctions_path + end + def upload_spreadsheet if params[:q].nil? flash[:alert] = 'No file upload! Look at the left of upload button!' diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 707b40654..0b3a8b785 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -2,7 +2,7 @@ module Admin class DomainsController < BaseController DEFAULT_VERSIONS_PER_PAGE = 10 - before_action :set_domain, only: %i[show edit update keep] + before_action :set_domain, only: %i[show edit update download keep] authorize_resource # rubocop:disable Metrics/MethodLength @@ -65,6 +65,11 @@ module Admin .per(DEFAULT_VERSIONS_PER_PAGE) end + def download + filename = "#{@domain.name}.pdf" + send_data @domain.as_pdf, filename: filename + end + def keep @domain.keep redirect_to edit_admin_domain_url(@domain), notice: t('.kept') diff --git a/app/controllers/admin/registrars_controller.rb b/app/controllers/admin/registrars_controller.rb index a803a8e7d..b552a8cb3 100644 --- a/app/controllers/admin/registrars_controller.rb +++ b/app/controllers/admin/registrars_controller.rb @@ -1,3 +1,5 @@ +require 'net/http' + module Admin class RegistrarsController < BaseController # rubocop:disable Metrics/ClassLength load_and_authorize_resource @@ -55,8 +57,56 @@ module Admin end end + def set_test_date + registrar = Registrar.find(params[:registrar_id]) + + uri = URI.parse((ENV['registry_demo_registrar_results_url']) + "?registrar_name=#{registrar.name}") + + response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port']) + + if response.code == "200" + return record_result_for_each_api_user(response: response) + else + return redirect_to request.referer, notice: 'Registrar no found' + end + + redirect_to request.referer, notice: 'Something goes wrong' + end + + def remove_test_date + registrar = Registrar.find(params[:registrar_id]) + registrar.api_users.each do |api| + api.accreditation_date = nil + api.accreditation_expire_date = nil + api.save + end + + redirect_to request.referer + end + private + def record_result_for_each_api_user(response:) + result = JSON.parse(response.body) + registrar_users = result['registrar_users'] + + return redirect_to request.referer, notice: 'Registrar found, but not accreditated yet' if registrar_users.empty? + + registrar_users.each do |api| + a = ApiUser.find_by(username: api['username'], identity_code: api['identity_code']) + Actions::RecordDateOfTest.record_result_to_api_user(api_user: a, date: api['accreditation_date']) unless a.nil? + end + + redirect_to request.referer, notice: 'Registrar found' + end + + def base_get_request(uri:, port:) + http = Net::HTTP.new(uri.host, port) + req = Net::HTTP::Get.new(uri.request_uri) + + http.request(req) + end + def filter_by_status case params[:status] when 'Active' diff --git a/app/controllers/api/v1/accreditation_center/base_controller.rb b/app/controllers/api/v1/accreditation_center/base_controller.rb index 7deb776b9..aebdffd8a 100644 --- a/app/controllers/api/v1/accreditation_center/base_controller.rb +++ b/app/controllers/api/v1/accreditation_center/base_controller.rb @@ -4,23 +4,25 @@ module Api module V1 module AccreditationCenter class BaseController < ActionController::API - rescue_from ActiveRecord::RecordNotFound, with: :show_not_found_error - rescue_from ActiveRecord::RecordInvalid, with: :show_invalid_record_error - rescue_from(ActionController::ParameterMissing) do |parameter_missing_exception| - error = {} - error[parameter_missing_exception.param] = ['parameter is required'] - response = { errors: [error] } - render json: response, status: :unprocessable_entity - end + if Feature.allow_accr_endspoints? + rescue_from ActiveRecord::RecordNotFound, with: :show_not_found_error + rescue_from ActiveRecord::RecordInvalid, with: :show_invalid_record_error + rescue_from(ActionController::ParameterMissing) do |parameter_missing_exception| + error = {} + error[parameter_missing_exception.param] = ['parameter is required'] + response = { errors: [error] } + render json: response, status: :unprocessable_entity + end - private + private - def show_not_found_error - render json: { errors: [{ base: ['Not found'] }] }, status: :not_found - end + def show_not_found_error + render json: { errors: [{ base: ['Not found'] }] }, status: :not_found + end - def show_invalid_record_error(exception) - render json: { errors: exception.record.errors }, status: :bad_request + def show_invalid_record_error(exception) + render json: { errors: exception.record.errors }, status: :bad_request + end end end end diff --git a/app/controllers/api/v1/accreditation_center/results_controller.rb b/app/controllers/api/v1/accreditation_center/results_controller.rb new file mode 100644 index 000000000..8a6fd2d51 --- /dev/null +++ b/app/controllers/api/v1/accreditation_center/results_controller.rb @@ -0,0 +1,40 @@ +require 'serializers/repp/contact' + +module Api + module V1 + module AccreditationCenter + class ResultsController < ::Api::V1::AccreditationCenter::BaseController + def show + accr_users = [] + registrar = Registrar.find_by(name: params[:registrar_name]) + + return render json: { errors: 'Registrar not found' }, status: :not_found if registrar.nil? + + registrar.api_users.where.not(accreditation_date: nil).each do |u| + accr_users << u + end + + render json: { code: 1000, registrar_users: accr_users } + end + + def show_api_user + user_api = User.find_by(username: params[:username], identity_code: params[:identity_code]) + + return render json: { errors: 'User not found' }, status: :not_found if user_api.nil? + + return render json: { errors: 'No accreditated yet' }, status: :not_found if user_api.accreditation_date.nil? + + render json: { code: 1000, user_api: user_api } + end + + def list_accreditated_api_users + users = User.where.not(accreditation_date: nil) + + return render json: { errors: 'Accreditated users not found' }, status: :not_found if users.empty? + + render json: { code: 1000, users: users } + end + end + end + end +end diff --git a/app/controllers/api/v1/auctions_controller.rb b/app/controllers/api/v1/auctions_controller.rb index 9a01f4e68..07f4971dc 100644 --- a/app/controllers/api/v1/auctions_controller.rb +++ b/app/controllers/api/v1/auctions_controller.rb @@ -31,6 +31,7 @@ module Api end auction.mark_deadline(params[:registration_deadline]) if params[:registration_deadline] + auction.platform = params[:platform] == 'english' ? :manual : :auto if auction.payment_not_received? || auction.domain_not_registered? update_whois_from_auction(Auction.pending(auction.domain)) diff --git a/app/controllers/eis_billing/payment_status_controller.rb b/app/controllers/eis_billing/payment_status_controller.rb index 4fa626e5d..015eed64a 100644 --- a/app/controllers/eis_billing/payment_status_controller.rb +++ b/app/controllers/eis_billing/payment_status_controller.rb @@ -10,9 +10,7 @@ module EisBilling bank = create_bank_transfer(invoice: invoice, sum: params[:standing_amount], paid_at: params[:transaction_time]) create_payment_order(invoice: invoice, everypay_response: params, payment_status: payment_status) - - registrar = invoice.buyer - bank.create_activity(registrar, invoice) + bank.bind_invoice(params[:order_reference]) respond_to do |format| format.json do diff --git a/app/controllers/repp/v1/registrar/accreditation_info_controller.rb b/app/controllers/repp/v1/registrar/accreditation_info_controller.rb index cd86ce9ed..c55a561d2 100644 --- a/app/controllers/repp/v1/registrar/accreditation_info_controller.rb +++ b/app/controllers/repp/v1/registrar/accreditation_info_controller.rb @@ -2,35 +2,37 @@ module Repp module V1 module Registrar class AccreditationInfoController < BaseController - api :GET, 'repp/v1/registrar/accreditation/get_info' - desc 'check login user and return data' + if Feature.allow_accr_endspoints? + api :GET, 'repp/v1/registrar/accreditation/get_info' + desc 'check login user and return data' - def index - login = current_user - registrar = current_user.registrar + def index + login = current_user + registrar = current_user.registrar - # rubocop:disable Style/AndOr - render_success(data: nil) and return unless login - # rubocop:enable Style/AndOr + # rubocop:disable Style/AndOr + render_success(data: nil) and return unless login + # rubocop:enable Style/AndOr - data = set_values_to_data(login: login, registrar: registrar) + data = set_values_to_data(login: login, registrar: registrar) - render_success(data: data) - end + render_success(data: data) + end - private + private - def set_values_to_data(login:, registrar:) - data = login.as_json(only: %i[id - username - name - uuid - roles - accreditation_date - accreditation_expire_date]) - data[:registrar_name] = registrar.name - data[:registrar_reg_no] = registrar.reg_no - data + def set_values_to_data(login:, registrar:) + data = login.as_json(only: %i[id + username + name + uuid + roles + accreditation_date + accreditation_expire_date]) + data[:registrar_name] = registrar.name + data[:registrar_reg_no] = registrar.reg_no + data + end end end end diff --git a/app/controllers/repp/v1/registrar/accreditation_results_controller.rb b/app/controllers/repp/v1/registrar/accreditation_results_controller.rb index b58fd3895..3cee7422b 100644 --- a/app/controllers/repp/v1/registrar/accreditation_results_controller.rb +++ b/app/controllers/repp/v1/registrar/accreditation_results_controller.rb @@ -2,79 +2,80 @@ module Repp module V1 module Registrar class AccreditationResultsController < ActionController::API - before_action :authenticate_shared_key + if Feature.allow_accr_endspoints? + before_action :authenticate_shared_key - TEMPORARY_SECRET_KEY = ENV['accreditation_secret'].freeze - EXPIRE_DEADLINE = 15.minutes.freeze + TEMPORARY_SECRET_KEY = ENV['accreditation_secret'].freeze + EXPIRE_DEADLINE = 15.minutes.freeze - api :POST, 'repp/v1/registrar/accreditation/push_results' - desc 'added datetime results' + api :POST, 'repp/v1/registrar/accreditation/push_results' + desc 'added datetime results' - def create - username = params[:accreditation_result][:username] - result = params[:accreditation_result][:result] + def create + username = params[:accreditation_result][:username] + result = params[:accreditation_result][:result] - record_accreditation_result(username, result) if result - rescue ActiveRecord::RecordNotFound - record_not_found(username) - end - - private - - def record_accreditation_result(username, result) - user = ApiUser.find_by(username: username) - - raise ActiveRecord::RecordNotFound if user.nil? - - user.accreditation_date = DateTime.current - user.accreditation_expire_date = user.accreditation_date + EXPIRE_DEADLINE - - if user.save - notify_registrar(user) - notify_admins - render_success(data: { user: user, - result: result, - message: 'Accreditation info successfully added' }) - else - render_failed + record_accreditation_result(username, result) if result + rescue ActiveRecord::RecordNotFound + record_not_found(username) end - end - def notify_registrar(user) - AccreditationCenterMailer.test_was_successfully_passed_registrar(user.registrar.email).deliver_now - end + private - def notify_admins - admin_users_emails = User.all.reject { |u| u.roles.nil? } - .select { |u| u.roles.include? 'admin' }.pluck(:email) + def record_accreditation_result(username, result) + user = ApiUser.find_by(username: username) - return if admin_users_emails.empty? + raise ActiveRecord::RecordNotFound if user.nil? + user.accreditation_date = DateTime.current + user.accreditation_expire_date = user.accreditation_date + EXPIRE_DEADLINE - admin_users_emails.each do |email| - AccreditationCenterMailer.test_was_successfully_passed_admin(email).deliver_now + if user.save + notify_registrar(user) + notify_admins + render_success(data: { user: user, + result: result, + message: 'Accreditation info successfully added' }) + else + render_failed + end end - end - def authenticate_shared_key - api_key = "Basic #{TEMPORARY_SECRET_KEY}" - render_failed unless api_key == request.authorization - end + def notify_registrar(user) + AccreditationCenterMailer.test_was_successfully_passed_registrar(user.registrar.email).deliver_now + end - def record_not_found(username) - @response = { code: 2303, message: "Object '#{username}' does not exist" } - render(json: @response) - end + def notify_admins + admin_users_emails = User.all.reject { |u| u.roles.nil? } + .select { |u| u.roles.include? 'admin' }.pluck(:email) - def render_failed - @response = { code: 2202, message: 'Invalid authorization information' } - render(json: @response, status: :unauthorized) - end + return if admin_users_emails.empty? - def render_success(code: nil, message: nil, data: nil) - @response = { code: code || 1000, message: message || 'Command completed successfully', - data: data || {} } + admin_users_emails.each do |email| + AccreditationCenterMailer.test_was_successfully_passed_admin(email).deliver_now + end + end - render(json: @response, status: :ok) + def authenticate_shared_key + api_key = "Basic #{TEMPORARY_SECRET_KEY}" + render_failed unless api_key == request.authorization + end + + def record_not_found(username) + @response = { code: 2303, message: "Object '#{username}' does not exist" } + render(json: @response) + end + + def render_failed + @response = { code: 2202, message: 'Invalid authorization information' } + render(json: @response, status: :unauthorized) + end + + def render_success(code: nil, message: nil, data: nil) + @response = { code: code || 1000, message: message || 'Command completed successfully', + data: data || {} } + + render(json: @response, status: :ok) + end end end end diff --git a/app/interactions/actions/record_date_of_test.rb b/app/interactions/actions/record_date_of_test.rb new file mode 100644 index 000000000..229929429 --- /dev/null +++ b/app/interactions/actions/record_date_of_test.rb @@ -0,0 +1,13 @@ +module Actions + module RecordDateOfTest + extend self + + TEST_DEADLINE = 1.year.freeze + + def record_result_to_api_user(api_user:, date:) + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + TEST_DEADLINE + api_user.save + end + end +end diff --git a/app/jobs/sync_accredited_users_job.rb b/app/jobs/sync_accredited_users_job.rb new file mode 100644 index 000000000..de95b59c8 --- /dev/null +++ b/app/jobs/sync_accredited_users_job.rb @@ -0,0 +1,27 @@ +class SyncAccreditedUsersJob < ApplicationJob + def perform + uri = URI.parse(ENV['registry_demo_accredited_users_url']) + response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port']) + + if response.code == '200' + result = JSON.parse(response.body) + result['users'].each do |api| + a = ApiUser.find_by(username: api.username, identity_code: api.identity_code) + Actions::RecordDateOfTest.record_result_to_api_user(a, api.accreditation_date) unless a.nil? + end + else + logger.warn 'User not found' + end + + nil + end + + private + + def base_get_request(uri:, port:) + http = Net::HTTP.new(uri.host, port) + req = Net::HTTP::Get.new(uri.request_uri) + + http.request(req) + end +end diff --git a/app/models/api_user.rb b/app/models/api_user.rb index dc5cff0cc..a15b12a85 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -56,6 +56,16 @@ class ApiUser < User username end + def accredited? + !accreditation_date.nil? + end + + def accreditation_expired? + return false if accreditation_expire_date.nil? + + accreditation_expire_date < Time.zone.now + end + def unread_notifications registrar.notifications.unread end diff --git a/app/models/auction.rb b/app/models/auction.rb index 465a827ec..d1c46d44e 100644 --- a/app/models/auction.rb +++ b/app/models/auction.rb @@ -84,7 +84,9 @@ class Auction < ApplicationRecord end def restart - new_auction = self.class.new(domain: domain) + new_platform = platform.nil? ? :auto : platform + + new_auction = self.class.new(domain: domain, platform: new_platform) new_auction.start end diff --git a/app/models/bank_transaction.rb b/app/models/bank_transaction.rb index ef2ab3370..bd437fe96 100644 --- a/app/models/bank_transaction.rb +++ b/app/models/bank_transaction.rb @@ -88,7 +88,16 @@ class BankTransaction < ApplicationRecord errors.add(:base, I18n.t('invoice_and_transaction_sums_do_not_match')) if invoice.total != sum end + def parsed_ref_number + reference_no || ref_number_from_description + end + + private + def create_activity(registrar, invoice) + validate_invoice_data(invoice) + return if errors.any? + activity = AccountActivity.new(account: registrar.cash_account, bank_transaction: self, invoice: invoice, sum: invoice.subtotal, currency: currency, description: description, @@ -102,12 +111,6 @@ class BankTransaction < ApplicationRecord end end - def parsed_ref_number - reference_no || ref_number_from_description - end - - private - def reset_pending_registrar_balance_reload(registrar) return unless registrar.settings['balance_auto_reload'] diff --git a/app/models/domain.rb b/app/models/domain.rb index a8fc323a0..e75f5165c 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -743,6 +743,12 @@ class Domain < ApplicationRecord ] end + def as_pdf + domain_html = ApplicationController.render(template: 'domain/pdf', assigns: { domain: self }) + generator = PDFKit.new(domain_html) + generator.to_pdf + end + def registrant_name return registrant.name if registrant diff --git a/app/models/feature.rb b/app/models/feature.rb index 7a0d6d78b..ed7ae12fd 100644 --- a/app/models/feature.rb +++ b/app/models/feature.rb @@ -4,4 +4,18 @@ class Feature ENV['billing_system_integrated'] || false end + # def self.obj_and_extensions_statuses_enabled? + # return false if ENV['obj_and_extensions_prohibited'] == 'false' + # + # ENV['obj_and_extensions_prohibited'] || false + # end + # + # def self.enable_lock_domain_with_new_statuses? + # return false if ENV['enable_lock_domain_with_new_statuses'] == 'false' + # + # ENV['enable_lock_domain_with_new_statuses'] || false + # end + def self.allow_accr_endspoints? + ENV['allow_accr_endspoints'] == 'true' + end end diff --git a/app/models/que_job.rb b/app/models/que_job.rb deleted file mode 100644 index 40ef6a67e..000000000 --- a/app/models/que_job.rb +++ /dev/null @@ -1,3 +0,0 @@ -class QueJob < ApplicationRecord - self.primary_key = 'job_id' -end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 07d7d4795..5d6d7538f 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -190,6 +190,16 @@ class Registrar < ApplicationRecord # rubocop:disable Metrics/ClassLength white_ips.api.include_ip?(ip) end + def accredited? + api_users.any? do |a| + return true unless a.accreditation_date.nil? + end + end + + def accreditation_expired? + api_users.all? { |api| api.accreditation_expired? } + end + # Audit log is needed, therefore no raw SQL def replace_nameservers(hostname, new_attributes, domains: []) transaction do diff --git a/app/views/admin/api_users/_api_user.html.erb b/app/views/admin/api_users/_api_user.html.erb index d8412a519..5c443bfee 100644 --- a/app/views/admin/api_users/_api_user.html.erb +++ b/app/views/admin/api_users/_api_user.html.erb @@ -2,4 +2,16 @@
+ | <%= sort_link(@q, 'username') %> | -+ | <%= sort_link(@q, 'registrar_name', Registrar.model_name.human) %> | -+ | <%= sort_link(@q, 'active', ApiUser.human_attribute_name(:active)) %> | ++ Test status + | <%= auction.registration_code %> | <%= auction.registration_deadline %> | <%= auction.platform.nil? ? 'auto' : auction.platform %> | +<%= link_to(t(:delete), admin_auction_path(auction), method: :delete, data: { confirm: t(:are_you_sure_you_want_to_delete_auction) }, class: 'btn btn-danger', id: "delete-auction-#{auction.id}") %> | <% end %> @@ -152,4 +153,4 @@ $('#user-form-edit').on("show.bs.modal", function(e) { $(this).find('.modal-body').load(e.relatedTarget.dataset.url); }); - \ No newline at end of file + diff --git a/app/views/admin/base/_menu.haml b/app/views/admin/base/_menu.haml index 92efc2347..f1e855742 100644 --- a/app/views/admin/base/_menu.haml +++ b/app/views/admin/base/_menu.haml @@ -39,7 +39,9 @@ %li= link_to t('.bounced_email_addresses'), admin_bounced_mail_addresses_path %li= link_to t('.epp_log'), admin_epp_logs_path(created_after: 'today') %li= link_to t('.repp_log'), admin_repp_logs_path(created_after: 'today') - %li= link_to t('.que'), '/admin/que' + %li.divider + %li.dropdown-header= t('.tasks') + %li= link_to t('.sidekiq'), admin_sidekiq_web_path %ul.nav.navbar-nav.navbar-right %li= link_to t('.sign_out'), destroy_admin_user_session_path, method: :delete, diff --git a/app/views/admin/domains/show.html.erb b/app/views/admin/domains/show.html.erb index 2b2835429..3055dbca5 100644 --- a/app/views/admin/domains/show.html.erb +++ b/app/views/admin/domains/show.html.erb @@ -6,11 +6,12 @@<%= t(:emails) %> | + ++ Test status + | @@ -58,6 +62,17 @@ <%= content_tag(:span, x[:billing_email]) %> <% end %> ++ <% if !x.accredited? || x.accreditation_expired? %> + <%= button_to t('.set_test_btn'), + { controller: 'registrars', action: 'set_test_date', registrar_id: x.id}, + { method: :post, class: 'btn btn-primary'} %> + <% else %> + <%= button_to t('.remove_test_btn'), + { controller: 'registrars', action: 'remove_test_date', registrar_id: x.id}, + { method: :post, class: 'btn btn-danger'} %> + <% end %> + | <% end %> diff --git a/app/views/admin/registrars/show/_api_users.html.erb b/app/views/admin/registrars/show/_api_users.html.erb index 2d10b1c56..fddccd9b7 100644 --- a/app/views/admin/registrars/show/_api_users.html.erb +++ b/app/views/admin/registrars/show/_api_users.html.erb @@ -8,6 +8,7 @@
---|---|---|---|---|---|---|
<%= ApiUser.human_attribute_name :username %> | <%= ApiUser.human_attribute_name :active %> | +Test Results | ||||
<%= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user) %> | <%= api_user.active %> | ++ + <% if !api_user.accredited? || api_user.accreditation_expired? %> + <%= button_to t('.set_test_btn'), + { controller: 'api_users', action: 'set_test_date_to_api_user', user_api_id: api_user.id }, + { method: :post, class: 'btn btn-primary'} %> + <% else %> + <%= button_to t('.remove_test_btn'), + { controller: 'api_users', action: 'remove_test_date_to_api_user', user_api_id: api_user.id }, + { method: :post, class: 'btn btn-danger'} %> + <% end %> + |