2020-05-31 22:38:19 +02:00
|
|
|
class ContractTemplates::QrCodesController < ApplicationController
|
|
|
|
|
before_action :set_contract_template
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
|
send_file qr_code.to_png, download_attributes
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def contract_templates
|
|
|
|
|
policy_scope(ContractTemplate)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def set_contract_template
|
|
|
|
|
@contract_template = contract_templates.find(params[:contract_template_id])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def qr_code
|
2020-07-20 13:28:40 +00:00
|
|
|
if params[:multi_sign_ids].present?
|
|
|
|
|
contract_templates_group = authorize contract_templates.where(id: params[:multi_sign_ids]).order_by_recent
|
|
|
|
|
authorize QrCode.build_from_multiple_contract_templates(contract_templates_group, @contract_template.project)
|
|
|
|
|
else
|
|
|
|
|
authorize QrCode.build_from_contract_template(@contract_template)
|
|
|
|
|
end
|
2020-05-31 22:38:19 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def download_attributes
|
|
|
|
|
{
|
|
|
|
|
filename: qr_code.filename,
|
|
|
|
|
type: "image/png",
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|