Add valuation permissions to groups

This commit is contained in:
rgarcia
2018-02-09 21:52:17 +01:00
parent 1152f95965
commit 7a01745188
3 changed files with 13 additions and 2 deletions

View File

@@ -5,8 +5,8 @@ module Abilities
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 }
can [:read, :update, :comment_valuation], Budget::Investment, id: valuator.investment_ids + valuator.valuator_group.investment_ids
can [:valuate], Budget::Investment, { id: valuator.investment_ids + valuator.valuator_group.investment_ids, valuation_finished: false }
cannot [:update, :valuate, :comment_valuation], Budget::Investment, budget: { phase: 'finished' }
end
end

View File

@@ -1,3 +1,5 @@
class ValuatorGroup < ActiveRecord::Base
has_many :valuators
has_many :valuator_group_assignments, dependent: :destroy, class_name: 'Budget::ValuatorGroupAssignment'
has_many :investments, through: :valuator_group_assignments, class_name: 'Budget::Investment'
end