Refactor domain mailer views

#180
This commit is contained in:
Artur Beljajev 2016-11-14 01:35:47 +02:00
parent a6de3761c5
commit 2c3dbc6e32
31 changed files with 361 additions and 153 deletions

View file

@ -16,7 +16,9 @@ class DomainUpdateConfirmJob < Que::Job
domain.clean_pendings!
raise_errors!(domain)
when RegistrantVerification::REJECTED
domain.send_mail :pending_update_rejected_notification_for_new_registrant
RegistrantChangeMailer.rejected(domain: domain, registrar: domain.registrar, registrant: domain.registrant)
.deliver
domain.poll_message!(:poll_pending_update_rejected_by_registrant)
domain.clean_pendings_lowlevel
end

View file

View file

@ -1,36 +1,34 @@
class RegistrantChangeMailer < ApplicationMailer
include Que::Mailer
def confirmation(domain:, registrant:)
def confirm(domain:, registrar:, current_registrant:, new_registrant:)
@domain = DomainPresenter.new(domain: domain, view: view_context)
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
@verification_url = confirm_url(domain)
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
@new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context)
@confirm_url = confirm_url(domain)
subject = default_i18n_subject(domain_name: domain.name)
mail(to: registrant.email, subject: subject)
mail(to: current_registrant.email, subject: subject)
end
def pending_update_notification_for_new_registrant(params)
compose_from(params)
def notice(domain:, registrar:, current_registrant:, new_registrant:)
@domain = DomainPresenter.new(domain: domain, view: view_context)
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
@current_registrant = RegistrantPresenter.new(registrant: current_registrant, view: view_context)
@new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context)
@confirm_url = confirm_url(domain)
subject = default_i18n_subject(domain_name: domain.name)
mail(to: new_registrant.email, subject: subject)
end
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)
def rejected(domain:, registrar:, registrant:)
@domain = DomainPresenter.new(domain: domain, view: view_context)
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
@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)
compose_from(params)
subject = default_i18n_subject(domain_name: domain.name)
mail(to: domain.new_registrant_email, subject: subject)
end
def pending_update_expired_notification_for_new_registrant(params)

View file

@ -380,12 +380,12 @@ class Domain < ActiveRecord::Base
new_registrant_name = registrant.name
current_registrant = Registrant.find(registrant_id_was)
RegistrantChangeMailer.confirmation(domain: self, current_registrant: current_registrant).deliver
RegistrantChangeMailer.confirm(domain: self, registrar: registrar, current_registrant: current_registrant,
new_registrant: registrant).deliver
RegistrantChangeMailer.notice(domain: self, registrar: registrar, current_registrant: current_registrant,
new_registrant: registrant).deliver
send_mail :pending_update_request_for_old_registrant
send_mail :pending_update_notification_for_new_registrant
reload # revert back to original
reload
self.pending_json = pending_json_cache
self.registrant_verification_token = token
@ -397,8 +397,8 @@ class Domain < ActiveRecord::Base
pending_json['new_registrant_name'] = new_registrant_name
# This pending_update! method is triggered by before_update
# Note, all before_save callbacks are excecuted before before_update,
# thus automatic statuses has already excectued by this point
# Note, all before_save callbacks are executed before before_update,
# thus automatic statuses has already executed by this point
# and we need to trigger automatic statuses manually (second time).
manage_automatic_statuses
end
@ -741,6 +741,10 @@ class Domain < ActiveRecord::Base
admin_contact_emails << registrant_email
end
def new_registrant_email
pending_json['new_registrant_email']
end
def self.to_csv
CSV.generate do |csv|
csv << column_names

View file

@ -6,30 +6,6 @@ class DomainMailModel
@params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id}
end
def pending_update_request_for_old_registrant
registrant_old
subject(:pending_update_request_for_old_registrant_subject)
confirm_update
domain_info
compose
end
def pending_update_notification_for_new_registrant
registrant # new registrant at this point
subject(:pending_update_notification_for_new_registrant_subject)
domain_info
compose
end
def pending_update_rejected_notification_for_new_registrant
registrant_pending
subject(:pending_update_rejected_notification_for_new_registrant_subject)
@params[:deliver_emails] = true # triggered from que
@params[:registrar_name] = @domain.registrar.name
compose
end
def pending_update_expired_notification_for_new_registrant
registrant_pending
subject(:pending_update_expired_notification_for_new_registrant_subject)

View file

@ -21,7 +21,7 @@ Registrikood: <b><%= @registrant.ident %></b></p>
<p>Lisak&uuml;simuste korral v&otilde;tke palun &uuml;hendust oma registripidajaga:</p>
<%= render 'mailers/domain_mailer/registrar/registrar.et.html', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<hr>
@ -42,7 +42,7 @@ Registry code: <b><%= @registrant.ident %></b></p>
<p>Should you have additional questions, please contact your registrar:</p>
<%= render 'mailers/domain_mailer/registrar/registrar.en.html', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<hr>
@ -63,7 +63,7 @@ Registry code: <b><%= @registrant.ident %></b></p>
<p>Просим обратиться к своему регистратору:</p>
<%= render 'mailers/domain_mailer/registrar/registrar.ru.html', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.ru.html', registrar: @registrar %>
<br /><br />

View file

@ -15,7 +15,7 @@ Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.nam
Lisaküsimuste korral võtke palun ühendust oma registripidajaga:
<%= render 'mailers/domain_mailer/registrar/registrar.et.text', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
@ -36,7 +36,7 @@ If the transfer has not been made in 30 days, the domain <%= @domain.name %> wil
Should you have additional questions, please contact your registrar:
<%= render 'mailers/domain_mailer/registrar/registrar.en.text', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
Уважаемое контактное лицо домена <%= @domain.name %>
@ -56,7 +56,7 @@ EIS стало известно, что юридическое лицо с ре
Просим обратиться к своему регистратору:
<%= render 'mailers/domain_mailer/registrar/registrar.ru.text', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.ru.text', registrar: @registrar %>
Lugupidamisega,

View file

@ -2,17 +2,17 @@ Tere
<br><br>
Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
<%= render 'mailers/domain_mailer/registrar/registrar.et.html', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<br><br>
Uue registreerija andmed:<br>
<%= render 'mailers/domain_mailer/registrant/registrant.et.html', registrant: @new_registrant %>
<%= render 'mailers/shared/registrant/registrant.et.html', registrant: @new_registrant %>
<br><br>
Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka.
<br><br>
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:<br>
<%= link_to @verification_url, @verification_url %>
<%= link_to @confirm_url, @confirm_url %>
<br><br>
Lugupidamisega<br>
Eesti Interneti Sihtasutus
@ -23,16 +23,16 @@ Hi,
<br><br>
Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. In case of problems please turn to your registrar:
<%= render 'mailers/domain_mailer/registrar/registrar.en.html', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<br><br>
New registrant:<br>
<%= render 'mailers/domain_mailer/registrant/registrant.en.html', registrant: @new_registrant %>
<%= render 'mailers/shared/registrant/registrant.en.html', registrant: @new_registrant %>
<br><br>
The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before.
<br><br>
To confirm the update please visit this website, once again review the data and press approve:<br>
<%= link_to @verification_url, @verification_url %>
<%= link_to @confirm_url, @confirm_url %>
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -2,14 +2,14 @@ Tere
Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
<%= render 'mailers/domain_mailer/registrar/registrar.et.text', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
Uue registreerija andmed:
<%= render 'mailers/domain_mailer/registrant/registrant.et.text', registrant: @new_registrant %>
<%= render 'mailers/shared/registrant/registrant.et.text', registrant: @new_registrant %>
Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka.
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
<%= @verification_url %>
<%= @confirm_url %>
Lugupidamisega
Eesti Interneti Sihtasutus
@ -20,14 +20,14 @@ Hi,
Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. In case of problems please turn to your registrar:
<%= render 'mailers/domain_mailer/registrar/registrar.en.text', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
New registrant:
<%= render 'mailers/domain_mailer/registrant/registrant.en.text', registrant: @new_registrant %>
<%= render 'mailers/shared/registrant/registrant.en.text', registrant: @new_registrant %>
The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before.
To confirm the update please visit this website, once again review the data and press approve:
<%= @verification_url %>
<%= @confirm_url %>
Best Regards,
Estonian Internet Foundation

View file

@ -4,11 +4,11 @@ Registripidaja <%= @registrar.name %> vahendusel on algatatud <%= @domain.name %
<br><br>
Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
<%= render 'registrar.et.html', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<br><br>
Uue registreerija andmed:<br>
<%= render 'registrant.et.html', registrant: @new_registrant %>
<%= render 'mailers/shared/registrant/registrant.et.html', registrant: @new_registrant %>
<br><br>
Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @current_registrant.name %> omanikuvahetuse tähtaegselt kinnitab.
<br><br>
@ -25,11 +25,11 @@ Registrant change process for the domain <%= @domain.name %> has been started.
<br><br>
Please verify the details of the following change request. In case of problems contact your registrar:
<%= render 'registrar.en.html', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<br><br>
New registrant:<br>
<%= render 'registrant.en.html', registrant: @new_registrant %>
<%= render 'mailers/shared/registrant/registrant.en.html', registrant: @new_registrant %>
<br><br>
The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it.
<br><br>

View file

@ -4,10 +4,10 @@ Registripidaja <%= @registrar.name %> vahendusel on algatatud <%= @domain.name %
Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
<%= render 'registrar.et.text', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
Uue registreerija andmed:
<%= render 'registrant.et.text', registrant: @new_registrant %>
<%= render 'mailers/shared/registrant/registrant.et.text', registrant: @new_registrant %>
Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @current_registrant.name %> omanikuvahetuse tähtaegselt kinnitab.
@ -24,10 +24,10 @@ Registrant change process for the domain <%= @domain.name %> has been started.
Please verify the details of the following change request. In case of problems contact your registrar:
<%= render 'registrar.en.text', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
New registrant:
<%= render 'registrant.en.text', registrant: @new_registrant %>
<%= render 'mailers/shared/registrant/registrant.en.text', registrant: @new_registrant %>
The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it.

View file

@ -1,23 +0,0 @@
Tere
Domeeni <%= @domain.name %> registreerija <%= @current_registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
Küsimuste korral võtke palun ühendust oma registripidajaga:
<%= render 'registrar.et.text', registrar: @registrar %>
Lugupidamisega
Eesti Interneti Sihtasutus
--------------------------------------
Hi,
Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @current_registrant.name %>.
Please contact your registrar if you have any questions:
<%= render 'registrar.en.text', registrar: @registrar %>
Best Regards,
Estonian Internet Foundation

View file

@ -1,10 +1,10 @@
Tere
<br><br>
Domeeni <%= @domain.name %> registreerija <%= @current_registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
<br><br>
Küsimuste korral võtke palun ühendust oma registripidajaga:
<%= render 'registrar.et.html', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<br><br>
Lugupidamisega<br>
@ -14,11 +14,11 @@ Eesti Interneti Sihtasutus
<br><br>
Hi,
<br><br>
Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @current_registrant.name %>.
Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @registrant.name %>.
<br><br>
Please contact your registrar if you have any questions:
<%= render 'registrar.en.html', registrar: @registrar %>
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<br><br>
Best Regards,<br>

View file

@ -0,0 +1,23 @@
Tere
Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
Küsimuste korral võtke palun ühendust oma registripidajaga:
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
Lugupidamisega
Eesti Interneti Sihtasutus
--------------------------------------
Hi,
Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @registrant.name %>.
Please contact your registrar if you have any questions:
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
Best Regards,
Estonian Internet Foundation