Merge remote-tracking branch 'origin/master' into 116043697-domain_reject_delete_status

# Conflicts:
#	app/jobs/domain_delete_confirm_job.rb
This commit is contained in:
Vladimir Krylov 2016-04-18 17:30:46 +03:00
commit 475ba0b45a
15 changed files with 160 additions and 116 deletions

View file

@ -5,7 +5,11 @@ class Admin::EppLogsController < AdminController
def index
@q = ApiLog::EppLog.search(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
@epp_logs = @q.result.page(params[:page])
@epp_logs = @q.result
@epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present?
@epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present?
@epp_logs = @epp_logs.page(params[:page])
end
def show

View file

@ -5,7 +5,11 @@ class Admin::ReppLogsController < AdminController
def index
@q = ApiLog::ReppLog.search(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
@repp_logs = @q.result.page(params[:page])
@repp_logs = @q.result
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present?
@repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present?
@repp_logs = @repp_logs.page(params[:page])
end
def show

View file

@ -22,18 +22,18 @@ class Registrant::DomainDeleteConfirmsController < RegistrantController
verification_token: params[:token])
if params[:rejected]
if @registrant_verification.domain_registrant_delete_reject!
flash[:notice] = t(:registrant_domain_verification_rejected)
flash[:notice] = t(:registrant_domain_delete_rejected)
redirect_to registrant_domain_delete_confirm_path(@domain.id, rejected: true)
else
flash[:alert] = t(:registrant_domain_verification_rejected_failed)
flash[:alert] = t(:registrant_domain_delete_rejected_failed)
return render 'show'
end
elsif params[:confirmed]
if @registrant_verification.domain_registrant_delete_confirm!
flash[:notice] = t(:registrant_domain_verification_confirmed)
flash[:notice] = t(:registrant_domain_delete_confirmed)
redirect_to registrant_domain_delete_confirm_path(@domain.id, confirmed: true)
else
flash[:alert] = t(:registrant_domain_verification_confirmed_failed)
flash[:alert] = t(:registrant_domain_delete_confirmed_failed)
return render 'show'
end
end

View file

@ -3,18 +3,30 @@ class DomainDeleteConfirmJob < Que::Job
# 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.poll_message!(:poll_pending_delete_confirmed_by_registrant)
domain.apply_pending_delete!
raise_errors!(domain)
when RegistrantVerification::REJECTED
DomainMailer.pending_delete_rejected_notification(domain_id, true).deliver
domain.statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)
domain.poll_message!(:poll_pending_delete_rejected_by_registrant)
domain.cancel_pending_delete
domain.save(validate: false)
raise_errors!(domain)
DomainMailer.pending_delete_rejected_notification(domain_id, true).deliver
end
domain.save(validate: false)
destroy # it's best to destroy the job in the same transaction
end
end
def raise_errors!(domain)
throw "domain #{domain.name} failed with errors #{domain.errors.full_messages}" if domain.errors.any?
end
end

View file

@ -7,8 +7,13 @@ class DomainUpdateConfirmJob < Que::Job
case action
when RegistrantVerification::CONFIRMED
domain.poll_message!(:poll_pending_update_confirmed_by_registrant)
raise_errors!(domain)
domain.apply_pending_update!
raise_errors!(domain)
domain.clean_pendings!
raise_errors!(domain)
when RegistrantVerification::REJECTED
domain.send_mail :pending_update_rejected_notification_for_new_registrant
domain.poll_message!(:poll_pending_update_rejected_by_registrant)
@ -17,4 +22,8 @@ class DomainUpdateConfirmJob < Que::Job
destroy # it's best to destroy the job in the same transaction
end
end
def raise_errors!(domain)
throw "domain #{domain.name} failed with errors #{domain.errors.full_messages}" if domain.errors.any?
end
end

View file

@ -9,12 +9,34 @@ class DomainMailer < ApplicationMailer
compose_from(params)
end
def registrant_updated_notification_for_new_registrant(params)
compose_from(params)
def registrant_updated_notification_for_new_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver)
@domain = Domain.find_by(id: domain_id)
return unless @domain
return if delivery_off?(@domain, should_deliver)
@old_registrant = Registrant.find(old_registrant_id)
@new_registrant = Registrant.find(new_registrant_id)
return if whitelist_blocked?(@new_registrant.email)
mail(to: format(@new_registrant.email),
subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject,
name: @domain.name)} [#{@domain.name}]")
end
def registrant_updated_notification_for_old_registrant(params)
compose_from(params)
def registrant_updated_notification_for_old_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver)
@domain = Domain.find_by(id: domain_id)
return unless @domain
return if delivery_off?(@domain, should_deliver)
@old_registrant = Registrant.find(old_registrant_id)
@new_registrant = Registrant.find(new_registrant_id)
return if whitelist_blocked?(@old_registrant.email)
mail(to: format(@old_registrant.email),
subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject,
name: @domain.name)} [#{@domain.name}]")
end
def pending_update_rejected_notification_for_new_registrant(params)

View file

@ -20,28 +20,7 @@ class DomainMailModel
domain_info
compose
end
def registrant_updated_notification_for_new_registrant
registrant
subject(:registrant_updated_notification_for_new_registrant_subject)
domain_info
compose
end
def registrant_updated_notification_for_old_registrant
registrant_pending
registrant_old
subject(:registrant_updated_notification_for_old_registrant_subject)
new_registrant = Registrant.find @domain.pending_json['new_registrant_id']
@params[:registrant_name] = new_registrant.name
@params[:registrant_ident] = new_registrant.ident
@params[:registrant_priv] = new_registrant.priv?
@params[:registrant_email] = new_registrant.email
@params[:registrant_street] = new_registrant.street
@params[:registrant_city] = new_registrant.city
@params[:registrant_country] = new_registrant.country.name
compose
end
def pending_update_rejected_notification_for_new_registrant
registrant_pending

View file

@ -535,6 +535,7 @@ class Epp::Domain < Domain
preclean_pendings
user = ApiUser.find(pending_json['current_user_id'])
frame = Nokogiri::XML(pending_json['frame'])
old_registrant_id = registrant_id
self.deliver_emails = true # turn on email delivery
self.statuses.delete(DomainStatus::PENDING_UPDATE)
@ -542,14 +543,15 @@ class Epp::Domain < Domain
self.up_date = Time.zone.now
::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user
send_mail :registrant_updated_notification_for_old_registrant
return unless update(frame, user, false)
clean_pendings!
send_mail :registrant_updated_notification_for_new_registrant
WhoisRecord.find_by(domain_id: id).save # need to reload model
save! # for notification if everything fails
WhoisRecord.find_by(domain_id: id).save # need to reload model
DomainMailer.registrant_updated_notification_for_old_registrant(id, old_registrant_id, registrant_id, true).deliver
DomainMailer.registrant_updated_notification_for_new_registrant(id, old_registrant_id, registrant_id, true).deliver
true
end

View file

@ -1,18 +1,18 @@
Tere,
<br><br>
Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
<br><br>
Uue registreerija andmed:<br>
Nimi: <%= @params[:registrant_name] %><br>
<% if @params[:registrant_priv] %>
Isikukood: <%= @params[:registrant_ident] %><br>
Nimi: <%= @new_registrant.name %><br>
<% if @new_registrant.priv? %>
Isikukood: <%= @new_registrant.ident %><br>
<% else %>
Äriregistrikood: <%= @params[:registrant_ident] %><br>
Äriregistrikood: <%= @new_registrant.ident %><br>
<% end %>
Epost: <%= @params[:registrant_email] %><br>
Tänav: <%= @params[:registrant_street] %><br>
Linn: <%= @params[:registrant_city] %><br>
Riik: <%= @params[:registrant_country] %>
Epost: <%= @new_registrant.email %><br>
Tänav: <%= @new_registrant.street %><br>
Linn: <%= @new_registrant.city %><br>
Riik: <%= @new_registrant.country.name %>
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
@ -21,19 +21,19 @@ Eesti Interneti SA
<br><br>
Hi,
<br><br>
Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
<br><br>
New registrant:<br>
Name: <%= @params[:registrant_name] %><br>
<% if @params[:registrant_priv] %>
Personal code: <%= @params[:registrant_ident] %><br>
Name: <%= @new_registrant.name %><br>
<% if @new_registrant.priv? %>
Personal code: <%= @new_registrant.ident %><br>
<% else %>
Business Registry code: <%= @params[:registrant_ident] %><br>
Business Registry code: <%= @new_registrant.ident %><br>
<% end %>
E-mail: <%= @params[:registrant_email] %><br>
Street: <%= @params[:registrant_street] %><br>
City: <%= @params[:registrant_city] %><br>
Country: <%= @params[:registrant_country] %>
E-mail: <%= @new_registrant.email %><br>
Street: <%= @new_registrant.street %><br>
City: <%= @new_registrant.city %><br>
Country: <%= @new_registrant.country.name %>
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -1,18 +1,19 @@
Tere,
Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
Uue registreerija andmed:
Nimi: <%= @params[:registrant_name] %>
<% if @params[:registrant_priv] %>
Isikukood: <%= @params[:registrant_ident] %>
Nimi: <%= @new_registrant.name %>
<% if @new_registrant.priv? %>
Isikukood: <%= @new_registrant.ident %>
<% else %>
Äriregistrikood: <%= @params[:registrant_ident] %>
Äriregistrikood: <%= @new_registrant.ident %>
<% end %>
Epost: <%= @params[:registrant_email] %>
Tänav: <%= @params[:registrant_street] %>
Linn: <%= @params[:registrant_city] %>
Riik: <%= @params[:registrant_country] %>
Epost: <%= @new_registrant.email %>
Tänav: <%= @new_registrant.street %>
Linn: <%= @new_registrant.city %>
Riik: <%= @new_registrant.country.name %>
Lugupidamisega
Eesti Interneti SA
@ -21,19 +22,20 @@ Eesti Interneti SA
Hi,
Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
New registrant:
Name: <%= @params[:registrant_name] %>
<% if @params[:registrant_priv] %>
Personal code: <%= @params[:registrant_ident] %>
Name: <%= @new_registrant.name %>
<% if @new_registrant.priv? %>
Personal code: <%= @new_registrant.ident %>
<% else %>
Business Registry code: <%= @params[:registrant_ident] %>
Business Registry code: <%= @new_registrant.ident %>
<% end %>
E-mail: <%= @params[:registrant_email] %>
Street: <%= @params[:registrant_street] %>
City: <%= @params[:registrant_city] %>
Country: <%= @params[:registrant_country] %>
E-mail: <%= @new_registrant.email %>
Street: <%= @new_registrant.street %>
City: <%= @new_registrant.city %>
Country: <%= @new_registrant.country.name %>
Best Regards,
Estonian Internet Foundation

View file

@ -1,18 +1,18 @@
Tere,
<br><br>
Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
<br><br>
Uue registreerija andmed:<br>
Nimi: <%= @params[:new_registrant_name] %><br>
<% if @params[:registrant_priv] %>
Isikukood: <%= @params[:registrant_ident] %><br>
Nimi: <%= @new_registrant.name %><br>
<% if @new_registrant.priv? %>
Isikukood: <%= @new_registrant.ident %><br>
<% else %>
Äriregistrikood: <%= @params[:registrant_ident] %><br>
Äriregistrikood: <%= @new_registrant.ident %><br>
<% end %>
Epost: <%= @params[:registrant_email] %><br>
Tänav: <%= @params[:registrant_street] %><br>
Linn: <%= @params[:registrant_city] %><br>
Riik: <%= @params[:registrant_country] %>
Epost: <%= @new_registrant.email %><br>
Tänav: <%= @new_registrant.street %><br>
Linn: <%= @new_registrant.city %><br>
Riik: <%= @new_registrant.country.name %>
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
@ -21,19 +21,19 @@ Eesti Interneti SA
<br><br>
Hi,
<br><br>
Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
<br><br>
New registrant:<br>
Name: <%= @params[:new_registrant_name] %><br>
<% if @params[:registrant_priv] %>
Personal code: <%= @params[:registrant_ident] %><br>
Name: <%= @new_registrant.name %><br>
<% if @new_registrant.priv? %>
Personal code: <%= @new_registrant.ident %><br>
<% else %>
Business Registry code: <%= @params[:registrant_ident] %><br>
Business Registry code: <%= @new_registrant.ident %><br>
<% end %>
E-mail: <%= @params[:registrant_email] %><br>
Street: <%= @params[:registrant_street] %><br>
City: <%= @params[:registrant_city] %><br>
Country: <%= @params[:registrant_country] %>
E-mail: <%= @new_registrant.email %><br>
Street: <%= @new_registrant.street %><br>
City: <%= @new_registrant.city %><br>
Country: <%= @new_registrant.country.name %>
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -1,19 +1,19 @@
Tere,
Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
Uue registreerija andmed:
Nimi: <%= @params[:new_registrant_name] %>
Nimi: <%= @new_registrant.name %>
<% if @params[:registrant_priv] %>
Isikukood: <%= @params[:registrant_ident] %>
<% if @new_registrant.priv? %>
Isikukood: <%= @new_registrant.ident %>
<% else %>
Äriregistrikood: <%= @params[:registrant_ident] %>
Äriregistrikood: <%= @new_registrant.ident %>
<% end %>
Epost: <%= @params[:registrant_email] %>
Tänav: <%= @params[:registrant_street] %>
Linn: <%= @params[:registrant_city] %>
Riik: <%= @params[:registrant_country] %>
Epost: <%= @new_registrant.email %>
Tänav: <%= @new_registrant.street %>
Linn: <%= @new_registrant.city %>
Riik: <%= @new_registrant.country.name %>
Lugupidamisega
Eesti Interneti SA
@ -22,20 +22,20 @@ Eesti Interneti SA
Hi,
Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
New registrant:
Name: <%= @params[:new_registrant_name] %>
Name: <%= @new_registrant.name %>
<% if @params[:registrant_priv] %>
Personal code: <%= @params[:registrant_ident] %>
<% if @new_registrant.priv? %>
Personal code: <%= @new_registrant.ident %>
<% else %>
Business Registry code: <%= @params[:registrant_ident] %>
Business Registry code: <%= @new_registrant.ident %>
<% end %>
E-mail: <%= @params[:registrant_email] %>
Street: <%= @params[:registrant_street] %>
City: <%= @params[:registrant_city] %>
Country: <%= @params[:registrant_country] %>
E-mail: <%= @new_registrant.email %>
Street: <%= @new_registrant.street %>
City: <%= @new_registrant.city %>
Country: <%= @new_registrant.country.name %>
Best Regards,
Estonian Internet Foundation

View file

@ -827,16 +827,20 @@ en:
domain_registrant_change_confirmed_body: 'You have successfully submitted domain registrant change confirmation. You will receive email confirmation.'
registrant_domain_verification_confirmed: 'Domain registrant change has successfully received.'
registrant_domain_verification_confirmed_failed: 'Something went wrong.'
domain_registrant_change_rejected_title: 'Domain registrant change has been rejected'
domain_registrant_change_rejected_body: 'You have rejected domain registrant change.'
domain_registrant_change_rejected_title: 'Domain registrant change rejection has been received'
domain_registrant_change_rejected_body: 'You have rejected domain registrant change. You will receive confirmation by email.'
registrant_domain_verification_rejected: 'Domain registrant change has been rejected successfully.'
registrant_domain_verification_rejected_failed: 'Something went wrong.'
domain_delete_title: 'Please confirm or reject domain deletation'
domain_delete_title: 'Please confirm or reject domain deletion'
domain_delete_body: 'There is a request to delete a domain. Before doing it we need your confirmation.'
registrant_domain_delete_confirmed: 'Setting the domain up for deletion...'
registrant_domain_delete_confirmed_failed: 'Something went wrong.'
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.'
registrant_domain_delete_rejected: 'Rejecting the domain deletion...'
registrant_domain_delete_rejected_failed: 'Something went wrong.'
domain_delete_rejected_title: 'Domain deletion rejection has been received successfully'
domain_delete_rejected_body: 'You have rejected pending domain deletion. You will receive confirmation by email.'
no_permission: 'No permission'
access_denied: 'Access denied'
common_name: 'Common name'

View file

@ -0,0 +1,6 @@
class AddTimeIndexingToEppLog < ActiveRecord::Migration
def change
ApiLog::EppLog.connection.execute( "CREATE INDEX CONCURRENTLY epp_logs_created_at ON epp_logs USING btree (extract(epoch from created_at));")
ApiLog::ReppLog.connection.execute("CREATE INDEX CONCURRENTLY repp_logs_created_at ON repp_logs USING btree (extract(epoch from created_at));")
end
end

View file

@ -153,7 +153,7 @@ describe DomainMailer do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@mail = DomainMailer.registrant_updated_notification_for_new_registrant(@domain.id, deliver_emails)
@mail = DomainMailer.registrant_updated_notification_for_new_registrant(@domain.id, @registrant.id, @registrant.id, deliver_emails)
end
it 'should render email subject' do
@ -178,7 +178,7 @@ describe DomainMailer do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@mail = DomainMailer.registrant_updated_notification_for_old_registrant(@domain.id, deliver_emails)
@mail = DomainMailer.registrant_updated_notification_for_old_registrant(@domain.id, @registrant.id, @registrant.id, deliver_emails)
end
it 'should render email subject' do