Files
nairobi/app/models/abilities/valuator.rb
Bertocq 1ef2789640 Trim valuator investment valuation ability scope
Valuators shouldn't be able to valuate an investment which valuation has
already been finished (only admins can)
2018-03-06 20:18:05 +01:00

14 lines
493 B
Ruby

module Abilities
class Valuator
include CanCan::Ability
def initialize(user)
valuator = user.valuator
can [:read, :update, :valuate], SpendingProposal
can [:read, :update, :comment_valuation], Budget::Investment, id: valuator.investment_ids
can [:valuate], Budget::Investment, { id: valuator.investment_ids, valuation_finished: false }
cannot [:update, :valuate, :comment_valuation], Budget::Investment, budget: { phase: 'finished' }
end
end
end