-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Remove `Que::Mailer` (#895) - Extract controller - Convert HAML to ERB - Add mailer preview - Improve UI - Add tests
- Loading branch information
Artur Beljajev
committed
Apr 10, 2019
1 parent
c192cc0
commit 60cabbb
Showing
25 changed files
with
237 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Admin | ||
module Invoices | ||
class DeliveryController < BaseController | ||
before_action :find_invoice | ||
|
||
def new | ||
authorize! :manage, @invoice | ||
@recipient = @invoice.buyer.billing_email | ||
end | ||
|
||
def create | ||
authorize! :manage, @invoice | ||
|
||
InvoiceMailer.invoice_email(invoice: @invoice, recipient: params[:recipient]).deliver_now | ||
|
||
redirect_to admin_invoice_path(@invoice), notice: t('.delivered') | ||
end | ||
|
||
private | ||
|
||
def find_invoice | ||
@invoice = Invoice.find(params[:invoice_id]) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Registrar | ||
module Invoices | ||
class DeliveryController < BaseController | ||
before_action :find_invoice | ||
|
||
def new | ||
authorize! :manage, @invoice | ||
@recipient = @invoice.buyer.billing_email | ||
end | ||
|
||
def create | ||
authorize! :manage, @invoice | ||
|
||
InvoiceMailer.invoice_email(invoice: @invoice, recipient: params[:recipient]).deliver_now | ||
|
||
redirect_to registrar_invoice_path(@invoice), notice: t('.delivered') | ||
end | ||
|
||
private | ||
|
||
def find_invoice | ||
@invoice = Invoice.find(params[:invoice_id]) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
class InvoiceMailer < ApplicationMailer | ||
include Que::Mailer | ||
def invoice_email(invoice:, recipient:) | ||
@invoice = invoice | ||
|
||
def invoice_email(invoice_id, html, billing_email) | ||
@invoice = Invoice.find_by(id: invoice_id) | ||
billing_email ||= @invoice.billing_email | ||
return unless @invoice | ||
return if whitelist_blocked?(billing_email) | ||
|
||
kit = PDFKit.new(html) | ||
pdf = kit.to_pdf | ||
invoice = @invoice | ||
|
||
attachments[invoice.pdf_name] = pdf | ||
mail(to: format(billing_email), subject: invoice) | ||
subject = default_i18n_subject(invoice_number: invoice.number) | ||
attachments[invoice.pdf_name] = invoice.invoice_pdf | ||
mail(to: recipient, subject: subject) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<ol class="breadcrumb"> | ||
<li><%= link_to t('admin.invoices.index.header'), admin_invoices_path %></li> | ||
<li><%= link_to @invoice, admin_invoice_path(@invoice) %></li> | ||
</ol> | ||
|
||
<div class="page-header"> | ||
<h1><%= t '.header' %></h1> | ||
</div> | ||
|
||
<%= form_tag(admin_invoice_delivery_path(@invoice)) do %> | ||
<div class="row"> | ||
<div class="col-md-4 col-md-offset-4"> | ||
<div class="form-group"> | ||
<%= label_tag :recipient %> | ||
<%= email_field_tag :recipient, @recipient, autofocus: true, class: 'form-control' %> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-12 text-right"> | ||
<%= submit_tag t('.submit_btn'), class: 'btn btn-warning' %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<ol class="breadcrumb"> | ||
<li><%= link_to t('registrar.invoices.index.header'), registrar_invoices_path %></li> | ||
<li><%= link_to @invoice, registrar_invoice_path(@invoice) %></li> | ||
</ol> | ||
|
||
<div class="page-header"> | ||
<h1><%= t '.header' %></h1> | ||
</div> | ||
|
||
<%= form_tag(registrar_invoice_delivery_path(@invoice)) do %> | ||
<div class="row"> | ||
<div class="col-md-4 col-md-offset-4"> | ||
<div class="form-group"> | ||
<%= label_tag :recipient %> | ||
<%= email_field_tag :recipient, @recipient, autofocus: true, class: 'form-control' %> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-12 text-right"> | ||
<%= submit_tag t('.submit_btn'), class: 'btn btn-warning' %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
en: | ||
admin: | ||
invoices: | ||
index: | ||
header: Invoices | ||
|
||
show: | ||
deliver_btn: Send | ||
|
||
cancel: | ||
cancelled: Invoice has been cancelled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
en: | ||
admin: | ||
invoices: | ||
delivery: | ||
new: | ||
header: Send invoice | ||
submit_btn: Send | ||
|
||
create: | ||
delivered: Invoice has been sent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
en: | ||
invoice_mailer: | ||
invoice_email: | ||
subject: Invoice no. %{invoice_number} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
en: | ||
registrar: | ||
invoices: | ||
delivery: | ||
new: | ||
header: Send invoice | ||
submit_btn: Send | ||
|
||
create: | ||
delivered: Invoice has been sent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ one: | |
vat_rate: 0.1 | ||
total: 16.50 | ||
reference_no: 13 | ||
number: 1 | ||
|
||
for_payments_test: | ||
number: 1 | ||
|
Oops, something went wrong.