From 9d1ca3bfd4fe8c34411db74a975720092f6f1c00 Mon Sep 17 00:00:00 2001 From: German Galia Date: Wed, 12 Jun 2019 10:17:31 +0200 Subject: [PATCH] Report generation. Download csv --- app/assets/javascripts/application.js | 2 + .../javascripts/modal_download.js.coffee | 9 + .../admin/budget_investments_controller.rb | 5 +- app/controllers/admin/comments_controller.rb | 17 + app/controllers/admin/debates_controller.rb | 20 ++ .../admin/download_settings_controller.rb | 43 +++ .../admin/legislation/processes_controller.rb | 12 + app/controllers/admin/proposals_controller.rb | 1 + .../budgets/executions_controller.rb | 14 + app/controllers/budgets/results_controller.rb | 9 + .../concerns/commentable_actions.rb | 9 + .../legislation/processes_controller.rb | 13 + app/helpers/download_settings_helper.rb | 47 +++ app/models/abilities/administrator.rb | 2 + app/models/budget/investment.rb | 4 + app/models/comment.rb | 3 + .../budget_investment_csv.rb | 28 ++ .../concerns/download_settings/comment_csv.rb | 28 ++ .../concerns/download_settings/debate_csv.rb | 28 ++ .../legislation_process_csv.rb | 28 ++ .../download_settings/proposal_csv.rb | 28 ++ app/models/debate.rb | 5 + app/models/download_setting.rb | 18 + app/models/legislation/process.rb | 3 + app/models/proposal.rb | 8 + app/views/admin/_menu.html.erb | 60 ++++ .../budget_investments/_investments.html.erb | 6 +- app/views/admin/comments/index.html.erb | 49 +++ app/views/admin/debates/index.html.erb | 38 ++ app/views/admin/debates/show.html.erb | 56 +++ .../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 | 18 +- app/views/admin/hidden_debates/index.html.erb | 20 +- .../legislation/processes/index.html.erb | 4 + app/views/admin/proposals/index.html.erb | 6 +- .../admin/shared/_debate_search.html.erb | 10 + 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 | 32 ++ config/locales/en/download.yml | 170 +++++++++ config/locales/en/general.yml | 8 + config/locales/es/admin.yml | 31 ++ config/locales/es/download.yml | 170 +++++++++ config/locales/es/general.yml | 8 + config/routes/admin.rb | 6 + ...20190312100543_create_download_settings.rb | 13 + ...1144328_add_config_to_download_settings.rb | 8 + db/schema.rb | 10 + .../features/admin/budget_investments_spec.rb | 14 +- spec/features/admin/debates_spec.rb | 8 + spec/features/admin/download_settings_spec.rb | 328 ++++++++++++++++++ spec/features/admin/proposals_spec.rb | 2 +- .../information_texts_spec.rb | 4 +- spec/features/budgets/results_spec.rb | 2 +- spec/features/proposals_spec.rb | 2 +- 63 files changed, 1528 insertions(+), 40 deletions(-) create mode 100644 app/assets/javascripts/modal_download.js.coffee create mode 100644 app/controllers/admin/comments_controller.rb create mode 100644 app/controllers/admin/debates_controller.rb create mode 100644 app/controllers/admin/download_settings_controller.rb create mode 100644 app/helpers/download_settings_helper.rb create mode 100644 app/models/concerns/download_settings/budget_investment_csv.rb create mode 100644 app/models/concerns/download_settings/comment_csv.rb create mode 100644 app/models/concerns/download_settings/debate_csv.rb create mode 100644 app/models/concerns/download_settings/legislation_process_csv.rb create mode 100644 app/models/concerns/download_settings/proposal_csv.rb create mode 100644 app/models/download_setting.rb create mode 100644 app/views/admin/comments/index.html.erb create mode 100644 app/views/admin/debates/index.html.erb create mode 100644 app/views/admin/debates/show.html.erb create mode 100644 app/views/admin/download_settings/_form.html.erb create mode 100644 app/views/admin/download_settings/_form_hidden_params.html.erb create mode 100644 app/views/admin/download_settings/_modal.html.erb create mode 100644 app/views/admin/download_settings/edit.html.erb create mode 100644 app/views/admin/shared/_debate_search.html.erb create mode 100644 app/views/shared/_download_links.html.erb create mode 100644 config/locales/en/download.yml create mode 100644 config/locales/es/download.yml create mode 100644 db/migrate/20190312100543_create_download_settings.rb create mode 100644 db/migrate/20190321144328_add_config_to_download_settings.rb create mode 100644 spec/features/admin/download_settings_spec.rb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 1efdc69b7..5265a7ece 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -82,6 +82,7 @@ //= require managers //= require globalize //= require send_admin_notification_alert +//= require modal_download //= require settings var initialize_modules = function() { @@ -130,6 +131,7 @@ var initialize_modules = function() { App.Managers.initialize(); App.Globalize.initialize(); App.SendAdminNotificationAlert.initialize(); + App.ModalDownload.initialize(); App.Settings.initialize(); }; diff --git a/app/assets/javascripts/modal_download.js.coffee b/app/assets/javascripts/modal_download.js.coffee new file mode 100644 index 000000000..b4cad86dc --- /dev/null +++ b/app/assets/javascripts/modal_download.js.coffee @@ -0,0 +1,9 @@ +App.ModalDownload = + + enableButton: -> + $("#js-download-modal-submit").attr("disabled", false) + $("#js-download-modal-submit").removeClass('disabled') + + initialize: -> + $("#js-download-modal-submit").on "click", -> + setTimeout(App.ModalDownload.enableButton, 2000) diff --git a/app/controllers/admin/budget_investments_controller.rb b/app/controllers/admin/budget_investments_controller.rb index d036e8006..73a19dc7a 100644 --- a/app/controllers/admin/budget_investments_controller.rb +++ b/app/controllers/admin/budget_investments_controller.rb @@ -1,6 +1,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController include FeatureFlags include CommentableActions + include DownloadSettingsHelper feature_flag :budgets @@ -18,7 +19,9 @@ class Admin::BudgetInvestmentsController < Admin::BaseController format.html format.js format.csv do - send_data Budget::Investment::Exporter.new(@investments).to_csv, + send_data to_csv(@investments, Budget::Investment), + type: "text/csv", + disposition: "attachment", filename: "budget_investments.csv" end end diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb new file mode 100644 index 000000000..06c20711a --- /dev/null +++ b/app/controllers/admin/comments_controller.rb @@ -0,0 +1,17 @@ +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 {send_data to_csv(Comment.sort_by_newest, Comment), + type: "text/csv", + disposition: "attachment", + filename: "comments.csv" } + end + end + +end diff --git a/app/controllers/admin/debates_controller.rb b/app/controllers/admin/debates_controller.rb new file mode 100644 index 000000000..44ac33926 --- /dev/null +++ b/app/controllers/admin/debates_controller.rb @@ -0,0 +1,20 @@ +class Admin::DebatesController < Admin::BaseController + include FeatureFlags + include CommentableActions + include HasOrders + + feature_flag :debates + + has_orders %w[created_at] + + def show + @debate = Debate.find(params[:id]) + end + + private + + def resource_model + Debate + end + +end diff --git a/app/controllers/admin/download_settings_controller.rb b/app/controllers/admin/download_settings_controller.rb new file mode 100644 index 000000000..2c8b50789 --- /dev/null +++ b/app/controllers/admin/download_settings_controller.rb @@ -0,0 +1,43 @@ +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 f0b9c6de3..053017644 100644 --- a/app/controllers/admin/legislation/processes_controller.rb +++ b/app/controllers/admin/legislation/processes_controller.rb @@ -1,6 +1,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseController include Translatable include ImageAttributes + include DownloadSettingsHelper has_filters %w[active all], only: :index @@ -9,6 +10,13 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll def index @processes = ::Legislation::Process.send(@current_filter).order(start_date: :desc) .page(params[:page]) + respond_to do |format| + format.html + format.csv {send_data to_csv(process_for_download, Legislation::Process), + type: "text/csv", + disposition: "attachment", + filename: "legislation_processes.csv" } + end end def create @@ -43,6 +51,10 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll private + def process_for_download + ::Legislation::Process.send(@current_filter).order(start_date: :desc) + end + def process_params params.require(:legislation_process).permit(allowed_params) end diff --git a/app/controllers/admin/proposals_controller.rb b/app/controllers/admin/proposals_controller.rb index 7e53d1a46..f764761c6 100644 --- a/app/controllers/admin/proposals_controller.rb +++ b/app/controllers/admin/proposals_controller.rb @@ -3,6 +3,7 @@ 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 63f74717e..05ea96fcf 100644 --- a/app/controllers/budgets/executions_controller.rb +++ b/app/controllers/budgets/executions_controller.rb @@ -1,5 +1,6 @@ module Budgets class ExecutionsController < ApplicationController + include DownloadSettingsHelper before_action :load_budget load_and_authorize_resource :budget @@ -8,6 +9,19 @@ 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 { send_data to_csv(downloadables, + Budget::Investment, + 1), + type: "text/csv", + disposition: "attachment", + filename: "budget_investment_milestones.csv" } + end end private diff --git a/app/controllers/budgets/results_controller.rb b/app/controllers/budgets/results_controller.rb index f8d54c2a2..982f76439 100644 --- a/app/controllers/budgets/results_controller.rb +++ b/app/controllers/budgets/results_controller.rb @@ -2,6 +2,7 @@ module Budgets class ResultsController < ApplicationController before_action :load_budget before_action :load_heading + include DownloadSettingsHelper load_and_authorize_resource :budget @@ -9,6 +10,14 @@ 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 { send_data to_csv(@investments.compatible, Budget::Investment), + type: "text/csv", + disposition: "attachment", + filename: "budget_investment_results.csv" } + end end private diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index aa1a40fc3..66e2456de 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -2,6 +2,7 @@ module CommentableActions extend ActiveSupport::Concern include Polymorphic include Search + include DownloadSettingsHelper def index @resources = resource_model.all @@ -10,6 +11,7 @@ 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}") @@ -21,6 +23,13 @@ module CommentableActions set_resource_votes(@resources) set_resources_instance + respond_to do |format| + format.html + format.csv {send_data to_csv(resources_csv, resource_model), + type: "text/csv", + disposition: "attachment", + filename: "#{get_resource(resource_model)}.csv" } + end end def show diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb index 1d9f32c5f..c950cabf5 100644 --- a/app/controllers/legislation/processes_controller.rb +++ b/app/controllers/legislation/processes_controller.rb @@ -1,5 +1,6 @@ class Legislation::ProcessesController < Legislation::BaseController include RandomSeed + include DownloadSettingsHelper has_filters %w[open past], only: :index has_filters %w[random winners], only: :proposals @@ -12,6 +13,14 @@ 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 { send_data to_csv(process_for_download, Legislation::Process), + type: "text/csv", + disposition: "attachment", + filename: "legislation_processes.csv" } + end end def show @@ -122,6 +131,10 @@ 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 new file mode 100644 index 000000000..535c81824 --- /dev/null +++ b/app/helpers/download_settings_helper.rb @@ -0,0 +1,47 @@ +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 c0e723fff..9e75e798a 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -97,6 +97,8 @@ module Abilities can [:deliver], Newsletter, hidden_at: nil can [:manage], Dashboard::AdministratorTask + + can [:edit, :update], DownloadSetting end end end diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index d078437bb..c6ae03a00 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -1,4 +1,5 @@ class Budget + require "csv" class Investment < ApplicationRecord SORTING_OPTIONS = {id: "id", title: "title", supports: "cached_votes_up"}.freeze @@ -39,6 +40,9 @@ class Budget has_many :comments, -> {where(valuation: false)}, as: :commentable, class_name: "Comment" has_many :valuations, -> {where(valuation: true)}, as: :commentable, class_name: "Comment" + extend DownloadSettings::BudgetInvestmentCsv + delegate :name, :email, to: :author, prefix: true + validates :title, presence: true validates :author, presence: true validates :description, presence: true diff --git a/app/models/comment.rb b/app/models/comment.rb index 9323f9f17..e5b83e818 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,8 +1,11 @@ +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 new file mode 100644 index 000000000..d257a899e --- /dev/null +++ b/app/models/concerns/download_settings/budget_investment_csv.rb @@ -0,0 +1,28 @@ +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 new file mode 100644 index 000000000..2226054a7 --- /dev/null +++ b/app/models/concerns/download_settings/comment_csv.rb @@ -0,0 +1,28 @@ +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 new file mode 100644 index 000000000..79113f54d --- /dev/null +++ b/app/models/concerns/download_settings/debate_csv.rb @@ -0,0 +1,28 @@ +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 new file mode 100644 index 000000000..175c998ce --- /dev/null +++ b/app/models/concerns/download_settings/legislation_process_csv.rb @@ -0,0 +1,28 @@ +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 new file mode 100644 index 000000000..f15b26b82 --- /dev/null +++ b/app/models/concerns/download_settings/proposal_csv.rb @@ -0,0 +1,28 @@ +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 fa4130038..3f1ca7d76 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -1,4 +1,6 @@ require "numeric" +require "csv" + class Debate < ApplicationRecord include Rails.application.routes.url_helpers include Flaggable @@ -22,6 +24,9 @@ class Debate < ApplicationRecord belongs_to :geozone has_many :comments, as: :commentable + extend DownloadSettings::DebateCsv + delegate :name, :email, to: :author, prefix: true + validates :title, presence: true validates :description, presence: true validates :author, presence: true diff --git a/app/models/download_setting.rb b/app/models/download_setting.rb new file mode 100644 index 000000000..76c7f21c5 --- /dev/null +++ b/app/models/download_setting.rb @@ -0,0 +1,18 @@ +class DownloadSetting < ActiveRecord::Base + 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 874af7b6c..3a434409b 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -1,3 +1,5 @@ +require "csv" + class Legislation::Process < ApplicationRecord include ActsAsParanoidAliases include Taggable @@ -15,6 +17,7 @@ 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 people_proposals_phase draft_publication diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 3b4fbd0e2..e0f707918 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -1,3 +1,5 @@ +require "csv" + class Proposal < ApplicationRecord include Rails.application.routes.url_helpers include Flaggable @@ -34,6 +36,12 @@ class Proposal < ApplicationRecord has_many :dashboard_actions, through: :dashboard_executed_actions, class_name: "Dashboard::Action" has_many :polls, as: :related + extend DownloadSettings::ProposalCsv + delegate :name, :email, to: :author, prefix: true + + extend DownloadSettings::ProposalCsv + delegate :name, :email, to: :author, prefix: true + validates :title, presence: true validates :summary, presence: true validates :author, presence: true diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 24911cee6..ac350ae06 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -9,6 +9,22 @@ <% end %> + <% if feature?(:debates) %> +
  • "> + <%= link_to admin_debates_path do %> + + <%= t("admin.menu.debates") %> + <% end %> +
  • + <% end %> + +
  • "> + <%= link_to admin_comments_path do %> + + <%= t("admin.menu.comments") %> + <% end %> +
  • + <% if feature?(:polls) %>
  • "> <%= link_to admin_polls_path do %> @@ -212,6 +228,50 @@ <% 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 9f7f97735..0de8b230d 100644 --- a/app/views/admin/budget_investments/_investments.html.erb +++ b/app/views/admin/budget_investments/_investments.html.erb @@ -1,6 +1,4 @@ -<%= link_to t("admin.budget_investments.index.download_current_selection"), - admin_budget_budget_investments_path(csv_params), - class: "float-right small clear" %> +<%= t("admin.budget_investments.index.download_current_selection") %> <% if params[:advanced_filters].include?("winners") %> @@ -62,3 +60,5 @@ <%= 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 new file mode 100644 index 000000000..991e2e054 --- /dev/null +++ b/app/views/admin/comments/index.html.erb @@ -0,0 +1,49 @@ +<% provide(:title) do %> + <%= t("admin.header.title") %> - <%= t("admin.comments.index.title") %> +<% end %> + +

    <%= t("admin.comments.index.title") %>

    + +<% if @comments.any? %> + +

    <%= page_entries_info @comments %>

    + + <%= t("admin.comments.index.link") %> + + + + + + + + + + + + + <% @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") %>
    <%= 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 %> +
    + + <%= paginate @comments %> +<% else %> +
    + <%= 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 new file mode 100644 index 000000000..3e42821e0 --- /dev/null +++ b/app/views/admin/debates/index.html.erb @@ -0,0 +1,38 @@ +<% provide(:title) do %> + <%= t("admin.header.title") %> - <%= t("admin.debates.index.title") %> +<% end %> + +

    <%= t("admin.debates.index.title") %>

    + +<% if @debates.any? %> + <%= render "/admin/shared/debate_search", url: admin_debates_path %> + +

    <%= page_entries_info @debates %>

    + + <%= t("admin.debates.index.link") %> + + + + + + + + + <% @debates.each do |debate| %> + + + + + + <% end %> + +
    <%= 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 %>
    + + <%= paginate @debates %> +<% else %> +
    + <%= t("admin.debates.index.no_debates") %> +
    +<% end %> + +<%= render "admin/download_settings/modal", resource: { name: "debates" } %> diff --git a/app/views/admin/debates/show.html.erb b/app/views/admin/debates/show.html.erb new file mode 100644 index 000000000..af37f7bf3 --- /dev/null +++ b/app/views/admin/debates/show.html.erb @@ -0,0 +1,56 @@ +<% provide :title do %> + <%= t("admin.header.title") %> - <%= t("admin.menu.debates") %> - <%= @debate.title %> +<% end %> + +
    +

    <%= @debate.title %>

    + + <% if @debate.conflictive? %> +
    + <%= t("debates.show.flag") %> +
    + <% end %> + +
    + <%= render '/shared/author_info', resource: @debate %> + +  •  + <%= l @debate.created_at.to_date %> +  •  +   + <%= link_to t("debates.show.comments", count: @debate.comments_count), "#comments" %> +  •  + + <%= render 'debates/flag_actions', debate: @debate %> + +
    + + <%= safe_html_with_links @debate.description %> + +

    <%= t("votes.supports") %>

    + + + <%= t("debates.debate.votes", count: @debate.votes_score) %> + + +  •  + +
    + + <%= t('votes.agree') %> + + <%= votes_percentage('likes', @debate) %> +
    + +  •  + +
    + + <%= t('votes.disagree') %> + + <%= votes_percentage('dislikes', @debate) %> +
    + +
    + +<%= render 'shared/tags', taggable: @debate %> diff --git a/app/views/admin/download_settings/_form.html.erb b/app/views/admin/download_settings/_form.html.erb new file mode 100644 index 000000000..b7beb497a --- /dev/null +++ b/app/views/admin/download_settings/_form.html.erb @@ -0,0 +1,19 @@ + + + + + + + + + + + <% 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 new file mode 100644 index 000000000..a04aaba35 --- /dev/null +++ b/app/views/admin/download_settings/_form_hidden_params.html.erb @@ -0,0 +1,30 @@ +<% 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 new file mode 100644 index 000000000..d66a2e186 --- /dev/null +++ b/app/views/admin/download_settings/_modal.html.erb @@ -0,0 +1,13 @@ +
    +

    <%= 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 new file mode 100644 index 000000000..43485871f --- /dev/null +++ b/app/views/admin/download_settings/edit.html.erb @@ -0,0 +1,16 @@ +<% 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 28cabbcb5..8500dce58 100644 --- a/app/views/admin/hidden_comments/index.html.erb +++ b/app/views/admin/hidden_comments/index.html.erb @@ -9,8 +9,8 @@ - - + + <% @comments.each do |comment| %> @@ -25,15 +25,15 @@ diff --git a/app/views/admin/hidden_debates/index.html.erb b/app/views/admin/hidden_debates/index.html.erb index a11e821d9..92bb70c8c 100644 --- a/app/views/admin/hidden_debates/index.html.erb +++ b/app/views/admin/hidden_debates/index.html.erb @@ -9,9 +9,9 @@
    <%= t("admin.shared.description") %><%= t("admin.shared.actions") %><%= t("admin.shared.description") %><%= t("admin.shared.actions") %>
    <%= link_to t("admin.actions.restore"), - restore_admin_hidden_comment_path(comment, request.query_parameters), - method: :put, - data: { confirm: t("admin.actions.confirm") }, - class: "button hollow warning" %> + restore_admin_hidden_comment_path(comment, request.query_parameters), + method: :put, + data: { confirm: t("admin.actions.confirm") }, + class: "button hollow warning" %> <% unless comment.confirmed_hide? %> <%= link_to t("admin.actions.confirm_hide"), - confirm_hide_admin_hidden_comment_path(comment, request.query_parameters), - method: :put, - class: "button" %> + confirm_hide_admin_hidden_comment_path(comment, request.query_parameters), + method: :put, + class: "button" %> <% end %>
    - - - + + + <% @debates.each do |debate| %> @@ -26,15 +26,15 @@ diff --git a/app/views/admin/legislation/processes/index.html.erb b/app/views/admin/legislation/processes/index.html.erb index 5e2a647c3..92d96bc9b 100644 --- a/app/views/admin/legislation/processes/index.html.erb +++ b/app/views/admin/legislation/processes/index.html.erb @@ -12,6 +12,8 @@ <% 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") %>
    <%= link_to t("admin.actions.restore"), - restore_admin_hidden_debate_path(debate, request.query_parameters), - method: :put, - data: { confirm: t("admin.actions.confirm") }, - class: "button hollow warning" %> + restore_admin_hidden_debate_path(debate, request.query_parameters), + method: :put, + data: { confirm: t("admin.actions.confirm") }, + class: "button hollow warning" %> <% unless debate.confirmed_hide? %> <%= link_to t("admin.actions.confirm_hide"), - confirm_hide_admin_hidden_debate_path(debate, request.query_parameters), - method: :put, - class: "button" %> + confirm_hide_admin_hidden_debate_path(debate, request.query_parameters), + method: :put, + class: "button" %> <% end %>
    @@ -50,3 +52,5 @@ <%= 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 bc59de812..9967b60ce 100644 --- a/app/views/admin/proposals/index.html.erb +++ b/app/views/admin/proposals/index.html.erb @@ -7,7 +7,9 @@ <% if @proposals.any? %> <%= render "/admin/shared/proposal_search", url: admin_proposals_path %> -

    <%= page_entries_info @proposals %>

    +

    <%= page_entries_info @proposals %>

    + + <%= t("admin.proposals.index.link") %>
    @@ -39,3 +41,5 @@ <%= t("admin.proposals.index.no_proposals") %> <% end %> + +<%= render "admin/download_settings/modal", resource: { name: "proposals" } %> diff --git a/app/views/admin/shared/_debate_search.html.erb b/app/views/admin/shared/_debate_search.html.erb new file mode 100644 index 000000000..42c9938d0 --- /dev/null +++ b/app/views/admin/shared/_debate_search.html.erb @@ -0,0 +1,10 @@ +<%= form_for(Debate.new, url: url, as: :debate, method: :get) do |f| %> +
    +
    + <%= text_field_tag :search, "", placeholder: t("admin.shared.debate_search.placeholder") %> +
    + <%= f.submit t("admin.shared.debate_search.button"), class: "button" %> +
    +
    +
    +<% end %> diff --git a/app/views/budgets/executions/show.html.erb b/app/views/budgets/executions/show.html.erb index f9410fdc8..1dfb67936 100644 --- a/app/views/budgets/executions/show.html.erb +++ b/app/views/budgets/executions/show.html.erb @@ -42,6 +42,10 @@
    + + <%= 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 6a8829437..9d11bde19 100644 --- a/app/views/budgets/results/show.html.erb +++ b/app/views/budgets/results/show.html.erb @@ -48,6 +48,9 @@ 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 7895a9c2a..9a93e95eb 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -98,6 +98,7 @@
    diff --git a/app/views/legislation/processes/index.html.erb b/app/views/legislation/processes/index.html.erb index 72a54aa69..bae92b596 100644 --- a/app/views/legislation/processes/index.html.erb +++ b/app/views/legislation/processes/index.html.erb @@ -25,6 +25,14 @@

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

    + + +
    + + +
    diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index cdb5f8465..6534224b6 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -139,6 +139,7 @@ <% 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 new file mode 100644 index 000000000..a084b7211 --- /dev/null +++ b/app/views/shared/_download_links.html.erb @@ -0,0 +1,4 @@ + + + +

    <%= 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 321686723..6251cd002 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -46,6 +46,7 @@ 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 @@ -189,6 +190,7 @@ ignore_unused: - "legislation.processes.proposals.filters.*" - "helpers.page_entries_info.*" # kaminari - "views.pagination.*" # kaminari + - "shared.download.*" - "shared.suggest.*" - "invisible_captcha.*" - "admin.site_customization.pages.page.status_*" diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index fd472c7f1..34d0091a1 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -357,6 +357,16 @@ en: notice: "Progress bar updated successfully" delete: notice: "Progress bar deleted successfully" + comments: + index: + id: "ID" + content: "Content" + author: "Author" + commentable_type: "Type" + link: "Download comments" + title: Comments + no_comments: There is no comments. + table_link: "Link" hidden_comments: index: filter: Filter @@ -432,6 +442,13 @@ en: request: Requested resource update: success: The task has been marked as solved. + debates: + index: + id: ID + author: Author + title: Debates + no_debates: There is no debates. + link: "Download debates" hidden_debates: index: filter: Filter @@ -522,6 +539,7 @@ en: filters: active: Active all: All + link: "Download legislation process" new: back: Back title: Create new collaborative legislation process @@ -725,6 +743,16 @@ 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" administrators: index: title: Administrators @@ -1240,6 +1268,7 @@ 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: @@ -1309,6 +1338,9 @@ en: proposal_search: button: Search placeholder: Search proposals by title, code, description or question + debate_search: + button: Search + placeholder: Search debates by title or description user_search: button: Search placeholder: Search user by name or email diff --git a/config/locales/en/download.yml b/config/locales/en/download.yml new file mode 100644 index 000000000..d768aa7e7 --- /dev/null +++ b/config/locales/en/download.yml @@ -0,0 +1,170 @@ +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 5bb51982d..c52270d3c 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -794,6 +794,14 @@ 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" social: facebook: "%{org} Facebook" twitter: "%{org} Twitter" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 907fc15c7..248c2c98e 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -357,6 +357,18 @@ es: notice: "Barra de progreso actualizada" delete: notice: "Barra de progreso eliminada correctamente" + comments: + index: + id: "ID" + content: "Contenido" + author: "Autor" + commentable_type: "Tipo" + link: "Descargar comentarios" + title: Comentarios + no_comments: No hay comentarios. + hidden_debate: Debate oculto + hidden_proposal: Propuesta oculta + table_link: "Link" hidden_comments: index: filter: Filtro @@ -432,6 +444,13 @@ es: request: Recurso solicitado update: success: La tarea ha sido marcada como resuelta + debates: + index: + id: ID + author: Autor + title: Debates + no_debates: No hay debates. + link: "Descargar debates" hidden_debates: index: filter: Filtro @@ -522,6 +541,7 @@ es: filters: active: Activos all: Todos + link: "Descargar procesos legislativos" new: back: Volver title: Crear nuevo proceso de legislación colaborativa @@ -724,6 +744,16 @@ 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" administrators: index: title: Administradores @@ -1239,6 +1269,7 @@ 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 new file mode 100644 index 000000000..e05aa5f76 --- /dev/null +++ b/config/locales/es/download.yml @@ -0,0 +1,170 @@ +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 52994ae87..ec52caa54 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -792,6 +792,14 @@ 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" social: facebook: "Facebook de %{org}" twitter: "Twitter de %{org}" diff --git a/config/routes/admin.rb b/config/routes/admin.rb index be819f243..557e13a11 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -29,6 +29,8 @@ namespace :admin do end end + resources :debates, only: [:index, :show] + resources :proposals, only: [:index, :show, :update] do member { patch :toggle_selection } resources :milestones, controller: "proposal_milestones" @@ -82,6 +84,8 @@ namespace :admin do end end + resources :comments, only: :index + resources :tags, only: [:index, :create, :update, :destroy] resources :officials, only: [:index, :edit, :update, :destroy] do @@ -241,4 +245,6 @@ namespace :admin do resources :actions, only: [:index, :new, :create, :edit, :update, :destroy] 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' end diff --git a/db/migrate/20190312100543_create_download_settings.rb b/db/migrate/20190312100543_create_download_settings.rb new file mode 100644 index 000000000..ab28b09df --- /dev/null +++ b/db/migrate/20190312100543_create_download_settings.rb @@ -0,0 +1,13 @@ +class CreateDownloadSettings < ActiveRecord::Migration + def change + create_table :download_settings do |t| + t.string :name_model, null: false + t.string :name_field, null: false + t.boolean :downloadable, null: false, default: false + + t.timestamps null: false + end + + add_index :download_settings, [:name_model, :name_field], unique: true + end +end diff --git a/db/migrate/20190321144328_add_config_to_download_settings.rb b/db/migrate/20190321144328_add_config_to_download_settings.rb new file mode 100644 index 000000000..61fddcef3 --- /dev/null +++ b/db/migrate/20190321144328_add_config_to_download_settings.rb @@ -0,0 +1,8 @@ +class AddConfigToDownloadSettings < ActiveRecord::Migration + def change + add_column :download_settings, :config, :integer, default: 0, null: false + + remove_index :download_settings, name: "index_download_settings_on_name_model_and_name_field" + add_index :download_settings, [:name_model, :name_field, :config], unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index fed6d8263..1426492a2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -512,6 +512,16 @@ ActiveRecord::Schema.define(version: 20190607160900) 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 8e870fa5a..73253cf0b 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -1708,20 +1708,11 @@ describe "Admin budget investments" do visit admin_budget_budget_investments_path(budget) - click_link "Download current selection" + click_button "Download" 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 @@ -1733,7 +1724,8 @@ describe "Admin budget investments" do check "Valuation finished" click_button "Filter" - click_link "Download current selection" + find(:css, "#downloadable_[value='title']").set(true) + click_button "Download" expect(page).to have_content("Finished Investment") expect(page).not_to have_content("Unfeasible one") diff --git a/spec/features/admin/debates_spec.rb b/spec/features/admin/debates_spec.rb index 2b3e683c0..783edf6b8 100644 --- a/spec/features/admin/debates_spec.rb +++ b/spec/features/admin/debates_spec.rb @@ -17,6 +17,14 @@ describe "Admin debates" do login_as(admin.user) end + scenario "Show debate" do + debate = create(:debate) + visit admin_debate_path(debate) + + expect(page).to have_content(debate.title) + expect(page).to have_content(debate.description) + end + scenario "Restore" do debate = create(:debate, :hidden) visit admin_hidden_debates_path diff --git a/spec/features/admin/download_settings_spec.rb b/spec/features/admin/download_settings_spec.rb new file mode 100644 index 000000000..7891db1ee --- /dev/null +++ b/spec/features/admin/download_settings_spec.rb @@ -0,0 +1,328 @@ +require "rails_helper" + +feature "Admin download settings" do + + background 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 + + background 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 + + background 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 + + background 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, phase: "finished") } + let(:group) { create(:budget_group, budget: budget_finished) } + let(:heading) { create(:budget_heading, group: group, price: 1000) } + + let(:investment1) { create(:budget_investment, + :selected, + heading: heading, + price: 200, + ballot_lines_count: 900) } + let(:investment2) { create(:budget_investment, + :selected, + heading: heading, + price: 300, + ballot_lines_count: 800) } + let(:investment3) { create(:budget_investment, + :incompatible, + heading: heading, + price: 500, + ballot_lines_count: 700) } + let(:investment4) { create(:budget_investment, + :selected, + heading: heading, + price: 600, + ballot_lines_count: 600) } + let(:budget) {create :budget} + + background 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 7377ca7d2..173710572 100644 --- a/spec/features/admin/proposals_spec.rb +++ b/spec/features/admin/proposals_spec.rb @@ -16,7 +16,7 @@ describe "Admin proposals" do create(:proposal, title: "Build a monument to honour CONSUL developers") visit admin_root_path - within("#side_menu") { click_link "Proposals" } + within("#side_menu") { first(:link, "Proposals").click } expect(page).to have_content "Make Pluto a planet again" expect(page).to have_content "Build a monument" diff --git a/spec/features/admin/site_customization/information_texts_spec.rb b/spec/features/admin/site_customization/information_texts_spec.rb index f561c909a..dba000a4e 100644 --- a/spec/features/admin/site_customization/information_texts_spec.rb +++ b/spec/features/admin/site_customization/information_texts_spec.rb @@ -22,10 +22,10 @@ describe "Admin custom information texts" do expect(page).to have_content "Help about collaborative legislation" expect(page).to have_content "Help with participatory budgets" - click_link "Debates" + within("#information-texts-tabs") { click_link "Debates" } expect(page).to have_content "Help about debates" - click_link "Community" + within("#information-texts-tabs") { click_link "Community" } expect(page).to have_content "Access the community" within("#information-texts-tabs") { click_link "Proposals" } diff --git a/spec/features/budgets/results_spec.rb b/spec/features/budgets/results_spec.rb index 5b9277d56..7c125c2fa 100644 --- a/spec/features/budgets/results_spec.rb +++ b/spec/features/budgets/results_spec.rb @@ -83,7 +83,7 @@ describe "Results" do end scenario "Loads budget and heading by slug" do - visit budget_results_path(budget.slug, heading.slug) + visit budget_results_path(budget.slug, heading_id: heading.slug) expect(page).to have_selector("a.is-active", text: heading.name) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index ea79c8768..5c095d56a 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -107,7 +107,7 @@ describe "Proposals" do proposal_with_image = create(:proposal) image = create(:image, imageable: proposal_with_image) - visit proposals_path(proposal) + visit proposals_path(id: proposal) within("#proposal_#{proposal.id}") do expect(page).not_to have_css("div.with-image")