Merge pull request #2396 from internetee/2391-domain-pdf

Admin: download pdf with domain data on show
This commit is contained in:
Timo Võhmar 2022-09-29 15:32:30 +03:00 committed by GitHub
commit c488085cb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 276 additions and 3 deletions

View file

@ -2,7 +2,7 @@ module Admin
class DomainsController < BaseController
DEFAULT_VERSIONS_PER_PAGE = 10
before_action :set_domain, only: %i[show edit update keep]
before_action :set_domain, only: %i[show edit update download keep]
authorize_resource
# rubocop:disable Metrics/MethodLength
@ -65,6 +65,11 @@ module Admin
.per(DEFAULT_VERSIONS_PER_PAGE)
end
def download
filename = "#{@domain.name}.pdf"
send_data @domain.as_pdf, filename: filename
end
def keep
@domain.keep
redirect_to edit_admin_domain_url(@domain), notice: t('.kept')