Create valuation comments creation ability
Why: Only admins or valuators (for those investments they've assigned) can create internal valuation comments on them. How: * Creating a new `comment_valuation` ability for admins and valuators in the same manner the `valuate` ability works. * Adding a validation at Comment model for those with `valuation` flag active that checks if the author can make a valuation comment on the commentable, as well as the respective active record error messages. This will prevent comments from being created at a controller level as well. * Improving comment factory trait `valuation` to have an associated investment, author that is a valuator and setting the valuator on the valuators list of the investment
This commit is contained in:
@@ -5,8 +5,8 @@ module Abilities
|
||||
def initialize(user)
|
||||
valuator = user.valuator
|
||||
can [:read, :update, :valuate], SpendingProposal
|
||||
can [:read, :update, :valuate], Budget::Investment, id: valuator.investment_ids
|
||||
cannot [:update, :valuate], Budget::Investment, budget: { phase: 'finished' }
|
||||
can [:read, :update, :valuate, :comment_valuation], Budget::Investment, id: valuator.investment_ids
|
||||
cannot [:update, :valuate, :comment_valuation], Budget::Investment, budget: { phase: 'finished' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user