Add calculate_winners on Admin Budget controller, route and ability for admins

This commit is contained in:
Bertocq
2017-06-21 19:39:28 +02:00
parent ee9d3cd7e3
commit 154cdac332
5 changed files with 21 additions and 9 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