Add can_comment and can_edit_dossier abilities to valuators
This commit is contained in:
@@ -65,6 +65,7 @@ module Abilities
|
||||
can [:hide, :update, :toggle_selection], Budget::Investment
|
||||
can [:valuate, :comment_valuation], Budget::Investment
|
||||
can :create, Budget::ValuatorAssignment
|
||||
can [:edit_dossier], Budget::Investment
|
||||
|
||||
can(:read_admin_stats, Budget) { |budget| budget.balloting_or_later? }
|
||||
|
||||
|
||||
@@ -4,10 +4,20 @@ module Abilities
|
||||
|
||||
def initialize(user)
|
||||
valuator = user.valuator
|
||||
assigned_investment_ids = valuator.assigned_investment_ids
|
||||
finished = { phase: "finished" }
|
||||
|
||||
can [:read, :update, :comment_valuation], Budget::Investment, id: valuator.assigned_investment_ids
|
||||
can [:valuate], Budget::Investment, { id: valuator.assigned_investment_ids, valuation_finished: false }
|
||||
cannot [:update, :valuate, :comment_valuation], Budget::Investment, budget: { phase: "finished" }
|
||||
can [:read, :update], Budget::Investment, id: assigned_investment_ids
|
||||
can [:valuate], Budget::Investment, { id: assigned_investment_ids, valuation_finished: false }
|
||||
cannot [:update, :valuate, :comment_valuation], Budget::Investment, budget: finished
|
||||
|
||||
if valuator.can_edit_dossier?
|
||||
can [:edit_dossier], Budget::Investment, id: assigned_investment_ids
|
||||
end
|
||||
|
||||
if valuator.can_comment?
|
||||
can [:comment_valuation], Budget::Investment, id: assigned_investment_ids
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user