Don't allow to modify answer's documents for started polls

This commit is contained in:
Julian Herrero
2022-09-05 11:33:13 +02:00
committed by Javi Martín
parent 245594f32b
commit 4c8f247de7
13 changed files with 162 additions and 22 deletions

View File

@@ -124,7 +124,9 @@ module Abilities
cannot :comment_as_moderator, [::Legislation::Question, Legislation::Annotation, ::Legislation::Proposal]
can [:create], Document
can [:destroy], Document, documentable_type: "Poll::Question::Answer"
can [:destroy], Document do |document|
document.documentable_type == "Poll::Question::Answer" && can?(:update, document.documentable)
end
can [:create, :destroy], DirectUpload
can [:deliver], Newsletter, hidden_at: nil

View File

@@ -71,7 +71,7 @@ module Abilities
can [:create, :destroy], Follow, user_id: user.id
can [:destroy], Document do |document|
document.documentable&.author_id == user.id
document.documentable_type != "Poll::Question::Answer" && document.documentable&.author_id == user.id
end
can [:destroy], Image do |image|