Fix users can comment into private assembly#4924
Conversation
|
@isaacmg410 can we close #4893 then? |
|
@mrcasals yes! I will close now! |
e1ef3b2 to
43ad612
Compare
|
@decidim/lot-core Can you make a first review, please? I know that there are some failing tests,but your review will be helpful |
| * @augments Component | ||
| */ | ||
| /** | ||
| * COm dinamitzo això? |
| comments: [], | ||
| hasComments: false, | ||
| acceptsNewComments: false, | ||
| userCanComment: false, |
There was a problem hiding this comment.
Maybe I'd replace userCanComment with userAllowedToComment, or something similar. Maybe the user cannot comment because comments are not enabled, but "allowed" is tightly bound to permissions (which is what we're checking here)
|
|
||
| # Public: Whether the object can have new comments or not. | ||
| def can_participate?(user) | ||
| can_participate_in_space?(user) |
There was a problem hiding this comment.
What do you think about moving this to the concerns? This way logic can be overwritten by each participatory space. Take into account that this should work for all existing participatory spaces.
# participable.rb
def can_participate?(user)
user.present?
end
# models/assembly.rb
def can_participate?(user)
return true unless participatory_space.private_space?
return false unless user
participatory_space.users.include?(user)
end
# has_component.rb
def can_participate_in_space?(user)
participatory_space.can_participate?(user)
endThere was a problem hiding this comment.
Or even, move this logic to the permissions system, since this is what we're checking here: whether the user has permissions to comment on that space or not. Then you can skip these methods, move this to the permissions system and check the permissions in the API.
There was a problem hiding this comment.
@mrcasals is there any example of what you are saying?
move this to the permissions system and check the permissions in the API.
There was a problem hiding this comment.
also, this two methods already existis in concerns.
# participable.rb
def can_participate?(user)
user.present?
end
# models/assembly.rb
def can_participate?(user)
return true unless participatory_space.private_space?
return false unless user
participatory_space.users.include?(user)
endSo, I will extend the functionality using concerns.
43ad612 to
dce6215
Compare
|
@decidim/lot-core de failing specs, are working good in local development. Any idea on how to solve it? |
|
@mrcasals got it! is this screenshot no? 👏 👏 |
|
@isaacmg410 yup! |
|
@decidim/lot-core ready to review and merge 😄 |
|
Ei @decidim/lot-core all checks are green and no conflicts, can you review it againg, please? |
|
👏 👏 |

🎩 What? Why?
This PR fixes that as a normal user (no private user) I can comment on a private assembly where is available. Meetigns, Proposals, etc.
📌 Related Issues
📋 Subtasks
CHANGELOGentry📷 Screenshots (optional)