mirror of
https://github.com/internetee/registry.git
synced 2025-05-20 19:29:39 +02:00
Added registrant successful email confirmation #2557
This commit is contained in:
parent
9f2d87606d
commit
8102b8f1a2
11 changed files with 169 additions and 18 deletions
|
@ -3,7 +3,7 @@ class DomainMailer < ApplicationMailer
|
||||||
@domain = domain
|
@domain = domain
|
||||||
return if Rails.env.production? ? false : !TEST_EMAILS.include?(@domain.registrant_email)
|
return if Rails.env.production? ? false : !TEST_EMAILS.include?(@domain.registrant_email)
|
||||||
|
|
||||||
# turn on delivery on specific request only, thus rake tasks does not deliver anything
|
# turn on delivery on specific EPP request only, thus rake tasks does not deliver anything
|
||||||
return if @domain.deliver_emails != true
|
return if @domain.deliver_emails != true
|
||||||
|
|
||||||
if @domain.registrant_verification_token.blank?
|
if @domain.registrant_verification_token.blank?
|
||||||
|
@ -25,11 +25,22 @@ class DomainMailer < ApplicationMailer
|
||||||
subject: "#{I18n.t(:domain_registrant_pending_updated_subject, name: @domain.name)} [#{@domain.name}]")
|
subject: "#{I18n.t(:domain_registrant_pending_updated_subject, name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def registrant_updated(domain)
|
||||||
|
@domain = domain
|
||||||
|
return if Rails.env.production? ? false : !TEST_EMAILS.include?(@domain.registrant_email)
|
||||||
|
|
||||||
|
# turn on delivery on specific EPP request only, thus rake tasks does not deliver anything
|
||||||
|
return if @domain.deliver_emails != true
|
||||||
|
|
||||||
|
mail(to: @domain.registrant_email,
|
||||||
|
subject: "#{I18n.t(:domain_registrant_updated, name: @domain.name)} [#{@domain.name}]")
|
||||||
|
end
|
||||||
|
|
||||||
def pending_deleted(domain)
|
def pending_deleted(domain)
|
||||||
@domain = domain
|
@domain = domain
|
||||||
return if Rails.env.production? ? false : !TEST_EMAILS.include?(@domain.registrant_email)
|
return if Rails.env.production? ? false : !TEST_EMAILS.include?(@domain.registrant_email)
|
||||||
|
|
||||||
# turn on delivery on specific request only, thus rake tasks does not deliver anything
|
# turn on delivery on specific EPP request only, thus rake tasks does not deliver anything
|
||||||
return if @domain.deliver_emails != true
|
return if @domain.deliver_emails != true
|
||||||
|
|
||||||
if @domain.registrant_verification_token.blank?
|
if @domain.registrant_verification_token.blank?
|
||||||
|
|
|
@ -186,13 +186,10 @@ class Domain < ActiveRecord::Base
|
||||||
def start_expire_period
|
def start_expire_period
|
||||||
STDOUT << "#{Time.zone.now.utc} - Expiring domains\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Expiring domains\n" unless Rails.env.test?
|
||||||
|
|
||||||
d = Domain.where('valid_to <= ?', Time.zone.now)
|
domains = Domain.where('valid_to <= ?', Time.zone.now)
|
||||||
d.each do |x|
|
domains.each do |domain|
|
||||||
next unless x.expirable?
|
next unless domain.expirable?
|
||||||
x.statuses << DomainStatus::EXPIRED
|
domain.set_expired!
|
||||||
# TODO: This should be managed by automatic_statuses
|
|
||||||
x.statuses.delete(DomainStatus::OK)
|
|
||||||
x.save(validate: false)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
STDOUT << "#{Time.zone.now.utc} - Successfully expired #{d.count} domains\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Successfully expired #{d.count} domains\n" unless Rails.env.test?
|
||||||
|
@ -517,6 +514,19 @@ class Domain < ActiveRecord::Base
|
||||||
save(validate: false)
|
save(validate: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_expired
|
||||||
|
# TODO: currently valid_to attribute update logic is open
|
||||||
|
# self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
|
||||||
|
self.outzone_at = Time.zone.now + Setting.expire_warning_period.days
|
||||||
|
self.delete_at = Time.zone.now + Setting.redemption_grace_period.days
|
||||||
|
statuses << DomainStatus::EXPIRED
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_expired!
|
||||||
|
set_expired
|
||||||
|
save(validate: false)
|
||||||
|
end
|
||||||
|
|
||||||
def manage_automatic_statuses
|
def manage_automatic_statuses
|
||||||
# domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable?
|
# domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable?
|
||||||
if statuses.empty? && valid?
|
if statuses.empty? && valid?
|
||||||
|
|
|
@ -398,7 +398,11 @@ class Epp::Domain < Domain
|
||||||
frame = Nokogiri::XML(pending_json['frame'])
|
frame = Nokogiri::XML(pending_json['frame'])
|
||||||
statuses.delete(DomainStatus::PENDING_UPDATE)
|
statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||||
|
|
||||||
clean_pendings! if update(frame, user, false)
|
if update(frame, user, false)
|
||||||
|
clean_pendings!
|
||||||
|
self.deliver_emails = true # turn on email delivery for epp
|
||||||
|
DomainMailer.registrant_updated(self).deliver_now
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_pending_delete!
|
def apply_pending_delete!
|
||||||
|
@ -429,7 +433,7 @@ class Epp::Domain < Domain
|
||||||
manage_automatic_statuses
|
manage_automatic_statuses
|
||||||
true # aka 1001 pending_delete
|
true # aka 1001 pending_delete
|
||||||
else
|
else
|
||||||
destroy
|
set_expired!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veen
|
||||||
<br><br>
|
<br><br>
|
||||||
Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
|
Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
|
||||||
<br><br>
|
<br><br>
|
||||||
Taotlus on aktiivne <48> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka.<br>
|
Taotlus on aktiivne 48 tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka.<br>
|
||||||
<%= link_to @verification_url, @verification_url %>
|
<%= link_to @verification_url, @verification_url %>
|
||||||
<br><br>
|
<br><br>
|
||||||
Lugupidamisega<br>
|
Lugupidamisega<br>
|
||||||
|
|
39
app/views/domain_mailer/registrant_updated.html.erb
Normal file
39
app/views/domain_mailer/registrant_updated.html.erb
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
Tere,
|
||||||
|
<br><br>
|
||||||
|
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
|
||||||
|
<br><br>
|
||||||
|
Uued registreerija andmed:<br>
|
||||||
|
Nimi: <%= @domain.registrant_name %><br>
|
||||||
|
<% if @domain.registrant.priv? %>
|
||||||
|
Isikukood: <%= @domain.registrant_ident %><br>
|
||||||
|
<% else %>
|
||||||
|
Äriregistrikood: <%= @domain.registrant_ident %><br>
|
||||||
|
<% end %>
|
||||||
|
Epost: <%= @domain.registrant_email %><br>
|
||||||
|
Tänav: <%= @domain.registrant_street %><br>
|
||||||
|
Linn: <%= @domain.registrant_city %><br>
|
||||||
|
Riik: <%= @domain.registrant_country %>
|
||||||
|
<br><br>
|
||||||
|
Lugupidamisega<br>
|
||||||
|
Eesti Interneti SA
|
||||||
|
<br><br>
|
||||||
|
<hr>
|
||||||
|
<br><br>
|
||||||
|
Hi,
|
||||||
|
<br><br>
|
||||||
|
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: <%= @domain.registrant_name %><br>
|
||||||
|
<% if @domain.registrant.priv? %>
|
||||||
|
Personal code: <%= @domain.registrant_ident %><br>
|
||||||
|
<% else %>
|
||||||
|
Business Registry code: <%= @domain.registrant_ident %><br>
|
||||||
|
<% end %>
|
||||||
|
E-mail: <%= @domain.registrant_email %><br>
|
||||||
|
Street: <%= @domain.registrant_street %><br>
|
||||||
|
City: <%= @domain.registrant_city %><br>
|
||||||
|
Country: <%= @domain.registrant_country %>
|
||||||
|
<br><br>
|
||||||
|
Best Regards,<br>
|
||||||
|
Estonian Internet Foundation
|
39
app/views/domain_mailer/registrant_updated.text.erb
Normal file
39
app/views/domain_mailer/registrant_updated.text.erb
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
Tere,
|
||||||
|
|
||||||
|
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
|
||||||
|
|
||||||
|
Uued registreerija andmed:
|
||||||
|
Nimi: <%= @domain.registrant_name %>
|
||||||
|
<% if @domain.registrant.priv? %>
|
||||||
|
Isikukood: <%= @domain.registrant_ident %>
|
||||||
|
<% else %>
|
||||||
|
Äriregistrikood: <%= @domain.registrant_ident %>
|
||||||
|
<% end %>
|
||||||
|
Epost: <%= @domain.registrant_email %>
|
||||||
|
Tänav: <%= @domain.registrant_street %>
|
||||||
|
Linn: <%= @domain.registrant_city %>
|
||||||
|
Riik: <%= @domain.registrant_country %>
|
||||||
|
|
||||||
|
Lugupidamisega
|
||||||
|
Eesti Interneti SA
|
||||||
|
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
|
Hi,
|
||||||
|
|
||||||
|
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
|
||||||
|
|
||||||
|
New registrant:
|
||||||
|
Name: <%= @domain.registrant_name %>
|
||||||
|
<% if @domain.registrant.priv? %>
|
||||||
|
Personal code: <%= @domain.registrant_ident %>
|
||||||
|
<% else %>
|
||||||
|
Business Registry code: <%= @domain.registrant_ident %>
|
||||||
|
<% end %>
|
||||||
|
E-mail: <%= @domain.registrant_email %>
|
||||||
|
Street: <%= @domain.registrant_street %>
|
||||||
|
City: <%= @domain.registrant_city %>
|
||||||
|
Country: <%= @domain.registrant_country %>
|
||||||
|
|
||||||
|
Best Regards,
|
||||||
|
Estonian Internet Foundation
|
|
@ -869,3 +869,4 @@ en:
|
||||||
reserved_pw: 'Reserved pw'
|
reserved_pw: 'Reserved pw'
|
||||||
no_transfers_found: 'No transfers found'
|
no_transfers_found: 'No transfers found'
|
||||||
parameter_value_range_error: 'Parameter value range error: %{key}'
|
parameter_value_range_error: 'Parameter value range error: %{key}'
|
||||||
|
domain_registrant_updated: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'
|
||||||
|
|
|
@ -199,6 +199,7 @@ ActiveRecord::Schema.define(version: 20150713113436) do
|
||||||
t.string "country_code"
|
t.string "country_code"
|
||||||
t.string "state"
|
t.string "state"
|
||||||
t.integer "legacy_id"
|
t.integer "legacy_id"
|
||||||
|
t.string "statuses", array: true
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "contacts", ["code"], name: "index_contacts_on_code", using: :btree
|
add_index "contacts", ["code"], name: "index_contacts_on_code", using: :btree
|
||||||
|
@ -1029,7 +1030,7 @@ ActiveRecord::Schema.define(version: 20150713113436) do
|
||||||
t.text "crt"
|
t.text "crt"
|
||||||
t.string "type"
|
t.string "type"
|
||||||
t.string "registrant_ident"
|
t.string "registrant_ident"
|
||||||
t.string "encrypted_password", default: "", null: false
|
t.string "encrypted_password", default: ""
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.integer "failed_attempts", default: 0, null: false
|
t.integer "failed_attempts", default: 0, null: false
|
||||||
t.datetime "locked_at"
|
t.datetime "locked_at"
|
||||||
|
|
|
@ -631,7 +631,8 @@ CREATE TABLE contacts (
|
||||||
zip character varying,
|
zip character varying,
|
||||||
country_code character varying,
|
country_code character varying,
|
||||||
state character varying,
|
state character varying,
|
||||||
legacy_id integer
|
legacy_id integer,
|
||||||
|
statuses character varying[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -2383,7 +2384,7 @@ CREATE TABLE pricelists (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
"desc" character varying,
|
"desc" character varying,
|
||||||
category character varying,
|
category character varying,
|
||||||
price_cents numeric(10,2) DEFAULT 0.0 NOT NULL,
|
price_cents numeric(10,2) DEFAULT 0 NOT NULL,
|
||||||
price_currency character varying DEFAULT 'EUR'::character varying NOT NULL,
|
price_currency character varying DEFAULT 'EUR'::character varying NOT NULL,
|
||||||
valid_from timestamp without time zone,
|
valid_from timestamp without time zone,
|
||||||
valid_to timestamp without time zone,
|
valid_to timestamp without time zone,
|
||||||
|
@ -2647,7 +2648,7 @@ CREATE TABLE users (
|
||||||
crt text,
|
crt text,
|
||||||
type character varying,
|
type character varying,
|
||||||
registrant_ident character varying,
|
registrant_ident character varying,
|
||||||
encrypted_password character varying DEFAULT ''::character varying NOT NULL,
|
encrypted_password character varying DEFAULT ''::character varying,
|
||||||
remember_created_at timestamp without time zone,
|
remember_created_at timestamp without time zone,
|
||||||
failed_attempts integer DEFAULT 0 NOT NULL,
|
failed_attempts integer DEFAULT 0 NOT NULL,
|
||||||
locked_at timestamp without time zone
|
locked_at timestamp without time zone
|
||||||
|
@ -4740,6 +4741,8 @@ INSERT INTO schema_migrations (version) VALUES ('20150227092508');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150227113121');
|
INSERT INTO schema_migrations (version) VALUES ('20150227113121');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150302130224');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150302161712');
|
INSERT INTO schema_migrations (version) VALUES ('20150302161712');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150303130729');
|
INSERT INTO schema_migrations (version) VALUES ('20150303130729');
|
||||||
|
@ -4798,6 +4801,8 @@ INSERT INTO schema_migrations (version) VALUES ('20150417082723');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150421134820');
|
INSERT INTO schema_migrations (version) VALUES ('20150421134820');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150422090645');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150422092514');
|
INSERT INTO schema_migrations (version) VALUES ('20150422092514');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150422132631');
|
INSERT INTO schema_migrations (version) VALUES ('20150422132631');
|
||||||
|
@ -4842,6 +4847,8 @@ INSERT INTO schema_migrations (version) VALUES ('20150519115050');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150519140853');
|
INSERT INTO schema_migrations (version) VALUES ('20150519140853');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150519142542');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150519144118');
|
INSERT INTO schema_migrations (version) VALUES ('20150519144118');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150520163237');
|
INSERT INTO schema_migrations (version) VALUES ('20150520163237');
|
||||||
|
@ -4858,6 +4865,8 @@ INSERT INTO schema_migrations (version) VALUES ('20150601083516');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150601083800');
|
INSERT INTO schema_migrations (version) VALUES ('20150601083800');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150603141054');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150603141549');
|
INSERT INTO schema_migrations (version) VALUES ('20150603141549');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150603211318');
|
INSERT INTO schema_migrations (version) VALUES ('20150603211318');
|
||||||
|
@ -4882,12 +4891,14 @@ INSERT INTO schema_migrations (version) VALUES ('20150612125720');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150701074344');
|
INSERT INTO schema_migrations (version) VALUES ('20150701074344');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150703084206');
|
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150703084632');
|
INSERT INTO schema_migrations (version) VALUES ('20150703084632');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150706091724');
|
INSERT INTO schema_migrations (version) VALUES ('20150706091724');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150707103241');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150707103801');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150707104937');
|
INSERT INTO schema_migrations (version) VALUES ('20150707104937');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150707154543');
|
INSERT INTO schema_migrations (version) VALUES ('20150707154543');
|
||||||
|
|
|
@ -112,4 +112,29 @@ describe DomainMailer do
|
||||||
@mail.body.encoded.should =~ %r{registrant\/domain_delete_con} # somehowe delete_confirms not matching
|
@mail.body.encoded.should =~ %r{registrant\/domain_delete_con} # somehowe delete_confirms not matching
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'registrant successfully changed confirmation' do
|
||||||
|
before :all do
|
||||||
|
@registrant = Fabricate(:registrant, email: 'test@example.com')
|
||||||
|
@domain = Fabricate(:domain, registrant: @registrant)
|
||||||
|
@domain.deliver_emails = true
|
||||||
|
@mail = DomainMailer.registrant_updated(@domain)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should render email subject' do
|
||||||
|
@mail.subject.should =~ /registreerija vahetus teostatud/
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have sender email' do
|
||||||
|
@mail.from.should == ["noreply@internet.ee"]
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should send to registrant email' do
|
||||||
|
@mail.to.should == ["test@example.com"]
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should render body' do
|
||||||
|
@mail.body.encoded.should =~ /registreerija vahetuse taotlus on kinnitatud/
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -182,6 +182,16 @@ describe Domain do
|
||||||
@domain.force_delete_at.should be_nil
|
@domain.force_delete_at.should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should set expired status and update outzone_at and delete_at' do
|
||||||
|
domain = Fabricate(:domain)
|
||||||
|
domain.statuses.should == ['ok']
|
||||||
|
domain.set_expired
|
||||||
|
domain.changes.keys.should == ['statuses', 'outzone_at', 'delete_at']
|
||||||
|
domain.save
|
||||||
|
|
||||||
|
domain.statuses.should == ['expired']
|
||||||
|
end
|
||||||
|
|
||||||
it 'should know its create price' do
|
it 'should know its create price' do
|
||||||
Fabricate(:pricelist, {
|
Fabricate(:pricelist, {
|
||||||
category: 'ee',
|
category: 'ee',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue