Remove new CSV report generation
The new CSV report was more configurable and could work on proposals,
processes and comments. However, it had several issues.
In the public area, by default it generated a blank file.
In the admin section, the report was hard to configure and it generated
a file with less quality than the old system.
So until we improve this system, we're bringing back the old investment
CSV exporter.
This commit reverts most of commit 9d1ca3bf.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
include CommentableActions
|
||||
include DownloadSettingsHelper
|
||||
include Translatable
|
||||
|
||||
feature_flag :budgets
|
||||
@@ -21,9 +20,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||
format.html
|
||||
format.js
|
||||
format.csv do
|
||||
send_data to_csv(@investments, Budget::Investment),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
send_data Budget::Investment::Exporter.new(@investments).to_csv,
|
||||
filename: "budget_investments.csv"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,18 +1,5 @@
|
||||
class Admin::CommentsController < Admin::BaseController
|
||||
include DownloadSettingsHelper
|
||||
|
||||
def index
|
||||
@comments = Comment.sort_by_newest.page(params[:page])
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
||||
format.csv do
|
||||
send_data to_csv(Comment.sort_by_newest, Comment),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "comments.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
class Admin::DownloadSettingsController < Admin::BaseController
|
||||
include DownloadSettingsHelper
|
||||
|
||||
load_and_authorize_resource
|
||||
|
||||
def edit
|
||||
permitted = downloadable_params
|
||||
@download_settings = []
|
||||
if permitted_models.include? permitted[:resource]
|
||||
set_edit(permitted[:resource])
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
permitted = downloadable_params
|
||||
if permitted[:downloadable]
|
||||
DownloadSetting.where(name_model: get_model(permitted[:resource]).to_s,
|
||||
config: permitted[:config].to_i).each do |download_setting|
|
||||
download_setting.update(downloadable: permitted[:downloadable]
|
||||
.include?(download_setting.name_field))
|
||||
end
|
||||
end
|
||||
set_edit(permitted[:resource])
|
||||
render :edit, resource: permitted[:resource], config: permitted[:config]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_edit(resource)
|
||||
@download_resource = { name: resource, config: get_config }
|
||||
@download_settings = get_attrs(get_model(resource), get_config)
|
||||
end
|
||||
|
||||
def permitted_models
|
||||
["legislation_processes", "debates", "proposals", "budget_investments", "comments"]
|
||||
end
|
||||
|
||||
def downloadable_params
|
||||
params.permit(:resource,
|
||||
:config,
|
||||
downloadable: [])
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,6 @@
|
||||
class Admin::Legislation::ProcessesController < Admin::Legislation::BaseController
|
||||
include Translatable
|
||||
include ImageAttributes
|
||||
include DownloadSettingsHelper
|
||||
|
||||
has_filters %w[active all], only: :index
|
||||
|
||||
@@ -10,15 +9,6 @@ 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 do
|
||||
send_data to_csv(process_for_download, Legislation::Process),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "legislation_processes.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -53,10 +43,6 @@ 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
|
||||
|
||||
@@ -3,7 +3,6 @@ class Admin::ProposalsController < Admin::BaseController
|
||||
include CommentableActions
|
||||
include FeatureFlags
|
||||
feature_flag :proposals
|
||||
helper DownloadSettingsHelper
|
||||
|
||||
has_orders %w[created_at]
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
module Budgets
|
||||
class ExecutionsController < ApplicationController
|
||||
include DownloadSettingsHelper
|
||||
before_action :load_budget
|
||||
|
||||
load_and_authorize_resource :budget
|
||||
@@ -9,19 +8,6 @@ module Budgets
|
||||
authorize! :read_executions, @budget
|
||||
@statuses = Milestone::Status.all
|
||||
@investments_by_heading = investments_by_heading_ordered_alphabetically.to_h
|
||||
downloadables = []
|
||||
investments_by_heading_ordered_alphabetically
|
||||
.map { |heading| downloadables.concat heading[1] }
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv do
|
||||
send_data to_csv(downloadables, Budget::Investment, 1),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "budget_investment_milestones.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -2,7 +2,6 @@ module Budgets
|
||||
class ResultsController < ApplicationController
|
||||
before_action :load_budget
|
||||
before_action :load_heading
|
||||
include DownloadSettingsHelper
|
||||
|
||||
load_and_authorize_resource :budget
|
||||
|
||||
@@ -10,16 +9,6 @@ module Budgets
|
||||
authorize! :read_results, @budget
|
||||
@investments = Budget::Result.new(@budget, @heading).investments
|
||||
@headings = @budget.headings.sort_by_name
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv do
|
||||
send_data to_csv(@investments.compatible, Budget::Investment),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "budget_investment_results.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -2,7 +2,6 @@ module CommentableActions
|
||||
extend ActiveSupport::Concern
|
||||
include Polymorphic
|
||||
include Search
|
||||
include DownloadSettingsHelper
|
||||
include RemotelyTranslatable
|
||||
|
||||
def index
|
||||
@@ -12,7 +11,6 @@ module CommentableActions
|
||||
@resources = @resources.search(@search_terms) if @search_terms.present?
|
||||
@resources = @advanced_search_terms.present? ? @resources.filter(@advanced_search_terms) : @resources
|
||||
@resources = @resources.tagged_with(@tag_filter) if @tag_filter
|
||||
resources_csv = @resources
|
||||
|
||||
@resources = @resources.page(params[:page]).send("sort_by_#{@current_order}")
|
||||
|
||||
@@ -25,16 +23,6 @@ module CommentableActions
|
||||
|
||||
set_resources_instance
|
||||
@remote_translations = detect_remote_translations(@resources, featured_proposals)
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv do
|
||||
send_data to_csv(resources_csv, resource_model),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "#{get_resource(resource_model)}.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
class Legislation::ProcessesController < Legislation::BaseController
|
||||
include RandomSeed
|
||||
include DownloadSettingsHelper
|
||||
|
||||
has_filters %w[open past], only: :index
|
||||
has_filters %w[random winners], only: :proposals
|
||||
@@ -14,16 +13,6 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
@current_filter ||= "open"
|
||||
@processes = ::Legislation::Process.send(@current_filter).published
|
||||
.not_in_draft.order(start_date: :desc).page(params[:page])
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv do
|
||||
send_data to_csv(process_for_download, Legislation::Process),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "legislation_processes.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@@ -149,10 +138,6 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
|
||||
private
|
||||
|
||||
def process_for_download
|
||||
Legislation::Process.send(@current_filter).order(start_date: :desc)
|
||||
end
|
||||
|
||||
def member_method?
|
||||
params[:id].present?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user