Skip to content

Fix users can comment into private assembly#4924

Merged
mrcasals merged 45 commits intomasterfrom
fix_users_can_comment_into_private_assembly
Apr 2, 2019
Merged

Fix users can comment into private assembly#4924
mrcasals merged 45 commits intomasterfrom
fix_users_can_comment_into_private_assembly

Conversation

@isaacmg410
Copy link
Copy Markdown
Contributor

@isaacmg410 isaacmg410 commented Mar 4, 2019

🎩 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

  • Add CHANGELOG entry
  • Add tests

📷 Screenshots (optional)

Description

@mrcasals
Copy link
Copy Markdown
Contributor

mrcasals commented Mar 4, 2019

@isaacmg410 can we close #4893 then?

@isaacmg410
Copy link
Copy Markdown
Contributor Author

@mrcasals yes! I will close now!

@isaacmg410 isaacmg410 changed the title Fix users can comment into private assembly [WIP] Fix users can comment into private assembly Mar 4, 2019
@isaacmg410 isaacmg410 changed the title [WIP] Fix users can comment into private assembly Fix users can comment into private assembly Mar 4, 2019
@isaacmg410 isaacmg410 force-pushed the fix_users_can_comment_into_private_assembly branch from e1ef3b2 to 43ad612 Compare March 4, 2019 14:08
@isaacmg410
Copy link
Copy Markdown
Contributor Author

@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ò?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed.

comments: [],
hasComments: false,
acceptsNewComments: false,
userCanComment: false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrcasals is there any example of what you are saying?

move this to the permissions system and check the permissions in the API.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
end

So, I will extend the functionality using concerns.

@isaacmg410 isaacmg410 force-pushed the fix_users_can_comment_into_private_assembly branch from 43ad612 to dce6215 Compare March 5, 2019 12:06
@isaacmg410
Copy link
Copy Markdown
Contributor Author

@decidim/lot-core de failing specs, are working good in local development. Any idea on how to solve it?

@isaacmg410
Copy link
Copy Markdown
Contributor Author

@mrcasals got it! is this screenshot no? 👏 👏
screenshot-circleci com-2019 03 21-14-29-29

@mrcasals
Copy link
Copy Markdown
Contributor

@isaacmg410 yup!

@isaacmg410
Copy link
Copy Markdown
Contributor Author

@decidim/lot-core ready to review and merge 😄

@isaacmg410
Copy link
Copy Markdown
Contributor Author

Ei @decidim/lot-core all checks are green and no conflicts, can you review it againg, please?

@mrcasals mrcasals self-requested a review April 2, 2019 10:44
@mrcasals mrcasals merged commit 553eed7 into master Apr 2, 2019
@mrcasals mrcasals deleted the fix_users_can_comment_into_private_assembly branch April 2, 2019 10:47
@tramuntanal
Copy link
Copy Markdown
Contributor

👏 👏

armandfardeau added a commit to OpenSourcePolitics/decidim that referenced this pull request May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I can comment as a normal user in a private assembly

3 participants