Merge pull request #1678 from consul/feature/1601#budget_winner_investments_button

Add button to Calculate Budget Winner investments
This commit is contained in:
Raimond Garcia
2017-06-26 17:41:08 +02:00
committed by GitHub
11 changed files with 71 additions and 10 deletions

View File

@@ -44,7 +44,7 @@ module Abilities
can [:read, :update, :valuate, :destroy, :summary], SpendingProposal
can [:index, :read, :new, :create, :update, :destroy], Budget
can [:index, :read, :new, :create, :update, :destroy, :calculate_winners], Budget
can [:read, :create, :update, :destroy], Budget::Group
can [:read, :create, :update, :destroy], Budget::Heading
can [:hide, :update, :toggle_selection], Budget::Investment

View File

@@ -67,8 +67,12 @@ class Budget < ActiveRecord::Base
phase == "finished"
end
def balloting_process?
balloting? || reviewing_ballots?
end
def balloting_or_later?
balloting? || reviewing_ballots? || finished?
balloting_process? || finished?
end
def on_hold?

View File

@@ -12,11 +12,10 @@ class Budget
reset_winners
investments.each do |investment|
@current_investment = investment
if inside_budget?
set_winner
end
set_winner if inside_budget?
end
end
handle_asynchronously :calculate_winners
def investments
heading.investments.selected.sort_by_ballots
@@ -52,4 +51,4 @@ class Budget
end
end
end
end