Merge pull request #3740 from consul/remove_obsolete_code

Remove leftover code
This commit is contained in:
Javier Martín
2019-10-05 04:11:58 +02:00
committed by GitHub
32 changed files with 60 additions and 135 deletions

View File

@@ -4,12 +4,12 @@ class Admin::TagsController < Admin::BaseController
respond_to :html, :js
def index
@tags = ActsAsTaggableOn::Tag.category.page(params[:page])
@tag = ActsAsTaggableOn::Tag.category.new
@tags = Tag.category.page(params[:page])
@tag = Tag.category.new
end
def create
ActsAsTaggableOn::Tag.category.create(tag_params)
Tag.category.create(tag_params)
redirect_to admin_tags_path
end
@@ -25,7 +25,7 @@ class Admin::TagsController < Admin::BaseController
end
def find_tag
@tag = ActsAsTaggableOn::Tag.category.find(params[:id])
@tag = Tag.category.find(params[:id])
end
end

View File

@@ -64,7 +64,7 @@ module Budgets
end
def load_categories
@categories = ActsAsTaggableOn::Tag.category.order(:name)
@categories = Tag.category.order(:name)
end
def load_ballot_referer

View File

@@ -17,7 +17,6 @@ module Budgets
load_and_authorize_resource :investment, through: :budget, class: "Budget::Investment",
except: :json_data
before_action -> { flash.now[:notice] = flash[:notice].html_safe if flash[:html_safe] && flash[:notice] }
before_action :load_ballot, only: [:index, :show]
before_action :load_heading, only: [:index, :show]
before_action :set_random_seed, only: :index
@@ -147,7 +146,7 @@ module Budgets
end
def load_categories
@categories = ActsAsTaggableOn::Tag.category.order(:name)
@categories = Tag.category.order(:name)
end
def load_content_blocks

View File

@@ -110,12 +110,12 @@ module CommentableActions
end
def load_categories
@categories = ActsAsTaggableOn::Tag.category.order(:name)
@categories = Tag.category.order(:name)
end
def parse_tag_filter
if params[:tag].present?
@tag_filter = params[:tag] if ActsAsTaggableOn::Tag.named(params[:tag]).exists?
@tag_filter = params[:tag] if Tag.named(params[:tag]).exists?
end
end

View File

@@ -67,7 +67,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController
end
def load_categories
@categories = ActsAsTaggableOn::Tag.category.order(:name)
@categories = Tag.category.order(:name)
end
end

View File

@@ -1,45 +0,0 @@
class SandboxController < ApplicationController
skip_authorization_check
layout :set_layout
helper_method(:namespace)
def index
@templates = Dir.glob(Rails.root.join("app", "views", "sandbox", "*.html.erb").to_s).map do |filename|
filename = File.basename(filename, File.extname(filename))
filename unless filename.starts_with?("_") || filename == "index.html"
end.compact
end
def show
if params[:template].index(".") # CVE-2014-0130
render action: "index"
elsif lookup_context.exists?("sandbox/#{params[:template]}")
if params[:template] == "index"
render action: "index"
else
render "sandbox/#{params[:template]}"
end
elsif lookup_context.exists?("sandbox/#{params[:template]}/index")
render "sandbox/#{params[:template]}/index"
else
render action: "index"
end
end
private
def set_layout
if params[:template] && params[:template].split("_").first == "admin"
"admin"
else
"application"
end
end
def namespace
"admin"
end
end

View File

@@ -1,10 +1,10 @@
class TagsController < ApplicationController
load_and_authorize_resource class: ActsAsTaggableOn::Tag
load_and_authorize_resource
respond_to :json
def suggest
@tags = ActsAsTaggableOn::Tag.search(params[:search]).map(&:name)
@tags = Tag.search(params[:search]).map(&:name)
respond_with @tags
end

View File

@@ -13,21 +13,6 @@ module ValuationHelper
ValuatorGroup.order("name ASC").collect { |g| [g.name, "group_#{g.id}"] }
end
def assigned_valuators_info(valuators)
case valuators.size
when 0
t("valuation.budget_investments.index.no_valuators_assigned")
when 1
"<span title=\"#{t("valuation.budget_investments.index.valuators_assigned", count: 1)}\">".html_safe +
valuators.first.name +
"</span>".html_safe
else
"<span title=\"".html_safe + valuators.map(&:name).join(", ") + "\">".html_safe +
t("valuation.budget_investments.index.valuators_assigned", count: valuators.size) +
"</span>".html_safe
end
end
def explanation_field(field)
simple_format_no_tags_no_sanitize(safe_html_with_links(field.html_safe)) if field.present?
end

View File

@@ -52,7 +52,7 @@ module Abilities
can :suggest, Debate
can :suggest, Proposal
can :suggest, Legislation::Proposal
can :suggest, ActsAsTaggableOn::Tag
can :suggest, Tag
can [:flag, :unflag], Comment
cannot [:flag, :unflag], Comment, user_id: user.id

View File

@@ -156,7 +156,7 @@ class Proposal < ApplicationRecord
def self.for_summary
summary = {}
categories = ActsAsTaggableOn::Tag.category_names.sort
categories = Tag.category_names.sort
geozones = Geozone.names.sort
groups = categories + geozones

View File

@@ -16,7 +16,7 @@ class TagCloud
end
def category_names
ActsAsTaggableOn::Tag.category_names.map(&:downcase)
Tag.category_names.map(&:downcase)
end
def geozone_names

View File

@@ -33,7 +33,7 @@
<div class="small-4 column">
<%= link_to t("admin.admin_notifications.index.edit"),
edit_admin_admin_notification_path(admin_notification),
method: :get, class: "button expanded hollow" %>
class: "button expanded hollow" %>
</div>
<div class="small-4 column">
<%= link_to t("admin.admin_notifications.index.delete"),

View File

@@ -95,7 +95,7 @@
<td>
<%= link_to t("admin.budgets.edit.edit_phase"),
edit_admin_budget_budget_phase_path(@budget, phase),
method: :get, class: "button hollow expanded" %>
class: "button hollow expanded" %>
</td>
</tr>
<% end %>

View File

@@ -25,7 +25,7 @@
<td>
<%= link_to t("admin.statuses.index.edit"),
edit_admin_milestone_status_path(status),
method: :get, class: "button hollow" %>
class: "button hollow" %>
<%= link_to t("admin.statuses.index.delete"),
admin_milestone_status_path(status),
method: :delete, class: "button hollow alert" %>

View File

@@ -31,7 +31,7 @@
<td>
<div class="small-4 column">
<%= link_to t("admin.newsletters.index.edit"), edit_admin_newsletter_path(newsletter),
method: :get, class: "button hollow expanded" %>
class: "button hollow expanded" %>
</div>
<div class="small-4 column">
<%= link_to t("admin.newsletters.index.delete"), admin_newsletter_path(newsletter),

View File

@@ -20,7 +20,7 @@ Debate:
comments: [Comment]
public_author: User
votes_for: [Vote]
tags: ["ActsAsTaggableOn::Tag"]
tags: [Tag]
Proposal:
fields:
id: integer
@@ -42,7 +42,7 @@ Proposal:
proposal_notifications: [ProposalNotification]
public_author: User
votes_for: [Vote]
tags: ["ActsAsTaggableOn::Tag"]
tags: [Tag]
Comment:
fields:
id: integer
@@ -68,7 +68,7 @@ ProposalNotification:
proposal_id: integer
public_created_at: string
proposal: Proposal
ActsAsTaggableOn::Tag:
Tag:
fields:
id: integer
name: string

View File

@@ -27,10 +27,6 @@ en:
assigned_to: "Assigned to %{valuator}"
title: Investment projects
edit: Edit dossier
valuators_assigned:
one: Assigned valuator
other: "%{count} valuators assigned"
no_valuators_assigned: No valuators assigned
table_id: ID
table_title: Title
table_heading_name: Heading name

View File

@@ -27,10 +27,6 @@ es:
assigned_to: "Asignadas a %{valuator}"
title: Proyectos de gasto
edit: Editar informe
valuators_assigned:
one: Evaluador asignado
other: "%{count} evaluadores asignados"
no_valuators_assigned: Sin evaluador
table_id: ID
table_title: Título
table_heading_name: Nombre de la partida

View File

@@ -1,12 +1,6 @@
Rails.application.routes.draw do
mount Ckeditor::Engine => "/ckeditor"
if Rails.env.development? || Rails.env.staging?
get "/sandbox" => "sandbox#index"
get "/sandbox/*template" => "sandbox#show"
end
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
draw :account

View File

@@ -19,7 +19,7 @@ section "Creating Debates" do
end
end
tags = ActsAsTaggableOn::Tag.where(kind: "category")
tags = Tag.where(kind: "category")
30.times do
author = User.all.sample
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"

View File

@@ -3,7 +3,7 @@ section "Creating comment notifications" do
debate = Debate.create!(author: user,
title: Faker::Lorem.sentence(3).truncate(60),
description: "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>",
tag_list: ActsAsTaggableOn::Tag.all.sample(3).join(","),
tag_list: Tag.all.sample(3).join(","),
geozone: Geozone.reorder("RANDOM()").first,
terms_of_service: "1")

View File

@@ -109,7 +109,7 @@ section "Creating Successful Proposals" do
add_image_to proposal
end
tags = ActsAsTaggableOn::Tag.where(kind: "category")
tags = Tag.where(kind: "category")
30.times do
author = User.all.sample
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"

View File

@@ -1,17 +1,17 @@
section "Creating Tags Categories" do
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.associations"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.culture"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.sports"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.social_rights"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.economy"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.employment"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.equity"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.sustainability"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.participation"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.mobility"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.media"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.health"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.transparency"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.security_emergencies"))
ActsAsTaggableOn::Tag.category.create!(name: I18n.t("seeds.categories.environment"))
Tag.category.create!(name: I18n.t("seeds.categories.associations"))
Tag.category.create!(name: I18n.t("seeds.categories.culture"))
Tag.category.create!(name: I18n.t("seeds.categories.sports"))
Tag.category.create!(name: I18n.t("seeds.categories.social_rights"))
Tag.category.create!(name: I18n.t("seeds.categories.economy"))
Tag.category.create!(name: I18n.t("seeds.categories.employment"))
Tag.category.create!(name: I18n.t("seeds.categories.equity"))
Tag.category.create!(name: I18n.t("seeds.categories.sustainability"))
Tag.category.create!(name: I18n.t("seeds.categories.participation"))
Tag.category.create!(name: I18n.t("seeds.categories.mobility"))
Tag.category.create!(name: I18n.t("seeds.categories.media"))
Tag.category.create!(name: I18n.t("seeds.categories.health"))
Tag.category.create!(name: I18n.t("seeds.categories.transparency"))
Tag.category.create!(name: I18n.t("seeds.categories.security_emergencies"))
Tag.category.create!(name: I18n.t("seeds.categories.environment"))
end

View File

@@ -134,7 +134,7 @@ The models are the following:
| `Comment` | Comments on debates, proposals and other comments |
| `Geozone` | Geozones (districts) |
| `ProposalNotification` | Notifications related to proposals |
| `ActsAsTaggableOn::Tag` | Tags on debates and proposals |
| `Tag` | Tags on debates and proposals |
| `Vote` | Information related to votes |
## Examples of queries

View File

@@ -134,7 +134,7 @@ La lista de modelos es la siguiente:
| `Comment` | Comentarios en debates, propuestas y otros comentarios |
| `Geozone` | Geozonas (distritos) |
| `ProposalNotification` | Notificaciones asociadas a propuestas |
| `ActsAsTaggableOn::Tag` | Tags en debates y propuestas |
| `Tag` | Tags en debates y propuestas |
| `Vote` | Información sobre votos |
## Ejemplos de consultas

View File

@@ -1,5 +1,5 @@
FactoryBot.define do
factory :tag, class: "ActsAsTaggableOn::Tag" do
factory :tag do
sequence(:name) { |n| "Tag #{n} name" }
trait :category do

View File

@@ -86,7 +86,7 @@ describe "Admin tags" do
click_button "Create topic"
end
expect(ActsAsTaggableOn::Tag.category.where(name: "wow_category")).to exist
expect(Tag.category.where(name: "wow_category")).to exist
end
end

View File

@@ -8,7 +8,7 @@ describe ActsAsTaggableOn do
let(:debate) { create(:debate) }
it "increases and decreases the tag's custom counters" do
tag = ActsAsTaggableOn::Tag.create(name: "foo")
tag = Tag.create(name: "foo")
expect(tag.debates_count).to eq(0)
expect(tag.proposals_count).to eq(0)
@@ -47,7 +47,7 @@ describe ActsAsTaggableOn do
describe "Tag" do
describe "#recalculate_custom_counter_for" do
it "updates the counters of proposals and debates, taking into account hidden ones" do
tag = ActsAsTaggableOn::Tag.create(name: "foo")
tag = Tag.create(name: "foo")
create(:proposal, tag_list: "foo")
create(:proposal, :hidden, tag_list: "foo")
@@ -73,7 +73,7 @@ describe ActsAsTaggableOn do
proposal.tag_list.add(tag)
proposal.save
expect(ActsAsTaggableOn::Tag.public_for_api).to eq [tag]
expect(Tag.public_for_api).to eq [tag]
end
it "returns tags whose kind is 'category' and have at least one tagging whose taggable is not hidden" do
@@ -82,7 +82,7 @@ describe ActsAsTaggableOn do
proposal.tag_list.add(tag)
proposal.save
expect(ActsAsTaggableOn::Tag.public_for_api).to eq [tag]
expect(Tag.public_for_api).to eq [tag]
end
it "blocks other kinds of tags" do
@@ -91,13 +91,13 @@ describe ActsAsTaggableOn do
proposal.tag_list.add(tag)
proposal.save
expect(ActsAsTaggableOn::Tag.public_for_api).to be_empty
expect(Tag.public_for_api).to be_empty
end
it "blocks tags that don't have at least one tagged element" do
create(:tag)
expect(ActsAsTaggableOn::Tag.public_for_api).to be_empty
expect(Tag.public_for_api).to be_empty
end
it "only permits tags on proposals or debates" do
@@ -117,7 +117,7 @@ describe ActsAsTaggableOn do
budget_investment.save
debate.save
expect(ActsAsTaggableOn::Tag.public_for_api).to match_array([tag_1, tag_3])
expect(Tag.public_for_api).to match_array([tag_1, tag_3])
end
it "blocks tags after its taggings became hidden" do
@@ -126,11 +126,11 @@ describe ActsAsTaggableOn do
proposal.tag_list.add(tag)
proposal.save
expect(ActsAsTaggableOn::Tag.public_for_api).to eq [tag]
expect(Tag.public_for_api).to eq [tag]
proposal.delete
expect(ActsAsTaggableOn::Tag.public_for_api).to be_empty
expect(Tag.public_for_api).to be_empty
end
end
@@ -141,10 +141,10 @@ describe ActsAsTaggableOn do
create(:tag, name: "Salud")
create(:tag, name: "Famosos")
expect(ActsAsTaggableOn::Tag.pg_search("f").length).to eq(2)
expect(ActsAsTaggableOn::Tag.search("cultura").first.name).to eq("Cultura")
expect(ActsAsTaggableOn::Tag.search("sal").first.name).to eq("Salud")
expect(ActsAsTaggableOn::Tag.search("fami").first.name).to eq("Familia")
expect(Tag.pg_search("f").length).to eq(2)
expect(Tag.search("cultura").first.name).to eq("Cultura")
expect(Tag.search("sal").first.name).to eq("Salud")
expect(Tag.search("fami").first.name).to eq("Familia")
end
end

View File

@@ -5,7 +5,7 @@ describe "Cache flow" do
describe "Tag destroy" do
it "invalidates Debate cache keys" do
debate = create(:debate, tag_list: "Good, Bad")
tag = ActsAsTaggableOn::Tag.find_by(name: "Bad")
tag = Tag.find_by(name: "Bad")
expect { tag.destroy }.to change { debate.reload.cache_key }
end

View File

@@ -521,7 +521,7 @@ describe "Consul Schema" do
it "does not display tags for taggings that are not public" do
create(:proposal, tag_list: "Health")
allow(ActsAsTaggableOn::Tag).to receive(:public_for_api).and_return([])
allow(Tag).to receive(:public_for_api).and_return([])
response = execute("{ tags { edges { node { name } } } }")
received_tags = extract_fields(response, "tags", "name")

View File

@@ -403,7 +403,7 @@ describe Debate do
describe "custom tag counters when hiding/restoring" do
it "decreases the tag counter when hiden, and increases it when restored" do
debate = create(:debate, tag_list: "foo")
tag = ActsAsTaggableOn::Tag.where(name: "foo").first
tag = Tag.where(name: "foo").first
expect(tag.debates_count).to eq(1)
debate.hide

View File

@@ -346,7 +346,7 @@ describe Proposal do
describe "custom tag counters when hiding/restoring" do
it "decreases the tag counter when hiden, and increases it when restored" do
proposal = create(:proposal, tag_list: "foo")
tag = ActsAsTaggableOn::Tag.where(name: "foo").first
tag = Tag.where(name: "foo").first
expect(tag.proposals_count).to eq(1)
proposal.hide