mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Add ability to download invoice in admin #2566
This commit is contained in:
parent
bfe9086ec0
commit
bfd3e07981
3 changed files with 14 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
class Admin::InvoicesController < AdminController
|
class Admin::InvoicesController < AdminController
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
|
before_action :set_invoice, only: [:forward, :download_pdf]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@deposit = Deposit.new
|
@deposit = Deposit.new
|
||||||
end
|
end
|
||||||
|
@ -39,9 +41,18 @@ class Admin::InvoicesController < AdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def download_pdf
|
||||||
|
pdf = @invoice.pdf(render_to_string('registrar/invoices/pdf', layout: false))
|
||||||
|
send_data pdf, filename: @invoice.pdf_name
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def deposit_params
|
def deposit_params
|
||||||
params.require(:deposit).permit(:amount, :description, :registrar_id)
|
params.require(:deposit).permit(:amount, :description, :registrar_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_invoice
|
||||||
|
@invoice = Invoice.find(params[:invoice_id])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
- if !@invoice.cancelled? && !@invoice.binded?
|
- if !@invoice.cancelled? && !@invoice.binded?
|
||||||
= link_to(t(:cancel), cancel_admin_invoice_path(@invoice), method: :patch, class: 'btn btn-warning')
|
= link_to(t(:cancel), cancel_admin_invoice_path(@invoice), method: :patch, class: 'btn btn-warning')
|
||||||
= link_to(t(:back), admin_invoices_path, class: 'btn btn-default')
|
= link_to(t(:back), admin_invoices_path, class: 'btn btn-default')
|
||||||
|
= link_to(t(:download), admin_invoice_download_pdf_path(@invoice), class: 'btn btn-default')
|
||||||
%hr
|
%hr
|
||||||
= render 'shared/full_errors', object: @invoice
|
= render 'shared/full_errors', object: @invoice
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,9 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :invoices do
|
resources :invoices do
|
||||||
|
get 'download_pdf'
|
||||||
patch 'cancel', on: :member
|
patch 'cancel', on: :member
|
||||||
|
match 'forward', via: [:post, :get]
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :domains do
|
resources :domains do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue