From 82b0a6a92d056e4c6f64997fd5315c7513e47944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 5 Nov 2019 19:50:00 +0100 Subject: [PATCH] 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. --- app/assets/javascripts/application.js | 2 - app/assets/javascripts/modal_download.js | 14 - .../admin/budget_investments_controller.rb | 5 +- app/controllers/admin/comments_controller.rb | 13 - .../admin/download_settings_controller.rb | 43 --- .../admin/legislation/processes_controller.rb | 14 - app/controllers/admin/proposals_controller.rb | 1 - .../budgets/executions_controller.rb | 14 - app/controllers/budgets/results_controller.rb | 11 - .../concerns/commentable_actions.rb | 12 - .../legislation/processes_controller.rb | 15 - app/helpers/download_settings_helper.rb | 44 --- app/models/abilities/administrator.rb | 2 - app/models/budget/investment.rb | 5 - app/models/comment.rb | 3 - .../budget_investment_csv.rb | 26 -- .../concerns/download_settings/comment_csv.rb | 26 -- .../concerns/download_settings/debate_csv.rb | 26 -- .../legislation_process_csv.rb | 26 -- .../download_settings/proposal_csv.rb | 26 -- app/models/debate.rb | 4 - app/models/download_setting.rb | 17 - app/models/legislation/process.rb | 3 - app/models/proposal.rb | 5 - app/views/admin/_menu.html.erb | 44 --- .../budget_investments/_investments.html.erb | 6 +- app/views/admin/comments/index.html.erb | 48 ++- app/views/admin/debates/index.html.erb | 24 +- .../admin/download_settings/_form.html.erb | 19 -- .../_form_hidden_params.html.erb | 30 -- .../admin/download_settings/_modal.html.erb | 13 - .../admin/download_settings/edit.html.erb | 16 - .../admin/hidden_comments/index.html.erb | 4 +- app/views/admin/hidden_debates/index.html.erb | 6 +- .../legislation/processes/index.html.erb | 4 - app/views/admin/proposals/index.html.erb | 6 +- app/views/budgets/executions/show.html.erb | 4 - app/views/budgets/results/show.html.erb | 3 - app/views/debates/index.html.erb | 1 - .../legislation/processes/index.html.erb | 8 - app/views/proposals/index.html.erb | 1 - app/views/shared/_download_links.html.erb | 4 - config/i18n-tasks.yml | 2 - config/locales/en/admin.yml | 12 - config/locales/en/download.yml | 170 ---------- config/locales/en/general.yml | 8 - config/locales/es/admin.yml | 12 - config/locales/es/download.yml | 170 ---------- config/locales/es/general.yml | 8 - config/routes/admin.rb | 3 - .../20191105184023_drop_download_settings.rb | 14 + db/schema.rb | 12 +- .../features/admin/budget_investments_spec.rb | 37 ++- spec/features/admin/download_settings_spec.rb | 309 ------------------ spec/features/admin/proposals_spec.rb | 2 +- 55 files changed, 91 insertions(+), 1266 deletions(-) delete mode 100644 app/assets/javascripts/modal_download.js delete mode 100644 app/controllers/admin/download_settings_controller.rb delete mode 100644 app/helpers/download_settings_helper.rb delete mode 100644 app/models/concerns/download_settings/budget_investment_csv.rb delete mode 100644 app/models/concerns/download_settings/comment_csv.rb delete mode 100644 app/models/concerns/download_settings/debate_csv.rb delete mode 100644 app/models/concerns/download_settings/legislation_process_csv.rb delete mode 100644 app/models/concerns/download_settings/proposal_csv.rb delete mode 100644 app/models/download_setting.rb delete mode 100644 app/views/admin/download_settings/_form.html.erb delete mode 100644 app/views/admin/download_settings/_form_hidden_params.html.erb delete mode 100644 app/views/admin/download_settings/_modal.html.erb delete mode 100644 app/views/admin/download_settings/edit.html.erb delete mode 100644 app/views/shared/_download_links.html.erb delete mode 100644 config/locales/en/download.yml delete mode 100644 config/locales/es/download.yml create mode 100644 db/migrate/20191105184023_drop_download_settings.rb delete mode 100644 spec/features/admin/download_settings_spec.rb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index abe121e1e..5332bc4f0 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -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(); diff --git a/app/assets/javascripts/modal_download.js b/app/assets/javascripts/modal_download.js deleted file mode 100644 index debd3672a..000000000 --- a/app/assets/javascripts/modal_download.js +++ /dev/null @@ -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); diff --git a/app/controllers/admin/budget_investments_controller.rb b/app/controllers/admin/budget_investments_controller.rb index c90c4f8e9..db731040b 100644 --- a/app/controllers/admin/budget_investments_controller.rb +++ b/app/controllers/admin/budget_investments_controller.rb @@ -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 diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 5a96634d3..00ff26542 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -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 diff --git a/app/controllers/admin/download_settings_controller.rb b/app/controllers/admin/download_settings_controller.rb deleted file mode 100644 index 15c3bf06e..000000000 --- a/app/controllers/admin/download_settings_controller.rb +++ /dev/null @@ -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 diff --git a/app/controllers/admin/legislation/processes_controller.rb b/app/controllers/admin/legislation/processes_controller.rb index 6c082869e..b6e818944 100644 --- a/app/controllers/admin/legislation/processes_controller.rb +++ b/app/controllers/admin/legislation/processes_controller.rb @@ -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 diff --git a/app/controllers/admin/proposals_controller.rb b/app/controllers/admin/proposals_controller.rb index 2ff35428e..75d8a2751 100644 --- a/app/controllers/admin/proposals_controller.rb +++ b/app/controllers/admin/proposals_controller.rb @@ -3,7 +3,6 @@ class Admin::ProposalsController < Admin::BaseController include CommentableActions include FeatureFlags feature_flag :proposals - helper DownloadSettingsHelper has_orders %w[created_at] diff --git a/app/controllers/budgets/executions_controller.rb b/app/controllers/budgets/executions_controller.rb index 9e846ac34..09a908928 100644 --- a/app/controllers/budgets/executions_controller.rb +++ b/app/controllers/budgets/executions_controller.rb @@ -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 diff --git a/app/controllers/budgets/results_controller.rb b/app/controllers/budgets/results_controller.rb index d7e6eb320..5910e292d 100644 --- a/app/controllers/budgets/results_controller.rb +++ b/app/controllers/budgets/results_controller.rb @@ -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 diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index 311890bee..12283d781 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -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 diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb index 15d18d0c9..96f4fa112 100644 --- a/app/controllers/legislation/processes_controller.rb +++ b/app/controllers/legislation/processes_controller.rb @@ -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 diff --git a/app/helpers/download_settings_helper.rb b/app/helpers/download_settings_helper.rb deleted file mode 100644 index 3ac737361..000000000 --- a/app/helpers/download_settings_helper.rb +++ /dev/null @@ -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 diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index c05dcec86..ef51690e0 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -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 diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 7f0bdb0f5..bfa752fb1 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -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 } diff --git a/app/models/comment.rb b/app/models/comment.rb index e769aa3df..1552ce3a5 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -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 diff --git a/app/models/concerns/download_settings/budget_investment_csv.rb b/app/models/concerns/download_settings/budget_investment_csv.rb deleted file mode 100644 index c4f19cbbc..000000000 --- a/app/models/concerns/download_settings/budget_investment_csv.rb +++ /dev/null @@ -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 diff --git a/app/models/concerns/download_settings/comment_csv.rb b/app/models/concerns/download_settings/comment_csv.rb deleted file mode 100644 index 663bea550..000000000 --- a/app/models/concerns/download_settings/comment_csv.rb +++ /dev/null @@ -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 diff --git a/app/models/concerns/download_settings/debate_csv.rb b/app/models/concerns/download_settings/debate_csv.rb deleted file mode 100644 index 6707acb9a..000000000 --- a/app/models/concerns/download_settings/debate_csv.rb +++ /dev/null @@ -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 diff --git a/app/models/concerns/download_settings/legislation_process_csv.rb b/app/models/concerns/download_settings/legislation_process_csv.rb deleted file mode 100644 index 9bbed6815..000000000 --- a/app/models/concerns/download_settings/legislation_process_csv.rb +++ /dev/null @@ -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 diff --git a/app/models/concerns/download_settings/proposal_csv.rb b/app/models/concerns/download_settings/proposal_csv.rb deleted file mode 100644 index ed1678b9a..000000000 --- a/app/models/concerns/download_settings/proposal_csv.rb +++ /dev/null @@ -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 diff --git a/app/models/debate.rb b/app/models/debate.rb index 756563007..22ed568b1 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -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 diff --git a/app/models/download_setting.rb b/app/models/download_setting.rb deleted file mode 100644 index a95497c98..000000000 --- a/app/models/download_setting.rb +++ /dev/null @@ -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 diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb index bac80536c..c72333346 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -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 diff --git a/app/models/proposal.rb b/app/models/proposal.rb index c9b5a5d19..c53968817 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -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 diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 0348cc4d9..45ad2d7d4 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -228,50 +228,6 @@ <% end %> -
  • - - - <%= t("admin.menu.download_settings.title") %> - - -
  • -
  • diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb index f38f5c62d..890448513 100644 --- a/app/views/admin/budget_investments/_investments.html.erb +++ b/app/views/admin/budget_investments/_investments.html.erb @@ -1,4 +1,6 @@ -<%= t("admin.budget_investments.index.download_current_selection") %> +<%= 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") %> <% end %> - -<%= render "admin/download_settings/modal", resource: { name: "budget_investments" } %> diff --git a/app/views/admin/comments/index.html.erb b/app/views/admin/comments/index.html.erb index 991e2e054..7fb62f017 100644 --- a/app/views/admin/comments/index.html.erb +++ b/app/views/admin/comments/index.html.erb @@ -8,34 +8,32 @@

    <%= page_entries_info @comments %>

    - <%= t("admin.comments.index.link") %> - - - - - - - - + + + + + + + - <% @comments.each do |comment| %> - - - - - - - - <% end %> + <% @comments.each do |comment| %> + + + + + + + + <% end %>
    <%= t("admin.comments.index.id") %><%= t("admin.comments.index.content") %><%= t("admin.comments.index.author") %><%= t("admin.comments.index.commentable_type") %><%= t("admin.comments.index.table_link") %>
    <%= t("admin.comments.index.id") %><%= t("admin.comments.index.content") %><%= t("admin.comments.index.author") %><%= t("admin.comments.index.commentable_type") %><%= t("admin.comments.index.table_link") %>
    <%= comment.id %><%= comment.body %><%= comment.author.username %><%= comment.commentable_type.constantize.model_name.human %> - <% if comment.commentable.hidden? %> - (<%= t("admin.comments.index.hidden_#{comment.commentable_type.downcase}") %>: <%= comment.commentable.title %>) - <% else %> - <%= link_to comment.commentable.title, commentable_path(comment) %> - <% end %> -
    <%= comment.id %><%= comment.body %><%= comment.author.username %><%= comment.commentable_type.constantize.model_name.human %> + <% if comment.commentable.hidden? %> + (<%= t("admin.comments.index.hidden_#{comment.commentable_type.downcase}") %>: <%= comment.commentable.title %>) + <% else %> + <%= link_to comment.commentable.title, commentable_path(comment) %> + <% end %> +
    @@ -45,5 +43,3 @@ <%= t("admin.comments.index.no_comments") %> <% end %> - -<%= render "admin/download_settings/modal", resource: { name: "comments" } %> diff --git a/app/views/admin/debates/index.html.erb b/app/views/admin/debates/index.html.erb index 3e42821e0..117c9f9f8 100644 --- a/app/views/admin/debates/index.html.erb +++ b/app/views/admin/debates/index.html.erb @@ -9,22 +9,20 @@

    <%= page_entries_info @debates %>

    - <%= t("admin.debates.index.link") %> - - - - + + + - <% @debates.each do |debate| %> - - - - - - <% end %> + <% @debates.each do |debate| %> + + + + + + <% end %>
    <%= t("admin.debates.index.id") %><%= t("admin.debates.index.title") %><%= t("admin.debates.index.author") %><%= t("admin.debates.index.id") %><%= t("admin.debates.index.title") %><%= t("admin.debates.index.author") %>
    <%= debate.id %><%= link_to debate.title, admin_debate_path(debate) %><%= debate.author.username %>
    <%= debate.id %><%= link_to debate.title, admin_debate_path(debate) %><%= debate.author.username %>
    @@ -34,5 +32,3 @@ <%= t("admin.debates.index.no_debates") %> <% end %> - -<%= render "admin/download_settings/modal", resource: { name: "debates" } %> diff --git a/app/views/admin/download_settings/_form.html.erb b/app/views/admin/download_settings/_form.html.erb deleted file mode 100644 index b7beb497a..000000000 --- a/app/views/admin/download_settings/_form.html.erb +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - <% download_settings.each do |attr| %> - - - - - - <% end %> - -
    <%= t("download.edit.fields") %><%= t("download.edit.description") %><%= t("download.edit.downloadable") %>
    <%= attr.name_field %><%= t("download.fielddescription.#{resource[:name]}.#{attr.name_field}", default: "") %><%= check_box_tag "downloadable[]", attr.name_field, attr.downloadable, class: "js-download-settings-check" %>
    diff --git a/app/views/admin/download_settings/_form_hidden_params.html.erb b/app/views/admin/download_settings/_form_hidden_params.html.erb deleted file mode 100644 index a04aaba35..000000000 --- a/app/views/admin/download_settings/_form_hidden_params.html.erb +++ /dev/null @@ -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 %> diff --git a/app/views/admin/download_settings/_modal.html.erb b/app/views/admin/download_settings/_modal.html.erb deleted file mode 100644 index 9d6f86493..000000000 --- a/app/views/admin/download_settings/_modal.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -
    -

    <%= t("download.modal.title") %>

    - <%= 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])) %> -
    - -
    - <% end %> - -
    diff --git a/app/views/admin/download_settings/edit.html.erb b/app/views/admin/download_settings/edit.html.erb deleted file mode 100644 index c5c1e039e..000000000 --- a/app/views/admin/download_settings/edit.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<% unless @download_settings.empty? %> - <% provide(:title) do %> - <%= t("admin.header.title") %> - <%= t("download.edit.#{@download_resource[:name]}") %> - <% end %> - -

    <%= t("download.edit.#{@download_resource[:name]}") %> <%= t("download.edit.config.#{@download_resource[:config].to_s}") unless @download_resource[:config] == 0 %>

    - - <%= 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 %> - -
    - <%= submit_tag t("download.edit.submit"), class: "button success expanded" %> -
    - <% end %> - -<% end %> diff --git a/app/views/admin/hidden_comments/index.html.erb b/app/views/admin/hidden_comments/index.html.erb index 693efda67..0744661b0 100644 --- a/app/views/admin/hidden_comments/index.html.erb +++ b/app/views/admin/hidden_comments/index.html.erb @@ -8,8 +8,8 @@ - - + + <% @comments.each do |comment| %> diff --git a/app/views/admin/hidden_debates/index.html.erb b/app/views/admin/hidden_debates/index.html.erb index 7392eb3e6..27473db52 100644 --- a/app/views/admin/hidden_debates/index.html.erb +++ b/app/views/admin/hidden_debates/index.html.erb @@ -8,9 +8,9 @@
    <%= t("admin.shared.description") %><%= t("admin.shared.actions") %><%= t("admin.shared.description") %><%= t("admin.shared.actions") %>
    - - - + + + <% @debates.each do |debate| %> diff --git a/app/views/admin/legislation/processes/index.html.erb b/app/views/admin/legislation/processes/index.html.erb index 92d96bc9b..5e2a647c3 100644 --- a/app/views/admin/legislation/processes/index.html.erb +++ b/app/views/admin/legislation/processes/index.html.erb @@ -12,8 +12,6 @@ <% if @processes.any? %>

    <%= page_entries_info @processes %>

    - <%= t("admin.legislation.processes.index.link") %> -
    <%= t("admin.shared.title") %><%= t("admin.shared.description") %><%= t("admin.shared.actions") %><%= t("admin.shared.title") %><%= t("admin.shared.description") %><%= t("admin.shared.actions") %>
    @@ -52,5 +50,3 @@ <%= page_entries_info @processes %> <% end %> - -<%= render "admin/download_settings/modal", resource: { name: "legislation_processes" } %> diff --git a/app/views/admin/proposals/index.html.erb b/app/views/admin/proposals/index.html.erb index 9967b60ce..bc59de812 100644 --- a/app/views/admin/proposals/index.html.erb +++ b/app/views/admin/proposals/index.html.erb @@ -7,9 +7,7 @@ <% if @proposals.any? %> <%= render "/admin/shared/proposal_search", url: admin_proposals_path %> -

    <%= page_entries_info @proposals %>

    - - <%= t("admin.proposals.index.link") %> +

    <%= page_entries_info @proposals %>

    @@ -41,5 +39,3 @@ <%= t("admin.proposals.index.no_proposals") %> <% end %> - -<%= render "admin/download_settings/modal", resource: { name: "proposals" } %> diff --git a/app/views/budgets/executions/show.html.erb b/app/views/budgets/executions/show.html.erb index 1dfb67936..f9410fdc8 100644 --- a/app/views/budgets/executions/show.html.erb +++ b/app/views/budgets/executions/show.html.erb @@ -42,10 +42,6 @@
    - - <%= 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 %>
    <%= label_tag :milestone_tag, t("budgets.executions.filters.milestone_tag.label") %> diff --git a/app/views/budgets/results/show.html.erb b/app/views/budgets/results/show.html.erb index f30f74f87..420683ffc 100644 --- a/app/views/budgets/results/show.html.erb +++ b/app/views/budgets/results/show.html.erb @@ -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, diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb index a1991937e..7da27cfcd 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -100,7 +100,6 @@
    diff --git a/app/views/legislation/processes/index.html.erb b/app/views/legislation/processes/index.html.erb index adcbcb4af..72a54aa69 100644 --- a/app/views/legislation/processes/index.html.erb +++ b/app/views/legislation/processes/index.html.erb @@ -25,14 +25,6 @@

    <%= t("legislation.processes.index.section_footer.description") %>

    - - -
    - - -
    diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index fb6256b72..d1098672a 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -143,7 +143,6 @@ <% end %> <%= render "retired" %> <%= render "proposals_lists" %> - <%= render "shared/download_links", downloadable: "proposal" %> diff --git a/app/views/shared/_download_links.html.erb b/app/views/shared/_download_links.html.erb deleted file mode 100644 index a084b7211..000000000 --- a/app/views/shared/_download_links.html.erb +++ /dev/null @@ -1,4 +0,0 @@ - - - -

    <%= link_to t("shared.download.link.#{downloadable}"), current_path_with_query_params(format: :csv), class: "small" %>

    diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index ad5d47f85..6f184c17e 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -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.*" diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 1958566d9..f2f3f42ba 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -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: diff --git a/config/locales/en/download.yml b/config/locales/en/download.yml deleted file mode 100644 index d768aa7e7..000000000 --- a/config/locales/en/download.yml +++ /dev/null @@ -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" diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 8cf293097..c7914a873 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -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 diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 256db29ec..e8adfaff4 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -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: diff --git a/config/locales/es/download.yml b/config/locales/es/download.yml deleted file mode 100644 index e05aa5f76..000000000 --- a/config/locales/es/download.yml +++ /dev/null @@ -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" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 34a58a50d..07a47c6c6 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -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 diff --git a/config/routes/admin.rb b/config/routes/admin.rb index d28093d52..7bfc22484 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -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] diff --git a/db/migrate/20191105184023_drop_download_settings.rb b/db/migrate/20191105184023_drop_download_settings.rb new file mode 100644 index 000000000..76c34ccc3 --- /dev/null +++ b/db/migrate/20191105184023_drop_download_settings.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index aad613106..14d489112 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index f23226381..f239e188d 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -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") diff --git a/spec/features/admin/download_settings_spec.rb b/spec/features/admin/download_settings_spec.rb deleted file mode 100644 index 4a67e25ce..000000000 --- a/spec/features/admin/download_settings_spec.rb +++ /dev/null @@ -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 diff --git a/spec/features/admin/proposals_spec.rb b/spec/features/admin/proposals_spec.rb index 0fa9c569a..21c6b8297 100644 --- a/spec/features/admin/proposals_spec.rb +++ b/spec/features/admin/proposals_spec.rb @@ -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"