Fixes all management bi issues except filtering by geozone
This commit is contained in:
@@ -6,8 +6,8 @@ class Management::Budgets::InvestmentsController < Management::BaseController
|
||||
before_action :only_verified_users, except: :print
|
||||
|
||||
def index
|
||||
@investments = apply_filters_and_search(@investments).order(cached_votes_up: :desc).page(params[:page]).for_render
|
||||
@investment_ids = @investments.pluck(:id)
|
||||
@investments = apply_filters_and_search(@investments).page(params[:page])
|
||||
set_investment_votes(@investments)
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -26,10 +26,12 @@ class Management::Budgets::InvestmentsController < Management::BaseController
|
||||
end
|
||||
|
||||
def show
|
||||
set_investment_votes(@investment)
|
||||
end
|
||||
|
||||
def vote
|
||||
@investment.register_vote(managed_user, 'yes')
|
||||
@investment.register_selection(managed_user)
|
||||
set_investment_votes(@investment)
|
||||
end
|
||||
|
||||
def print
|
||||
@@ -39,6 +41,10 @@ class Management::Budgets::InvestmentsController < Management::BaseController
|
||||
|
||||
private
|
||||
|
||||
def set_investment_votes(investments)
|
||||
@investment_votes = managed_user ? managed_user.budget_investment_votes(investments) : {}
|
||||
end
|
||||
|
||||
def load_budget
|
||||
@budget = Budget.find(params[:budget_id])
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class Management::BudgetsController < Management::BaseController
|
||||
end
|
||||
|
||||
def support_investments
|
||||
@budgets = Budget.accepting.order(created_at: :desc).page(params[:page])
|
||||
@budgets = Budget.selecting.order(created_at: :desc).page(params[:page])
|
||||
end
|
||||
|
||||
def print_investments
|
||||
|
||||
@@ -21,6 +21,15 @@ module BudgetsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def namespaced_budget_investment_vote_path(investment, options={})
|
||||
case namespace
|
||||
when "management::budgets"
|
||||
vote_management_budget_investment_path(investment.budget, investment, options)
|
||||
else
|
||||
vote_budget_investment_path(investment.budget, investment, options)
|
||||
end
|
||||
end
|
||||
|
||||
def display_budget_countdown?(budget)
|
||||
budget.balloting?
|
||||
end
|
||||
|
||||
@@ -14,11 +14,14 @@ class Budget < ActiveRecord::Base
|
||||
has_many :groups, dependent: :destroy
|
||||
has_many :headings, through: :groups
|
||||
|
||||
scope :current, -> { where.not(phase: "finished") }
|
||||
scope :finished, -> { where(phase: "finished") }
|
||||
scope :valuating, -> { where(valuating: true) }
|
||||
scope :on_hold, -> { where(phase: "on_hold") }
|
||||
scope :accepting, -> { where(phase: "accepting") }
|
||||
scope :selecting, -> { where(phase: "selecting") }
|
||||
scope :balloting, -> { where(phase: "balloting") }
|
||||
scope :finished, -> { where(phase: "finished") }
|
||||
|
||||
scope :current, -> { where.not(phase: "finished") }
|
||||
scope :valuating, -> { where(valuating: true) }
|
||||
|
||||
def on_hold?
|
||||
phase == "on_hold"
|
||||
|
||||
@@ -190,9 +190,7 @@ class Budget
|
||||
end
|
||||
|
||||
def should_show_aside?
|
||||
(budget.selecting? && !investment.unfeasible?) ||
|
||||
(budget.balloting? && investment.feasible?) ||
|
||||
budget.on_hold?
|
||||
(budget.selecting? && !unfeasible?) || (budget.balloting? && feasible?) || budget.on_hold?
|
||||
end
|
||||
|
||||
def should_show_votes?
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<%= render partial: '/budgets/investments/votes', locals: {
|
||||
investment: investment,
|
||||
investment_votes: investment_votes,
|
||||
vote_url: vote_budget_investment_path(investment.budget, investment, value: 'yes')
|
||||
vote_url: namespaced_budget_investment_vote_path(investment, value: 'yes')
|
||||
} %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
vote_url: vote_budget_investment_path(investment.budget, investment, value: 'yes')
|
||||
} %>
|
||||
</div>
|
||||
<% elseif investment.sould_show_ballots? %>
|
||||
<% elsif investment.should_show_ballots? %>
|
||||
<div id="<%= dom_id(investment) %>_ballot">
|
||||
<%= render 'ballot', investment: investment %>
|
||||
</div>
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
$("#<%= dom_id(@investment) %>_votes").html('<%= j render("budgets/investments/votes", investment: @investment, vote_url: vote_budget_investment_path(@budget, @investment, value: "yes")) %>');
|
||||
$("#<%= dom_id(@investment) %>_votes").html('<%= j render("/budgets/investments/votes",
|
||||
investment: @investment,
|
||||
investment_votes: @budget_investment_votes,
|
||||
vote_url: namespaced_budget_investment_vote_path(@investment, value: 'yes')) %>');
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
|
||||
<%= render '/shared/print' %>
|
||||
|
||||
<%= render partial: '/budgets/investments/investment_show', locals: { investment: @investment, investment_votes: @investment_votes } %>
|
||||
<%= render partial: '/budgets/investments/investment_show', locals: {
|
||||
investment: @investment,
|
||||
investment_votes: @investment_votes
|
||||
} %>
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
<%= render template: 'budgets/investments/vote' %>
|
||||
$("#<%= dom_id(@investment) %>_votes").html('<%= j render("/budgets/investments/votes",
|
||||
investment: @investment,
|
||||
investment_votes: @investment_votes,
|
||||
vote_url: namespaced_budget_investment_vote_path(@investment, value: 'yes')) %>');
|
||||
|
||||
Reference in New Issue
Block a user