diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 969d3689d..bf8fd7574 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -28,6 +28,7 @@ module Budgets @investments = @investments.apply_filters_and_search(@budget, params).send("sort_by_#{@current_order}").page(params[:page]).per(10).for_render @investment_ids = @investments.pluck(:id) load_investment_votes(@investments) + @tag_cloud = tag_cloud end def new @@ -101,6 +102,9 @@ module Budgets @categories = ActsAsTaggableOn::Tag.where("kind = 'category'").order(:name) end + def tag_cloud + TagCloud.new(Budget::Investment, params[:search]) + end end end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index da7824622..36ba8d048 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -6,6 +6,8 @@ module TagsHelper debates_path(search: tag_name) when 'proposal' proposals_path(search: tag_name) + when 'budget/investment' + budget_investments_path(@budget, search: tag_name) else '#' end diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 9575e7ae7..5389825e5 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -46,6 +46,7 @@ class Budget scope :undecided, -> { where(feasibility: "undecided") } scope :with_supports, -> { where('cached_votes_up > 0') } scope :selected, -> { where(selected: true) } + scope :last_week, -> { where("created_at >= ?", 7.days.ago)} scope :by_group, -> (group_id) { where(group_id: group_id) } scope :by_heading, -> (heading_id) { where(heading_id: heading_id) } @@ -106,6 +107,7 @@ class Budget { title => 'A', author.username => 'B', heading.try(:name) => 'B', + tag_list.join(' ') => 'B', description => 'C' } end diff --git a/app/models/tag_cloud.rb b/app/models/tag_cloud.rb index f3ea655f0..107ecbf1a 100644 --- a/app/models/tag_cloud.rb +++ b/app/models/tag_cloud.rb @@ -32,7 +32,7 @@ class TagCloud end def table_name - resource_model.to_s.downcase.pluralize + resource_model.to_s.downcase.pluralize.gsub("::", "/") end end \ No newline at end of file diff --git a/app/views/budgets/investments/_categories.html.erb b/app/views/budgets/investments/_categories.html.erb new file mode 100644 index 000000000..ad628b1b1 --- /dev/null +++ b/app/views/budgets/investments/_categories.html.erb @@ -0,0 +1,11 @@ + + +
+ + \ No newline at end of file diff --git a/app/views/budgets/investments/_investment.html.erb b/app/views/budgets/investments/_investment.html.erb index 87c2f663e..e90801f17 100644 --- a/app/views/budgets/investments/_investment.html.erb +++ b/app/views/budgets/investments/_investment.html.erb @@ -38,6 +38,7 @@

<%= link_to investment.description, namespaced_budget_investment_path(investment) %>

+ <%= render "shared/tags", taggable: investment, limit: 5 %> <% end %> diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index c0816d534..7917889c4 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -35,7 +35,7 @@

<% end %> - <%= render 'shared/tags', taggable: @investment, url: budget_investments_path(@budget) %> + <%= render 'shared/tags', taggable: @investment %> <%= safe_html_with_links investment.description.html_safe %> diff --git a/app/views/budgets/investments/_sidebar.html.erb b/app/views/budgets/investments/_sidebar.html.erb index 173132257..639106934 100644 --- a/app/views/budgets/investments/_sidebar.html.erb +++ b/app/views/budgets/investments/_sidebar.html.erb @@ -9,6 +9,8 @@ verify: link_to(t("budget.investments.index.sidebar.verify_account"), verification_path)).html_safe %> <% end %> + <%= render "shared/tag_cloud", taggable: 'budget/investment' %> + <%= render 'categories' %> <% end %> diff --git a/app/views/shared/_tags.html.erb b/app/views/shared/_tags.html.erb index ddb6fc7f2..950b074b1 100644 --- a/app/views/shared/_tags.html.erb +++ b/app/views/shared/_tags.html.erb @@ -3,7 +3,10 @@ <% if taggable.tags.any? %>