only creates ballots when budget balloting
This commit is contained in:
@@ -9,7 +9,9 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||
has_filters %w{valuation_open without_admin managed valuating valuation_finished all}, only: :index
|
||||
|
||||
def index
|
||||
@investments = Budget::Investment.scoped_filter(params, @current_filter).order(cached_votes_up: :desc, created_at: :desc).page(params[:page])
|
||||
@investments = Budget::Investment.scoped_filter(params, @current_filter)
|
||||
.order(cached_votes_up: :desc, created_at: :desc)
|
||||
.page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
@@ -36,7 +38,8 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||
private
|
||||
|
||||
def budget_investment_params
|
||||
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :administrator_id, :tag_list, valuator_ids: [])
|
||||
params.require(:budget_investment)
|
||||
.permit(:title, :description, :external_url, :heading_id, :administrator_id, :tag_list, valuator_ids: [])
|
||||
end
|
||||
|
||||
def load_budget
|
||||
@@ -60,8 +63,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def load_ballot
|
||||
if @budget.balloting?
|
||||
@ballot = Budget::Ballot.where(user: current_user, budget: @budget).first_or_create
|
||||
end
|
||||
query = Budget::Ballot.where(user: current_user, budget: @budget)
|
||||
@ballot = @budget.balloting? ? query.first_or_create : query.first_or_initialize
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user