Report generation. Download csv

This commit is contained in:
German Galia
2019-06-12 10:17:31 +02:00
parent 139b2720d8
commit 9d1ca3bfd4
63 changed files with 1528 additions and 40 deletions

View File

@@ -1,6 +1,7 @@
class Admin::Legislation::ProcessesController < Admin::Legislation::BaseController
include Translatable
include ImageAttributes
include DownloadSettingsHelper
has_filters %w[active all], only: :index
@@ -9,6 +10,13 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
def index
@processes = ::Legislation::Process.send(@current_filter).order(start_date: :desc)
.page(params[:page])
respond_to do |format|
format.html
format.csv {send_data to_csv(process_for_download, Legislation::Process),
type: "text/csv",
disposition: "attachment",
filename: "legislation_processes.csv" }
end
end
def create
@@ -43,6 +51,10 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
private
def process_for_download
::Legislation::Process.send(@current_filter).order(start_date: :desc)
end
def process_params
params.require(:legislation_process).permit(allowed_params)
end