mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.1 KiB
29 lines
1.1 KiB
# frozen_string_literal: true
|
|
|
|
class SubmissionsExportController < ApplicationController
|
|
load_and_authorize_resource :template
|
|
load_and_authorize_resource :submission, through: :template, parent: false, only: :index
|
|
|
|
def index
|
|
submissions = @submissions.active
|
|
.preload(submitters: { documents_attachments: :blob,
|
|
attachments_attachments: :blob })
|
|
.order(id: :asc)
|
|
|
|
submissions = Submissions.search(current_user, submissions, params[:q], search_values: true)
|
|
submissions = Submissions::Filter.call(submissions, current_user, params)
|
|
|
|
expires_at = Accounts.link_expires_at(current_account)
|
|
|
|
if params[:format] == 'csv'
|
|
send_data Submissions::GenerateExportFiles.call(submissions, format: params[:format], expires_at:),
|
|
filename: "#{@template.name}.csv"
|
|
elsif params[:format] == 'xlsx'
|
|
send_data Submissions::GenerateExportFiles.call(submissions, format: params[:format], expires_at:),
|
|
filename: "#{@template.name}.xlsx"
|
|
end
|
|
end
|
|
|
|
def new; end
|
|
end
|