mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 16:02:03 +02:00
Merge branch 'master' into alpha
This commit is contained in:
commit
16ab685eb1
12 changed files with 155 additions and 17 deletions
|
@ -1,12 +1,43 @@
|
|||
class Registrant::DomainDeleteConfirmsController < RegistrantController
|
||||
skip_before_action :authenticate_user!, only: [:show, :create]
|
||||
skip_authorization_check only: [:show, :create]
|
||||
skip_before_action :authenticate_user!, only: [:show, :update]
|
||||
skip_authorization_check only: [:show, :update]
|
||||
|
||||
def show
|
||||
return if params[:confirmed] || params[:rejected]
|
||||
@domain = Domain.find(params[:id])
|
||||
@domain = nil unless @domain.registrant_delete_confirmable?(params[:token])
|
||||
end
|
||||
|
||||
def create
|
||||
# # rubocop: disable Metrics/PerceivedComplexity
|
||||
# # rubocop: disable Metrics/CyclomaticComplexity
|
||||
def update
|
||||
@domain = Domain.find(params[:id])
|
||||
unless @domain.registrant_delete_confirmable?(params[:token])
|
||||
flash[:alert] = t(:registrant_domain_verification_failed)
|
||||
return render 'show'
|
||||
end
|
||||
|
||||
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
|
||||
domain_name: @domain.name,
|
||||
verification_token: params[:token])
|
||||
if params[:rejected]
|
||||
if @registrant_verification.domain_registrant_delete_reject!
|
||||
flash[:notice] = t(:registrant_domain_verification_rejected)
|
||||
redirect_to registrant_domain_delete_confirm_path(@domain.id, rejected: true)
|
||||
else
|
||||
flash[:alert] = t(:registrant_domain_verification_rejected_failed)
|
||||
return render 'show'
|
||||
end
|
||||
elsif params[:confirmed]
|
||||
if @registrant_verification.domain_registrant_delete_confirm!
|
||||
flash[:notice] = t(:registrant_domain_verification_confirmed)
|
||||
redirect_to registrant_domain_delete_confirm_path(@domain.id, confirmed: true)
|
||||
else
|
||||
flash[:alert] = t(:registrant_domain_verification_confirmed_failed)
|
||||
return render 'show'
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
end
|
||||
|
|
16
app/jobs/domain_delete_confirm_job.rb
Normal file
16
app/jobs/domain_delete_confirm_job.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
class DomainDeleteConfirmJob < Que::Job
|
||||
def run(domain_id, action)
|
||||
# it's recommended to keep transaction against job table as short as possible.
|
||||
ActiveRecord::Base.transaction do
|
||||
domain = Epp::Domain.find(domain_id)
|
||||
case action
|
||||
when RegistrantVerification::CONFIRMED
|
||||
domain.apply_pending_delete!
|
||||
domain.clean_pendings!
|
||||
when RegistrantVerification::REJECTED
|
||||
domain.clean_pendings!
|
||||
end
|
||||
destroy # it's best to destroy the job in the same transaction
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
class DomainConfirmJob < Que::Job
|
||||
class DomainUpdateConfirmJob < Que::Job
|
||||
def run(domain_id, action)
|
||||
# it's recommended to keep transaction against job table as short as possible.
|
||||
ActiveRecord::Base.transaction do
|
|
@ -390,6 +390,15 @@ class Epp::Domain < Domain
|
|||
clean_pendings! if update(frame, user, false)
|
||||
end
|
||||
|
||||
def apply_pending_delete!
|
||||
preclean_pendings
|
||||
user = ApiUser.find(pending_json['current_user_id'])
|
||||
frame = Nokogiri::XML(pending_json['frame'])
|
||||
statuses.delete(DomainStatus::PENDING_DELETE)
|
||||
|
||||
clean_pendings! if epp_destroy(frame, user, false)
|
||||
end
|
||||
|
||||
def attach_legal_document(legal_document_data)
|
||||
return unless legal_document_data
|
||||
|
||||
|
@ -399,11 +408,12 @@ class Epp::Domain < Domain
|
|||
)
|
||||
end
|
||||
|
||||
def epp_destroy(frame, user_id)
|
||||
def epp_destroy(frame, user_id, verify=true)
|
||||
return false unless valid?
|
||||
|
||||
if frame.css('delete').attr('verified').to_s.downcase != 'yes'
|
||||
if verify && frame.css('delete').attr('verified').to_s.downcase != 'yes'
|
||||
registrant_verification_asked!(frame.to_s, user_id)
|
||||
self.deliver_emails = true # turn on email delivery for epp
|
||||
pending_delete!
|
||||
manage_automatic_statuses
|
||||
true # aka 1001 pending_delete
|
||||
|
|
5
app/models/legacy/invoice.rb
Normal file
5
app/models/legacy/invoice.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
module Legacy
|
||||
class Invoice < Db
|
||||
self.table_name = :invoice
|
||||
end
|
||||
end
|
|
@ -1,5 +1,11 @@
|
|||
module Legacy
|
||||
class Registrar < Db
|
||||
self.table_name = :registrar
|
||||
|
||||
has_many :invoices, foreign_key: :registrarid
|
||||
|
||||
def account_balance
|
||||
invoices.sum(:credit)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,12 +17,24 @@ class RegistrantVerification < ActiveRecord::Base
|
|||
def domain_registrant_change_confirm!
|
||||
self.action_type = DOMAIN_REGISTRANT_CHANGE
|
||||
self.action = CONFIRMED
|
||||
DomainConfirmJob.enqueue domain.id, CONFIRMED if save
|
||||
DomainUpdateConfirmJob.enqueue domain.id, CONFIRMED if save
|
||||
end
|
||||
|
||||
def domain_registrant_change_reject!
|
||||
self.action_type = DOMAIN_REGISTRANT_CHANGE
|
||||
self.action = REJECTED
|
||||
DomainConfirmJob.enqueue domain.id, REJECTED if save
|
||||
DomainUpdateConfirmJob.enqueue domain.id, REJECTED if save
|
||||
end
|
||||
|
||||
def domain_registrant_delete_confirm!
|
||||
self.action_type = DOMAIN_DELETE
|
||||
self.action = CONFIRMED
|
||||
DomainDeleteConfirmJob.enqueue domain.id, CONFIRMED if save
|
||||
end
|
||||
|
||||
def domain_registrant_delete_reject!
|
||||
self.action_type = DOMAIN_DELETE
|
||||
self.action = REJECTED
|
||||
DomainDeleteConfirmJob.enqueue domain.id, REJECTED if save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
= f.label :th6_file
|
||||
.col-md-8
|
||||
= f.file_field :th6_file
|
||||
.col-md-4
|
||||
%p= t(:bank_statement_desc).html_safe
|
||||
%hr
|
||||
.row
|
||||
.col-md-8.text-right
|
||||
|
|
|
@ -1,4 +1,44 @@
|
|||
- if @domain.present?
|
||||
- if params[:confirmed].present?
|
||||
.row
|
||||
.col-md-12
|
||||
%h1= t(:domain_delete_confirmed_title)
|
||||
.row
|
||||
.col-md-12
|
||||
%p= t(:domain_delete_confirmed_body)
|
||||
- elsif params[:rejected].present?
|
||||
.row
|
||||
.col-md-12
|
||||
%h1= t(:domain_delete_rejected_title)
|
||||
.row
|
||||
.col-md-12
|
||||
%p= t(:domain_delete_rejected_body)
|
||||
- else
|
||||
%h1= t(:not_valid_domain_verification_title).html_safe
|
||||
%p= t(:not_valid_domain_verification_body).html_safe
|
||||
- if @domain.present?
|
||||
.row
|
||||
.col-md-12
|
||||
%h1= t(:domain_delete_title)
|
||||
.row
|
||||
.col-md-12
|
||||
%p= t(:domain_delete_body)
|
||||
|
||||
%hr
|
||||
.row
|
||||
.col-md-12.text-center.confirmation
|
||||
.column-keys
|
||||
%p= t(:domain_name) + ':'
|
||||
%p= t(:registrant) + ':'
|
||||
.column-values
|
||||
%p= @domain.name
|
||||
%p= "#{@domain.registrant_name} (#{@domain.registrant.ident})"
|
||||
|
||||
.row
|
||||
.col-md-12.text-center
|
||||
.confirmation
|
||||
= form_for registrant_domain_delete_confirm_path(@domain.id), method: :patch do |f|
|
||||
= hidden_field_tag :token, params[:token]
|
||||
= f.button t(:confirm_domain_delete), name: 'confirmed', class: 'btn btn-primary'
|
||||
= f.button t(:reject_domain_delete), name: 'rejected', class: 'btn btn-warning'
|
||||
%hr
|
||||
- else
|
||||
%h1= t(:not_valid_domain_verification_title).html_safe
|
||||
%p= t(:not_valid_domain_verification_body).html_safe
|
||||
|
|
|
@ -793,14 +793,20 @@ en:
|
|||
new_pending_registrant: 'New registrant'
|
||||
current_registrant: 'Current registrant'
|
||||
registrant_domain_verification_failed: 'Domain verification not available'
|
||||
domain_registrant_change_confirmed_title: 'Domain owner change has been confirmed'
|
||||
domain_registrant_change_confirmed_body: 'You have successfully confirmed domain owner change.'
|
||||
registrant_domain_verification_confirmed: 'Domain owner change has successfully confirmed.'
|
||||
registrant_domain_verification_confirmed_failed: 'Something went wrong'
|
||||
domain_registrant_change_confirmed_title: 'Domain owner change has been received'
|
||||
domain_registrant_change_confirmed_body: 'You have successfully submitted domain owner change confirmation. You will receive email confirmation.'
|
||||
registrant_domain_verification_confirmed: 'Domain owner change has successfully received.'
|
||||
registrant_domain_verification_confirmed_failed: 'Something went wrong.'
|
||||
domain_registrant_change_rejected_title: 'Domain owner change has been rejected'
|
||||
domain_registrant_change_rejected_body: 'You have rejected domain owner change.'
|
||||
registrant_domain_verification_rejected: 'Domain owner change has been rejected successfully.'
|
||||
registrant_domain_verification_rejected_failed: 'Something went wrong'
|
||||
registrant_domain_verification_rejected_failed: 'Something went wrong.'
|
||||
domain_delete_title: 'Please confirm or reject domain deletation'
|
||||
domain_delete_body: 'There is a request to delete a domain. Before doing it we need your confirmation.'
|
||||
domain_delete_confirmed_title: 'Domain deletion has been received successfully'
|
||||
domain_delete_confirmed_body: 'You have successfully submitted delete confirmation. You will receive registry final confirmation to email.'
|
||||
domain_delete_rejected_title: 'Domain deletion has been rejected successfully'
|
||||
domain_delete_rejected_body: 'You have rejected domain deletion.'
|
||||
ip_is_not_whitelisted: 'IP is not whitelisted'
|
||||
no_permission: 'No permission'
|
||||
access_denied: 'Access denied'
|
||||
|
@ -824,3 +830,4 @@ en:
|
|||
unset_force_delete: 'Unset force delete'
|
||||
domain_expiring: 'Domain expiring'
|
||||
domain_validation_rules: 'Domain validation rules'
|
||||
bank_statement_desc: 'Import file row will match only when matching following attributes: <b>invoice nr, description, sum and client ref number</b>.'
|
||||
|
|
|
@ -106,6 +106,15 @@ namespace :import do
|
|||
next if x.cash_account
|
||||
x.accounts.create(account_type: Account::CASH, currency: 'EUR')
|
||||
x.save(validate: false)
|
||||
|
||||
lr = Legacy::Registrar.find(x.legacy_id)
|
||||
x.cash_account.account_activities << AccountActivity.new({
|
||||
sum: lr.account_balance,
|
||||
currency: 'EUR',
|
||||
description: 'Transfer from legacy system'
|
||||
})
|
||||
|
||||
x.cash_account.save
|
||||
end
|
||||
|
||||
puts "-----> Imported #{count} new registrars in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
|
|
|
@ -82,7 +82,7 @@ describe DomainMailer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'email changed notification' do
|
||||
describe 'email pending delete notification' do
|
||||
before :all do
|
||||
@registrant = Fabricate(:registrant, email: 'test@example.com')
|
||||
@domain = Fabricate(:domain, name: 'delete-pending.ee', registrant: @registrant)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue