adds valuator tags

This commit is contained in:
rgarcia
2017-01-08 13:24:05 +01:00
parent fd28f6c2b3
commit 3ba57bbab2
6 changed files with 82 additions and 16 deletions

View File

@@ -11,8 +11,6 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
before_action :load_ballot, only: [:show, :index]
before_action :load_investments, only: [:index, :toggle_selection]
def index
end
@@ -26,6 +24,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
end
def update
set_valuation_tags
if @investment.update(budget_investment_params)
redirect_to admin_budget_budget_investment_path(@budget, @investment, Budget::Investment.filter_params(params)),
notice: t("flash.actions.update.budget_investment")
@@ -52,7 +51,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
def budget_investment_params
params.require(:budget_investment)
.permit(:title, :description, :external_url, :heading_id, :administrator_id, :tag_list, valuator_ids: [])
.permit(:title, :description, :external_url, :heading_id, :administrator_id, :valuation_tag_list, valuator_ids: [])
end
def load_budget
@@ -72,11 +71,16 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
end
def load_tags
@tags = ActsAsTaggableOn::Tag.budget_investment_tags
@tags = Budget::Investment.tags_on(:valuation).order(:name).uniq
end
def load_ballot
query = Budget::Ballot.where(user: current_user, budget: @budget)
@ballot = @budget.balloting? ? query.first_or_create : query.first_or_initialize
end
def set_valuation_tags
@investment.set_tag_list_on(:valuation, budget_investment_params[:valuation_tag_list])
params[:budget_investment] = params[:budget_investment].except(:valuation_tag_list)
end
end