Extract controllers to support investments
Since we're going to add an action to remove supports, having a separate controller makes things easier. Note there was a strange piece of code which assumed users were not verified if they couldn't vote investments. Now the code is also strange, since it assumes users are not verified if they can't create votes. We might need to revisit these conditions if our logic changes in the future.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
class Management::Budgets::Investments::VotesController < Management::BaseController
|
||||
load_resource :budget, find_by: :slug_or_id
|
||||
load_resource :investment, through: :budget, class: "Budget::Investment"
|
||||
|
||||
def create
|
||||
@investment.register_selection(managed_user)
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to management_budget_investments_path(heading_id: @investment.heading.id),
|
||||
notice: t("flash.actions.create.support")
|
||||
end
|
||||
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -38,19 +38,6 @@ class Management::Budgets::InvestmentsController < Management::BaseController
|
||||
def show
|
||||
end
|
||||
|
||||
def vote
|
||||
@investment.register_selection(managed_user)
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to management_budget_investments_path(heading_id: @investment.heading.id),
|
||||
notice: t("flash.actions.create.support")
|
||||
end
|
||||
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def print
|
||||
@investments = @investments.apply_filters_and_search(@budget, params).order(cached_votes_up: :desc).for_render.limit(15)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user