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:
Javi Martín
2019-11-05 19:50:00 +01:00
parent ea8efa36f5
commit 82b0a6a92d
55 changed files with 91 additions and 1266 deletions

View File

@@ -83,7 +83,6 @@
//= require i18n
//= require globalize
//= require send_admin_notification_alert
//= require modal_download
//= require settings
//= require cookies
//= require columns_selector
@@ -137,7 +136,6 @@ var initialize_modules = function() {
App.Managers.initialize();
App.Globalize.initialize();
App.SendAdminNotificationAlert.initialize();
App.ModalDownload.initialize();
App.Settings.initialize();
if ($("#js-columns-selector").length) {
App.ColumnsSelector.initialize();

View File

@@ -1,14 +0,0 @@
(function() {
"use strict";
App.ModalDownload = {
enableButton: function() {
$("#js-download-modal-submit").attr("disabled", false);
$("#js-download-modal-submit").removeClass("disabled");
},
initialize: function() {
$("#js-download-modal-submit").on("click", function() {
setTimeout(App.ModalDownload.enableButton, 2000);
});
}
};
}).call(this);

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -3,7 +3,6 @@ class Admin::ProposalsController < Admin::BaseController
include CommentableActions
include FeatureFlags
feature_flag :proposals
helper DownloadSettingsHelper
has_orders %w[created_at]

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,44 +0,0 @@
module DownloadSettingsHelper
def get_model(resource_name)
case resource_name
when "legislation_processes"
Legislation::Process
when "budget_investments"
Budget::Investment
else
resource_name.singularize.classify.constantize
end
end
def get_attrs(model, config = 0)
download_settings = []
get_attr_names(model).each do |attr_name|
download_settings << DownloadSetting.initialize(model, attr_name, config)
end
download_settings
end
def get_attr_names(model)
model.attribute_names + model.get_association_attribute_names
end
def to_csv(resources_csv, resource_model, config = 0)
attribute_csv = resource_model.get_downloadables_names(config)
if admin_downloables?
attribute_csv = params[:downloadable]
end
resource_model.to_csv(resources_csv, attribute_csv)
end
def admin_downloables?
params[:downloadable].present? && !params[:downloadable].empty?
end
def get_resource(resource)
resource.to_s.pluralize.downcase
end
def get_config
params[:config].present? && !params[:config].nil? ? params[:config] : 0
end
end

View File

@@ -101,8 +101,6 @@ module Abilities
can [:deliver], Newsletter, hidden_at: nil
can [:manage], Dashboard::AdministratorTask
can [:edit, :update], DownloadSetting
can :manage, LocalCensusRecord
can [:create, :read], LocalCensusRecords::Import
end

View File

@@ -1,5 +1,4 @@
class Budget
require "csv"
class Investment < ApplicationRecord
SORTING_OPTIONS = { id: "id", supports: "cached_votes_up" }.freeze
@@ -26,8 +25,6 @@ class Budget
include Milestoneable
include Randomizable
extend DownloadSettings::BudgetInvestmentCsv
translates :title, touch: true
translates :description, touch: true
include Globalizable
@@ -57,8 +54,6 @@ class Budget
inverse_of: :commentable,
class_name: "Comment"
delegate :name, :email, to: :author, prefix: true
validates_translation :title, presence: true, length: { in: 4..Budget::Investment.title_max_length }
validates_translation :description, presence: true, length: { maximum: Budget::Investment.description_max_length }

View File

@@ -1,11 +1,8 @@
require "csv"
class Comment < ApplicationRecord
include Flaggable
include HasPublicAuthor
include Graphqlable
include Notifiable
extend DownloadSettings::CommentCsv
COMMENTABLE_TYPES = %w[Debate Proposal Budget::Investment Poll Topic
Legislation::Question Legislation::Annotation

View File

@@ -1,26 +0,0 @@
module DownloadSettings
module BudgetInvestmentCsv
extend ActiveSupport::Concern
def get_association_attribute_names
["author_name", "author_email"]
end
def get_downloadables_names(config)
DownloadSetting.where(name_model: "Budget::Investment",
downloadable: true,
config: config).pluck(:name_field)
end
def to_csv(budgets, admin_attr, options = {})
attributes = admin_attr.nil? ? [] : admin_attr
CSV.generate(options) do |csv|
csv << attributes
budgets.each do |budget|
csv << attributes.map { |attr| budget.send(attr) }
end
end
end
end
end

View File

@@ -1,26 +0,0 @@
module DownloadSettings
module CommentCsv
extend ActiveSupport::Concern
def get_association_attribute_names
["author_name", "author_email"]
end
def get_downloadables_names(config)
DownloadSetting.where(name_model: "Comment",
downloadable: true,
config: config).pluck(:name_field)
end
def to_csv(comments, admin_attr, options = {})
attributes = admin_attr.nil? ? [] : admin_attr
CSV.generate(options) do |csv|
csv << attributes
comments.each do |comment|
csv << attributes.map { |attr| comment.send(attr) }
end
end
end
end
end

View File

@@ -1,26 +0,0 @@
module DownloadSettings
module DebateCsv
extend ActiveSupport::Concern
def get_association_attribute_names
["author_name", "author_email"]
end
def get_downloadables_names(config)
DownloadSetting.where(name_model: "Debate",
downloadable: true,
config: config).pluck(:name_field)
end
def to_csv(debates, admin_attr, options = {})
attributes = admin_attr.nil? ? [] : admin_attr
CSV.generate(options) do |csv|
csv << attributes
debates.each do |debate|
csv << attributes.map { |attr| debate.send(attr) }
end
end
end
end
end

View File

@@ -1,26 +0,0 @@
module DownloadSettings
module LegislationProcessCsv
extend ActiveSupport::Concern
def get_association_attribute_names
[]
end
def get_downloadables_names(config)
DownloadSetting.where(name_model: "Legislation::Process",
downloadable: true,
config: config).pluck(:name_field)
end
def to_csv(processes, admin_attr, options = {})
attributes = admin_attr.nil? ? [] : admin_attr
CSV.generate(options) do |csv|
csv << attributes
processes.each do |process|
csv << attributes.map { |attr| process.send(attr) }
end
end
end
end
end

View File

@@ -1,26 +0,0 @@
module DownloadSettings
module ProposalCsv
extend ActiveSupport::Concern
def get_association_attribute_names
["author_name", "author_email"]
end
def get_downloadables_names(config)
DownloadSetting.where(name_model: "Proposal",
downloadable: true,
config: config).pluck(:name_field)
end
def to_csv(proposals, admin_attr, options = {})
attributes = admin_attr.nil? ? [] : admin_attr
CSV.generate(options) do |csv|
csv << attributes
proposals.each do |proposal|
csv << attributes.map { |attr| proposal.send(attr) }
end
end
end
end
end

View File

@@ -1,5 +1,4 @@
require "numeric"
require "csv"
class Debate < ApplicationRecord
include Rails.application.routes.url_helpers
@@ -28,9 +27,6 @@ class Debate < ApplicationRecord
belongs_to :geozone
has_many :comments, as: :commentable, inverse_of: :commentable
extend DownloadSettings::DebateCsv
delegate :name, :email, to: :author, prefix: true
validates_translation :title, presence: true, length: { in: 4..Debate.title_max_length }
validates_translation :description, presence: true, length: { in: 10..Debate.description_max_length }
validates :author, presence: true

View File

@@ -1,17 +0,0 @@
class DownloadSetting < ApplicationRecord
validates :name_model, presence: true
validates :name_field, presence: true
def self.initialize(model, field_name, config)
download_setting = DownloadSetting.find_by(name_model: model.name,
name_field: field_name,
config: config)
if download_setting.nil?
download_setting = DownloadSetting.create!(downloadable: false,
name_model: model.name,
name_field: field_name,
config: config)
end
download_setting
end
end

View File

@@ -1,5 +1,3 @@
require "csv"
class Legislation::Process < ApplicationRecord
include ActsAsParanoidAliases
include Taggable
@@ -17,7 +15,6 @@ class Legislation::Process < ApplicationRecord
translates :milestones_summary, touch: true
translates :homepage, touch: true
include Globalizable
extend DownloadSettings::LegislationProcessCsv
PHASES_AND_PUBLICATIONS = %i[homepage_phase draft_phase debate_phase allegations_phase
proposals_phase draft_publication result_publication].freeze

View File

@@ -1,5 +1,3 @@
require "csv"
class Proposal < ApplicationRecord
include Rails.application.routes.url_helpers
include Flaggable
@@ -43,9 +41,6 @@ class Proposal < ApplicationRecord
has_many :dashboard_actions, through: :dashboard_executed_actions, class_name: "Dashboard::Action"
has_many :polls, as: :related, inverse_of: :related
extend DownloadSettings::ProposalCsv
delegate :name, :email, to: :author, prefix: true
validates_translation :title, presence: true, length: { in: 4..Proposal.title_max_length }
validates_translation :description, length: { maximum: Proposal.description_max_length }
validates_translation :summary, presence: true

View File

@@ -228,50 +228,6 @@
<% end %>
</li>
<li class="section-title">
<a href="#">
<span class="icon-arrow-down"></span>
<strong><%= t("admin.menu.download_settings.title") %></strong>
</a>
<ul <%= "class=is-active" if controller_name == "download_settings" %>>
<% if feature?(:debates) %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "debates" %>>
<%= link_to t("admin.menu.download_settings.debates"), admin_edit_download_settings_path(resource: "debates") %>
</li>
<% end %>
<% if feature?(:proposals) %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "proposals" %>>
<%= link_to t("admin.menu.download_settings.proposals"), admin_edit_download_settings_path(resource: "proposals") %>
</li>
<% end %>
<% if feature?(:legislation) %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "legislation_processes" %>>
<%= link_to t("admin.menu.download_settings.legislation_processes"), admin_edit_download_settings_path(resource: "legislation_processes") %>
</li>
<% end %>
<% if feature?(:budgets) %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "budget_investments" %>>
<%= link_to t("admin.menu.download_settings.budget_investments"), admin_edit_download_settings_path(resource: "budget_investments") %>
</li>
<% end %>
<% if feature?(:budgets) %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "budget_investments" %>>
<%= link_to t("admin.menu.download_settings.budget_investments_milestones"), admin_edit_download_settings_path(resource: "budget_investments", config: 1) %>
</li>
<% end %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "comments" %>>
<%= link_to t("admin.menu.download_settings.comments"), admin_edit_download_settings_path(resource: "comments") %>
</li>
</ul>
</li>
<li class="section-title">
<a href="#">
<span class="icon-settings"></span>

View File

@@ -1,4 +1,6 @@
<a class="small float-right clear" data-open="download-modal"><%= t("admin.budget_investments.index.download_current_selection") %></a>
<%= link_to t("admin.budget_investments.index.download_current_selection"),
admin_budget_budget_investments_path(csv_params),
class: "float-right small clear" %>
<% if params[:advanced_filters].include?("winners") %>
<% if display_calculate_winners_button?(@budget) %>
@@ -69,5 +71,3 @@
<%= t("admin.budget_investments.index.no_budget_investments") %>
</div>
<% end %>
<%= render "admin/download_settings/modal", resource: { name: "budget_investments" } %>

View File

@@ -8,8 +8,6 @@
<h3 class="inline-block"><%= page_entries_info @comments %></h3>
<a class="small float-right clear" data-open="download-modal"><%= t("admin.comments.index.link") %></a>
<table>
<thead>
<tr>
@@ -45,5 +43,3 @@
<%= t("admin.comments.index.no_comments") %>
</div>
<% end %>
<%= render "admin/download_settings/modal", resource: { name: "comments" } %>

View File

@@ -9,8 +9,6 @@
<h3 class="inline-block"><%= page_entries_info @debates %></h3>
<a class="small float-right clear" data-open="download-modal"><%= t("admin.debates.index.link") %></a>
<table>
<thead>
<th class="text-center"><%= t("admin.debates.index.id") %></th>
@@ -34,5 +32,3 @@
<%= t("admin.debates.index.no_debates") %>
</div>
<% end %>
<%= render "admin/download_settings/modal", resource: { name: "debates" } %>

View File

@@ -1,19 +0,0 @@
<table>
<thead>
<tr>
<th><%= t("download.edit.fields") %></th>
<th><%= t("download.edit.description") %></th>
<th class="small"><%= t("download.edit.downloadable") %></th>
</tr>
</thead>
<tbody>
<% download_settings.each do |attr| %>
<tr>
<td><%= attr.name_field %></td>
<td><%= t("download.fielddescription.#{resource[:name]}.#{attr.name_field}", default: "") %></td>
<td class="text-center small"><%= check_box_tag "downloadable[]", attr.name_field, attr.downloadable, class: "js-download-settings-check" %></td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -1,30 +0,0 @@
<% if params[:search].present? %>
<%= hidden_field_tag "search", params[:search] %>
<% end %>
<% if params[:commit].present? %>
<%= hidden_field_tag "commit", params[:commit] %>
<% end %>
<% if params[:filter].present? %>
<%= hidden_field_tag "filter", params[:filter] %>
<% end %>
<% if params[:page].present? %>
<%= hidden_field_tag "page", params[:page] %>
<% end %>
<% if params[:administrator_id].present? %>
<%= hidden_field_tag "administrator_id", params[:administrator_id] %>
<% end %>
<% if params[:valuator_or_group_id].present? %>
<%= hidden_field_tag "valuator_or_group_id", params[:valuator_or_group_id] %>
<% end %>
<% if params[:heading_id].present? %>
<%= hidden_field_tag "heading_id", params[:heading_id] %>
<% end %>
<% if params[:title_or_id].present? %>
<%= hidden_field_tag "title_or_id", params[:title_or_id] %>
<% end %>
<% if params[:tag_name].present? %>
<%= hidden_field_tag "tag_name", params[:tag_name] %>
<% end %>
<% if params[:min_total_supports].present? %>
<%= hidden_field_tag "min_total_supports", params[:min_total_supports] %>
<% end %>

View File

@@ -1,13 +0,0 @@
<div class="small reveal" id="download-modal" data-reveal>
<h1><%= t("download.modal.title") %></h1>
<%= form_tag current_path_with_query_params(format: :csv), method: :get do |f| %>
<%= render "admin/download_settings/form_hidden_params" %>
<%= render "admin/download_settings/form", resource: resource, download_settings: get_attrs(get_model(resource[:name])) %>
<div class="medium-5 column clear end">
<button type="submit" data-close id="js-download-modal-submit" class="button success expanded"><%= t("download.modal.submit") %></button>
</div>
<% end %>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">&times;</span>
</button>
</div>

View File

@@ -1,16 +0,0 @@
<% unless @download_settings.empty? %>
<% provide(:title) do %>
<%= t("admin.header.title") %> - <%= t("download.edit.#{@download_resource[:name]}") %>
<% end %>
<h2><%= t("download.edit.#{@download_resource[:name]}") %> <%= t("download.edit.config.#{@download_resource[:config].to_s}") unless @download_resource[:config] == 0 %></h2>
<%= form_tag admin_update_download_settings_path(resource: @download_resource[:name], config: @download_resource[:config]), method: :put do %>
<%= render "form", resource: @download_resource, download_settings: @download_settings %>
<div class="small-12 medium-3 column clear end">
<%= submit_tag t("download.edit.submit"), class: "button success expanded" %>
</div>
<% end %>
<% end %>

View File

@@ -12,8 +12,6 @@
<% if @processes.any? %>
<h3><%= page_entries_info @processes %></h3>
<a class="small float-right clear" data-open="download-modal"><%= t("admin.legislation.processes.index.link") %></a>
<table class="stack">
<thead>
<tr>
@@ -52,5 +50,3 @@
<%= page_entries_info @processes %>
</div>
<% end %>
<%= render "admin/download_settings/modal", resource: { name: "legislation_processes" } %>

View File

@@ -7,9 +7,7 @@
<% if @proposals.any? %>
<%= render "/admin/shared/proposal_search", url: admin_proposals_path %>
<h3 class="inline-block"><%= page_entries_info @proposals %></h3>
<a class="small float-right clear" data-open="download-modal"><%= t("admin.proposals.index.link") %></a>
<h3><%= page_entries_info @proposals %></h3>
<table>
<thead>
@@ -41,5 +39,3 @@
<%= t("admin.proposals.index.no_proposals") %>
</div>
<% end %>
<%= render "admin/download_settings/modal", resource: { name: "proposals" } %>

View File

@@ -42,10 +42,6 @@
</div>
<div class="small-12 medium-9 large-10 column">
<%= link_to t("shared.download.link.investments"), current_path_with_query_params(format: :csv),
class: "button hollow margin-bottom margin-right float-right-medium" %>
<%= form_tag(budget_executions_path(@budget), method: :get) do %>
<div class="small-12 medium-3 column">
<%= label_tag :milestone_tag, t("budgets.executions.filters.milestone_tag.label") %>

View File

@@ -48,9 +48,6 @@
data: { "toggle-selector" => ".js-discarded",
"toggle-text" => t("budgets.results.hide_discarded_link") } %>
<%= link_to t("shared.download.link.investments"), current_path_with_query_params(format: :csv),
class: "button hollow margin-bottom margin-right float-right-medium" %>
<%= render "results_table", results_type: :compatible,
title: @heading.name,
heading_price: @heading.price,

View File

@@ -100,7 +100,6 @@
<aside class="margin-bottom">
<%= link_to t("debates.index.start_debate"), new_debate_path, class: "button expanded" %>
<%= render "shared/tag_cloud", taggable: "debate" %>
<%= render "shared/download_links", downloadable: "debate" %>
</aside>
</div>

View File

@@ -25,14 +25,6 @@
</p>
<p><%= t("legislation.processes.index.section_footer.description") %></p>
</div>
</div>
</div>
<div class="small-12 medium-3 column">
<aside class="margin-bottom">
<%= render "shared/download_links", downloadable: "legislation_process" %>
</aside>
</div>
</div>

View File

@@ -143,7 +143,6 @@
<% end %>
<%= render "retired" %>
<%= render "proposals_lists" %>
<%= render "shared/download_links", downloadable: "proposal" %>
</aside>
</div>

View File

@@ -1,4 +0,0 @@
<div class="sidebar-divider"></div>
<h2 class="sidebar-title"><%= t("shared.download.title") %></h2>
<p><%= link_to t("shared.download.link.#{downloadable}"), current_path_with_query_params(format: :csv), class: "small" %></p>

View File

@@ -46,7 +46,6 @@ data:
- config/locales/%{locale}/i18n.yml
- config/locales/%{locale}/milestones.yml
- config/locales/%{locale}/stats.yml
- config/locales/%{locale}/download.yml
# Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
# `i18n-tasks normalize -p` will force move the keys according to these rules
@@ -191,7 +190,6 @@ ignore_unused:
- "legislation.processes.proposals.filters.*"
- "helpers.page_entries_info.*" # kaminari
- "views.pagination.*" # kaminari
- "shared.download.*"
- "shared.suggest.*"
- "invisible_captcha.*"
- "admin.legislation.processes.process.*"

View File

@@ -336,7 +336,6 @@ en:
content: "Content"
author: "Author"
commentable_type: "Type"
link: "Download comments"
title: Comments
no_comments: There are no comments.
table_link: "Link"
@@ -417,7 +416,6 @@ en:
author: Author
title: Debates
no_debates: There are no debates.
link: "Download debates"
hidden_debates:
index:
filter: Filter
@@ -502,7 +500,6 @@ en:
filters:
active: Active
all: All
link: "Download legislation process"
new:
back: Back
title: Create new collaborative legislation process
@@ -696,14 +693,6 @@ en:
dashboard: Proposals dashboard
administrator_tasks: Resources requested
dashboard_actions: Resources and actions
download_settings:
title: "Download settings"
debates: "Debates"
proposals: "Proposals"
legislation_processes: "Legislation process"
budget_investments: "Participatory budgeting"
comments: "Comments"
budget_investments_milestones: "Participatory budgeting (Milestones)"
debates: "Debates"
comments: "Comments"
local_census_records: Manage local census
@@ -1214,7 +1203,6 @@ en:
selected: Selected
milestones: Milestones
no_proposals: There are no proposals.
link: "Download proposals"
show:
create_question: Add this proposal to a poll to be voted
form:

View File

@@ -1,170 +0,0 @@
en:
download:
edit:
fields: "Fields"
description: "Description"
downloadable: "Downloadable"
debates: "Debates"
proposals: "Proposals"
legislation_processes: "Legislation process"
budget_investments: "Participatory budgeting"
comments: "Comments"
submit: "Save changes"
config:
"0": ""
"1": "- Milestones"
fielddescription:
debates:
id: "Identification Number"
title: "Title"
description: "Description"
author_id: "Author Identification Number"
created_at: "Created at"
updated_at: "Updated at"
visit_id: "Visit id"
hidden_at: "Hidden at"
flags_count: "Flags count"
ignored_flag_at: "Ignored flag at"
cached_votes_total: "Cached votes total"
cached_votes_up: "Cached votes up"
cached_votes_down: "Cached votes down"
comments_count: "Comments count"
confirmed_hide_at: "Confirmed hide at"
cached_anonymous_votes_total: "Cached anonymous votes total"
cached_votes_score: "Cached votes score"
hot_score: "Hot score"
confidence_score: "Confidence score"
geozone_id: "Geozone id"
tsv: "Tsv"
featured_at: "Featured at"
author_name: "Author name"
author_email: "Author email"
proposals:
id: "Identification Number"
title: "Title"
description: "Description"
question: "Question"
external_url: "External Url"
author_id: "Author Identification Number"
hidden_at: "Hidden at"
flags_count: "Flags count"
ignored_flag_at: "Ignored flag at"
cached_votes_up: "Cached votes up"
comments_count: "Comments count"
confirmed_hide_at: "Confirmed hide at"
hot_score: "Hot Score"
confidence_score: "Confidence Score"
created_at: "Created at"
updated_at: "Updated at"
responsible_name: "Responsible name"
summary: "Summary"
video_url: "Video url"
tsv: "Tsv"
geozone_id: "Geozone id"
retired_at: "Retired at"
retired_reason: "Retired reason"
retired_explanation: "Retired Explanation"
community_id: "Community id"
author_name: "Author name"
author_email: "Author email"
legislation_processes:
id: "Identification Number"
title: "Title"
description: "Description"
additional_info: "Additional Info"
start_date: "Start date"
end_date: "End date"
debate_start_date: "Debate start date"
debate_end_date: "Debate end date"
draft_publication_date: "Draft publication date"
allegations_start_date: "Allegation start date"
allegations_end_date: "Allegation end date"
result_publication_date: "Result publication date"
hidden_at: "Hidden at"
created_at: "Created at"
updated_at: "Updated at"
summary: "Summary"
debate_phase_enabled: "Debate phase enabled"
allegations_phase_enabled: "Allegations phase enabled"
draft_publication_enabled: "Draft publication enabled"
result_publication_enabled: "Result publication enabled"
published: "Published"
proposals_phase_start_date: "Proposals phase start date"
proposals_phase_end_date: "Proposals phase end date"
proposals_phase_enabled: "Proposal phase enabled"
proposals_description: "Proposals description"
draft_start_date: "Draft start date"
draft_end_date: "Draft end date"
draft_phase_enabled: "Draft phase enabled"
homepage_enabled: "Homepage enabled"
background_color: "Background color"
font_color: "Font color"
budget_investments:
id: "Identification Number"
author_id: "Author id"
administrator_id: "Administrator id"
title: "Title"
description: "Description"
external_url: "External url"
price: "Price"
feasibility: "Feasibility"
price_explanation: "Price explanation"
unfeasibility_explanation: "Unfeasibility explanation"
valuation_finished: "Valuation finished"
valuator_assignments_count: "Valuator assignments count"
price_first_year: "Price first year"
duration: "Duration"
hidden_at: "Hidden at"
cached_votes_up: "Cached votes up"
comments_count: "Comments count"
confidence_score: "Confidence score"
physical_votes: "Physical votes"
tsv: "Tsv"
created_at: "Created at"
updated_at: "Updated at"
heading_id: "Heading id"
responsible_name: "Responsible name"
budget_id: "Budget id"
group_id: "Group id"
selected: "Selected"
location: "Location"
organization_name: "Organization name"
unfeasible_email_sent_at: "Unfeasible email sent at"
ballot_lines_count: "Ballot lines count"
previous_heading_id: "Previous heading id"
winner: "Winner"
incompatible: "Incompatible"
community_id: "Commmunity id"
visible_to_valuators: "Visible to valuators"
valuator_group_assignments_count: "Valuator group assignments count"
confirmed_hide_at: "Confirmed hide at"
ignored_flag_at: "Ignored flag at"
flags_count: "Flags count"
author_name: "Author name"
author_email: "Author email"
comments:
id: "Identification Number"
commentable_id: "Commentable id"
commentable_type: "Commentable type"
body: "Body"
subject: "Subject"
user_id: "User id"
created_at: "Created at"
updated_at: "Updated at"
hidden_at: "Hidden at"
flags_count: "Flags count"
ignored_flag_at: "Ignored flag at"
moderator_id: "Moderator id"
administrator_id: "Administrator id"
cached_votes_total: "Cached votes total"
cached_votes_up: "Cached votes up"
cached_votes_down: "Cached votes down"
confirmed_hide_at: "Confirmed hide at"
ancestry: "Ancestry"
confidence_score: "Confidance score"
valuation: "Valuation"
author_name: "Author name"
author_email: "Author email"
modal:
title: "Download"
submit: "Download"

View File

@@ -774,14 +774,6 @@ en:
title: Recommendations
see_more: See more recommendations
hide: Hide recommendations
download:
title: "Downloads"
link:
proposal: "Download proposals"
debate: "Download debates"
legislation_process: "Download legislation processes"
budget: "Download budgets"
investments: "Download projects"
translations:
select_language_prompt: Choose language
remove_language: Remove language

View File

@@ -336,7 +336,6 @@ es:
content: "Contenido"
author: "Autor"
commentable_type: "Tipo"
link: "Descargar comentarios"
title: Comentarios
no_comments: No hay comentarios.
table_link: "Link"
@@ -417,7 +416,6 @@ es:
author: Autor
title: Debates
no_debates: No hay debates.
link: "Descargar debates"
hidden_debates:
index:
filter: Filtro
@@ -502,7 +500,6 @@ es:
filters:
active: Activos
all: Todos
link: "Descargar procesos legislativos"
new:
back: Volver
title: Crear nuevo proceso de legislación colaborativa
@@ -695,14 +692,6 @@ es:
dashboard: Panel de progreso de propuestas
administrator_tasks: Recursos solicitados
dashboard_actions: Recursos y acciones
download_settings:
title: "Configuración de descarga"
debates: "Debates"
proposals: "Propuestas"
legislation_processes: "Procesos legislativos"
budget_investments: "Pressupuestos participativos"
comments: "Comentarios"
budget_investments_milestones: "Pressupuestos participativos (Seguimiento)"
debates: "Debates"
comments: "Comentarios"
local_census_records: Gestionar censo local
@@ -1213,7 +1202,6 @@ es:
select: Seleccionar
selected: Seleccionada
no_proposals: No hay propuestas.
link: "Descargar propuestas"
show:
create_question: Añadir esta propuesta a una votación para ser votada
form:

View File

@@ -1,170 +0,0 @@
es:
download:
edit:
fields: "Campos"
description: "Descripción"
downloadable: "Descargable"
debates: "Debates"
proposals: "Propuestas"
legislation_processes: "Procesos legislativos"
budget_investments: "Pressupuestos participativos"
comments: "Comentarios"
submit: "Guardar cambios"
config:
"0": ""
"1": "- Seguimiento"
fielddescription:
debates:
id: "Número de Identificación"
title: "Título"
description: "Descripción"
author_id: "Número de Identificación del Autor"
created_at: "Creado el"
updated_at: "Actualizado el"
hidden_at: "Ocultado el"
visit_id: "Núm. Identificación de vísita"
flags_count: "Núm. de denúncias"
ignored_flag_at: "Denúncia ignorada el"
cached_votes_total: "Total de votos"
cached_votes_up: "Votos positivos"
cached_votes_down: "Votos negativos"
comments_count: "Núm. de comentarios"
confirmed_hide_at: "Confirmado ocultado el"
cached_anonymous_votes_total: "Total votos anónimos"
cached_votes_score: "Puntuación votos"
hot_score: "Hot score"
confidence_score: "Puntuación de confianza"
geozone_id: "Núm. Identificación de zona"
tsv: "Tsv"
featured_at: "Presentado el"
author_name: "Nombre del autor"
author_email: "Email del autor"
proposals:
id: "Número de Identificación"
title: "Título"
description: "Descripción"
question: "Pregunta"
external_url: "URL externa"
author_id: "Número de Identificación del Autor"
flags_count: "Núm. de denúncias"
ignored_flag_at: "Denúncia ignorada el"
cached_votes_up: "Votos positivos"
comments_count: "Núm. de comentarios"
confirmed_hide_at: "Confirmado ocultado el"
hot_score: "Hot Score"
confidence_score: "Puntuación de confianza"
created_at: "Creado el"
updated_at: "Actualizado el"
hidden_at: "Ocultado el"
responsible_name: "Nombre del responsable"
summary: "Resumen"
video_url: "URL del vídeo"
tsv: "Tsv"
geozone_id: "Núm. Identificación de zona"
retired_at: "Retirado el"
retired_reason: "Razón de retirada"
retired_explanation: "Explicación de retirada"
community_id: "Núm. Identificación de la comunidad"
author_name: "Nombre del autor"
author_email: "Email del autor"
legislation_processes:
id: "Número de Identificación"
title: "Título"
description: "Descripción"
additional_info: "Información adicional"
start_date: "Fecha de início"
end_date: "Fecha de finalización"
debate_start_date: "Fecha de inicio del debate"
debate_end_date: "Fecha de finalización del debate"
draft_publication_date: "Fecha de publicación del borrador"
allegations_start_date: "Fecha de inicio de las alegaciones"
allegations_end_date: "Fecha de finalización de las alegaciones"
result_publication_date: "Fecha de publicación de resultados"
created_at: "Creado el"
updated_at: "Actualizado el"
hidden_at: "Ocultado el"
summary: "Resumen"
debate_phase_enabled: "Fase de debate activa"
allegations_phase_enabled: "Fase de alegaciones activa"
draft_publication_enabled: "Publicación del borrador activa"
result_publication_enabled: "Publicación de los resltados activa"
published: "Publicado"
proposals_phase_start_date: "Fecha de inicio de la fase de propuestas"
proposals_phase_end_date: "Fecha de finalización de la fase de propuestas"
proposals_phase_enabled: "Fase de propuestas activa"
proposals_description: "Descripción de propuestas"
draft_start_date: "Fecha de inicio del borrador"
draft_end_date: "Fecha de finalización del borrador"
draft_phase_enabled: "Fase de borrador activa"
homepage_enabled: "Página principal activa"
background_color: "color de fondo"
font_color: "Color de fuente"
budget_investments:
id: "Número de Identificación"
author_id: "Núm. de identificación"
administrator_id: "Núm. de identificación del administrador"
title: "Título"
description: "Descripción"
external_url: "URL externa"
price: "Precio"
feasibility: "Factibilidad"
price_explanation: "Explicación del precio"
unfeasibility_explanation: "Explicación de la infactibilidad"
valuation_finished: "Evaluación finalizada"
valuator_assignments_count: "Núm. de asignaciones del evaluador"
price_first_year: "Precio primer año"
duration: "Duración"
hidden_at: "Ocultado el"
cached_votes_up: "Votos positivos"
comments_count: "Núm. de comentarios"
confidence_score: "Puntuación de confianza"
physical_votes: "Votos físicos"
tsv: "Tsv"
created_at: "Creado el"
updated_at: "Actualizado el"
heading_id: "Núm. de identificación de título"
responsible_name: "Nombre del responsable"
budget_id: "Núm. de identificación del presupuesto"
group_id: "Núm. de identificación del grupo"
selected: "Seleccionado"
location: "Localización"
organization_name: "Nombre de la organización"
unfeasible_email_sent_at: "Correo de infactibilidad enviado el"
ballot_lines_count: "Núm. de líneas de votación"
previous_heading_id: "Núm. de identificación del título anterior"
winner: "Ganador"
incompatible: "Incompatible"
community_id: "Núm. de identificación de la comunidad"
visible_to_valuators: "Visible a los evaluadores"
valuator_group_assignments_count: "Núm. de asignaciones al grupo de evaluación"
confirmed_hide_at: "Confirmado ocultado el"
flags_count: "Núm. de denúncias"
ignored_flag_at: "Denúncia ignorada el"
author_name: "Nombre del autor"
author_email: "Email del autor"
comments:
id: "Número de Identificación"
commentable_id: "Núm. identificación del comentable"
commentable_type: "Tipo del comentable"
body: "Body"
subject: "Tma"
user_id: "Núm. identificación del usuario"
created_at: "Creado el"
updated_at: "Actualizado el"
hidden_at: "Ocultado el"
flags_count: "Núm. de denúncias"
ignored_flag_at: "Denúncia ignorada el"
moderator_id: "Núm. identificación del moderador"
administrator_id: "Núm. identificación del administrador"
cached_votes_total: "Total de votos"
cached_votes_up: "Votos positivos"
cached_votes_down: "Votos negativos"
confirmed_hide_at: "Confirmado ocultado el"
ancestry: "Ascendencia"
confidence_score: "Puntuación de confianza"
valuation: "Evaluación"
author_name: "Nombre del autor"
author_email: "Email del autor"
modal:
title: "Descarga"
submit: "Descargar"

View File

@@ -772,14 +772,6 @@ es:
title: Recomendaciones
see_more: Ver más recomendaciones
hide: Ocultar recomendaciones
download:
title: "Descargas"
link:
proposal: "Descargar propuestas"
debate: "Descargar debates"
legislation_process: "Descargar procesos legislativos"
budget: "Descargar presupuestos"
investments: "Descargar proyectos"
translations:
select_language_prompt: Seleccionar idioma
remove_language: Eliminar idioma

View File

@@ -248,9 +248,6 @@ namespace :admin do
resources :administrator_tasks, only: [:index, :edit, :update]
end
get "download_settings/:resource", to: "download_settings#edit", as: "edit_download_settings"
put "download_settings/:resource", to: "download_settings#update", as: "update_download_settings"
resources :local_census_records
namespace :local_census_records do
resources :imports, only: [:new, :create, :show]

View File

@@ -0,0 +1,14 @@
class DropDownloadSettings < ActiveRecord::Migration[5.0]
def change
drop_table :download_settings do |t|
t.string :name_model, null: false
t.string :name_field, null: false
t.boolean :downloadable, default: false, null: false
t.timestamps null: false
t.integer :config, default: 0, null: false
t.index [:name_model, :name_field, :config], unique: true
end
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20191102002238) do
ActiveRecord::Schema.define(version: 20191105184023) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -597,16 +597,6 @@ ActiveRecord::Schema.define(version: 20191102002238) do
t.index ["user_id"], name: "index_documents_on_user_id", using: :btree
end
create_table "download_settings", force: :cascade do |t|
t.string "name_model", null: false
t.string "name_field", null: false
t.boolean "downloadable", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "config", default: 0, null: false
t.index ["name_model", "name_field", "config"], name: "index_download_settings_on_name_model_and_name_field_and_config", unique: true, using: :btree
end
create_table "failed_census_calls", force: :cascade do |t|
t.integer "user_id"
t.string "document_number"

View File

@@ -1689,15 +1689,45 @@ describe "Admin budget investments" do
context "Selecting csv" do
scenario "Downloading CSV file" do
create(:budget_investment, budget: budget)
admin = create(:administrator, user: create(:user, username: "Admin"))
valuator = create(:valuator, user: create(:user, username: "Valuator"))
valuator_group = create(:valuator_group, name: "Valuator Group")
budget_group = create(:budget_group, name: "Budget Group", budget: budget)
first_budget_heading = create(:budget_heading, group: budget_group, name: "Budget Heading")
second_budget_heading = create(:budget_heading, group: budget_group, name: "Other Heading")
first_investment = create(:budget_investment, :feasible, :selected, title: "Le Investment",
budget: budget, group: budget_group,
heading: first_budget_heading,
cached_votes_up: 88, price: 99,
valuators: [],
valuator_groups: [valuator_group],
administrator: admin,
visible_to_valuators: true)
second_investment = create(:budget_investment, :unfeasible, title: "Alt Investment",
budget: budget, group: budget_group,
heading: second_budget_heading,
cached_votes_up: 66, price: 88,
valuators: [valuator],
valuator_groups: [],
visible_to_valuators: false)
visit admin_budget_budget_investments_path(budget)
click_button "Download"
click_link "Download current selection"
header = page.response_headers["Content-Disposition"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="budget_investments.csv"$/)
csv_contents = "ID,Title,Supports,Administrator,Valuator,Valuation Group,Scope of operation,"\
"Feasibility,Val. Fin.,Selected,Show to valuators,Author username\n"\
"#{first_investment.id},Le Investment,88,Admin,-,Valuator Group,"\
"Budget Heading,Feasible (€99),Yes,Yes,Yes,"\
"#{first_investment.author.username}\n#{second_investment.id},"\
"Alt Investment,66,No admin assigned,Valuator,-,Other Heading,"\
"Unfeasible,No,No,No,#{second_investment.author.username}\n"
expect(page.body).to eq(csv_contents)
end
scenario "Downloading CSV file with applied filter" do
@@ -1709,8 +1739,7 @@ describe "Admin budget investments" do
check "Valuation finished"
click_button "Filter"
find(:css, "#downloadable_[value='title']").set(true)
click_button "Download"
click_link "Download current selection"
expect(page).to have_content("Finished Investment")
expect(page).not_to have_content("Unfeasible one")

View File

@@ -1,309 +0,0 @@
require "rails_helper"
describe "Admin download settings" do
before do
admin = create(:administrator)
login_as(admin.user)
end
scenario "Edit download settings debates" do
visit admin_edit_download_settings_path(resource: "debates")
expect(page).to have_content("Debates")
end
scenario "Update download settings debates" do
visit admin_edit_download_settings_path(resource: "debates")
find(:css, "#downloadable_[value='id']").set(true)
find(:css, "#downloadable_[value='title']").set(true)
click_button "Save changes"
expect(DownloadSetting.find_by(name_model: "Debate",
name_field: "id").downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Debate",
name_field: "title").downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Debate",
name_field: "description").downloadable).to eq false
end
context "Download debates" do
before do
create(:debate)
end
scenario "admin csv" do
visit admin_debates_path
click_button "Download"
header = page.response_headers["Content-Disposition"]
content_type = page.response_headers["Content-Type"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="debates.csv"$/)
expect(content_type).to match("text/csv")
end
scenario "public csv" do
visit debates_path
click_link "Download debates"
header = page.response_headers["Content-Disposition"]
content_type = page.response_headers["Content-Type"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="debates.csv"$/)
expect(content_type).to match("text/csv")
end
end
scenario "Edit download settings proposals" do
visit admin_edit_download_settings_path(resource: "proposals")
expect(page).to have_content("Proposals")
end
scenario "Update download settings proposals" do
visit admin_edit_download_settings_path(resource: "proposals")
find(:css, "#downloadable_[value='id']").set(true)
find(:css, "#downloadable_[value='title']").set(true)
click_button "Save changes"
expect(DownloadSetting.find_by(name_model: "Proposal",
name_field: "id").downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Proposal",
name_field: "title").downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Proposal",
name_field: "description").downloadable).to eq false
end
context "Download proposals" do
before do
create(:proposal)
end
scenario "admin csv" do
visit admin_proposals_path
click_button "Download"
header = page.response_headers["Content-Disposition"]
content_type = page.response_headers["Content-Type"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="proposals.csv"$/)
expect(content_type).to match("text/csv")
end
scenario "public csv" do
visit proposals_path
click_link "Download proposals"
header = page.response_headers["Content-Disposition"]
content_type = page.response_headers["Content-Type"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="proposals.csv"$/)
expect(content_type).to match("text/csv")
end
end
scenario "Edit download settings comments" do
visit admin_edit_download_settings_path(resource: "comments")
expect(page).to have_content("Comments")
end
scenario "Update download settings comments" do
visit admin_edit_download_settings_path(resource: "comments")
find(:css, "#downloadable_[value='id']").set(true)
find(:css, "#downloadable_[value='body']").set(true)
click_button "Save changes"
expect(DownloadSetting.find_by(name_model: "Comment",
name_field: "id").downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Comment",
name_field: "body").downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Comment",
name_field: "subject").downloadable).to eq false
end
scenario "Download comments" do
create(:comment)
visit admin_comments_path
click_button "Download"
header = page.response_headers["Content-Disposition"]
content_type = page.response_headers["Content-Type"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="comments.csv"$/)
expect(content_type).to match("text/csv")
end
scenario "Edit download settings legislation process" do
visit admin_edit_download_settings_path(resource: "legislation_processes")
expect(page).to have_content("Legislation process")
end
scenario "Update download settings legislation process" do
visit admin_edit_download_settings_path(resource: "legislation_processes")
find(:css, "#downloadable_[value='id']").set(true)
find(:css, "#downloadable_[value='title']").set(true)
click_button "Save changes"
expect(DownloadSetting.find_by(name_model: "Legislation::Process",
name_field: "id").downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Legislation::Process",
name_field: "title").downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Legislation::Process",
name_field: "description").downloadable).to eq false
end
context "Download legislation process" do
before do
create(:legislation_process, :open)
create(:legislation_process, :published)
end
scenario "admin csv" do
visit admin_legislation_processes_path
click_button "Download"
header = page.response_headers["Content-Disposition"]
content_type = page.response_headers["Content-Type"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="legislation_processes.csv"$/)
expect(content_type).to match("text/csv")
end
scenario "public csv" do
visit legislation_processes_path
click_link "Download legislation processes"
header = page.response_headers["Content-Disposition"]
content_type = page.response_headers["Content-Type"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="legislation_processes.csv"$/)
expect(content_type).to match("text/csv")
end
end
scenario "Edit download settings budget investment results" do
visit admin_edit_download_settings_path(resource: "budget_investments")
expect(page).to have_content("Participatory budgeting")
end
scenario "Update download settings budget investment results" do
visit admin_edit_download_settings_path(resource: "budget_investments")
find(:css, "#downloadable_[value='id']").set(true)
find(:css, "#downloadable_[value='title']").set(true)
click_button "Save changes"
expect(DownloadSetting.find_by(name_model: "Budget::Investment",
name_field: "id").downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Budget::Investment",
name_field: "title").downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Budget::Investment",
name_field: "description").downloadable).to eq false
end
scenario "Edit download settings budget investment milestones" do
visit admin_edit_download_settings_path(resource: "budget_investments", config: 1)
expect(page).to have_content("Participatory budgeting - Milestones")
end
scenario "Update download settings budget investment milestones" do
visit admin_edit_download_settings_path(resource: "budget_investments", config: 1)
find(:css, "#downloadable_[value='id']").set(true)
find(:css, "#downloadable_[value='title']").set(true)
click_button "Save changes"
expect(DownloadSetting.find_by(name_model: "Budget::Investment",
name_field: "id",
config: 1).downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Budget::Investment",
name_field: "title",
config: 1).downloadable).to eq true
expect(DownloadSetting.find_by(name_model: "Budget::Investment",
name_field: "description",
config: 1).downloadable).to eq false
end
context "Download budgets" do
let(:budget_finished) { create(:budget, :finished) }
let(:heading) { create(:budget_heading, budget: budget_finished, price: 1000) }
let(:investment1) do
create(:budget_investment, :selected, heading: heading, price: 200, ballot_lines_count: 900)
end
let(:investment2) do
create(:budget_investment, :selected, heading: heading, price: 300, ballot_lines_count: 800)
end
let(:investment3) do
create(:budget_investment, :incompatible, heading: heading, price: 500, ballot_lines_count: 700)
end
let(:investment4) do
create(:budget_investment, :selected, heading: heading, price: 600, ballot_lines_count: 600)
end
let(:budget) { create :budget }
before do
Budget::Result.new(budget_finished, heading).calculate_winners
end
scenario "admin results csv" do
visit admin_budget_budget_investments_path(budget_id: budget.id)
click_button "Download"
header = page.response_headers["Content-Disposition"]
content_type = page.response_headers["Content-Type"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="budget_investments.csv"$/)
expect(content_type).to match("text/csv")
end
xscenario "public csv results" do
visit budget_results_path(budget_id: budget_finished.id)
save_page
click_link "Download projects"
header = page.response_headers["Content-Disposition"]
content_type = page.response_headers["Content-Type"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="budget_investment_results.csv"$/)
expect(content_type).to match("text/csv")
end
scenario "public csv milestones" do
visit budget_executions_path(budget_id: budget_finished.id)
save_page
click_link "Download projects"
header = page.response_headers["Content-Disposition"]
content_type = page.response_headers["Content-Type"]
expect(header).to match(/^attachment/)
expect(header).to match(/filename="budget_investment_milestones.csv"$/)
expect(content_type).to match("text/csv")
end
end
end

View File

@@ -15,7 +15,7 @@ describe "Admin proposals" do
create(:proposal, title: "Build a monument to honour CONSUL developers")
visit admin_root_path
within("#side_menu") { first(:link, "Proposals").click }
within("#side_menu") { click_link "Proposals" }
expect(page).to have_content "Make Pluto a planet again"
expect(page).to have_content "Build a monument"