Skip to content

Conversation

@akatsoulas
Copy link
Collaborator

  • Optmize manager and model methods
  • Add tests
  • Add group documentation

Copy link
Contributor

@escattone escattone left a comment

Choose a reason for hiding this comment

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

I'm still confused about the following in terms of visibility:

  • What should happen if isolation is disabled for a private hierarchy?
  • What should happen if isolation is disabled for a moderated hierarchy?
  • Do members/leaders of non-root groups that have child groups see all of those child groups?

Comment on lines 79 to 81
def is_root_node(self):
"""Check if this is a root node using path length."""
return len(self.path) == self.steplen
Copy link
Contributor

Choose a reason for hiding this comment

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

The equivalent of this method is already provided by the MP_Node sub-class as the is_root method.

Comment on lines 134 to 135
root = self.get_root()
if root and root.leaders.filter(pk=user.pk).exists():
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the get_root() method will either return the root node or raise an exception, so I don't think it makes sense to check if root is truthy.

Comment on lines 175 to 180
if self.visibility == self.Visibility.MODERATED:
return self.visible_to_groups.filter(user=user).exists()

if self.visibility == self.Visibility.PRIVATE:
return (self.group.user_set.filter(pk=user.pk).exists() or
self.can_moderate_group(user))
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the isolation_enabled setting affect the return value for these two cases?

Also, it seems like this view isn't handling the cases where the user is a member/leader of an ancestor group of the current group.

It'd be nice to make this more DRY and not repeat the logic of the GroupProfileManager.visible method.

Comment on lines 161 to 162
root = self.get_root()
return root.leaders.filter(pk=user.pk).exists() if root else False
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise here, I don't think it makes sense to check the truthiness of root.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could rewrite the filtering within the visible method without running extra queries, but in the meantime, I have some questions below.

* Optmize manager and model methods
* Add tests
* Add group documentation
@akatsoulas akatsoulas force-pushed the block-sibling-visibility branch from 01c5913 to 03f0f28 Compare January 21, 2026 10:04
Copy link
Contributor

@escattone escattone left a comment

Choose a reason for hiding this comment

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

r+wc


### PRIVATE
- **Who can see**: Depends on `isolation_enabled` setting (default: True)
- **With isolation enabled**: Members/moderators see only their hierarchy (sibling isolation)
Copy link
Contributor

Choose a reason for hiding this comment

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

For me, it would be more clear to say "Members/moderators see only their ancestors and their own subtree (sibling isolation)". What do you think of that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The see both their ancestors and their descendants. Basically their whole branch/hierarchy so I think this is more accurate


root_paths = {p.path[:steplen] for p in all_user_profiles}

root_nodes = self.filter(path__in=root_paths).prefetch_related(
Copy link
Contributor

@escattone escattone Jan 21, 2026

Choose a reason for hiding this comment

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

I don't think the prefetch_related here will help with the is_root_member and is_root_moderator expressions below, because I think the .filter() on each of those querysets will initiate a fresh query?

@escattone escattone merged commit 5a720d6 into mozilla:main Jan 21, 2026
2 checks passed
@akatsoulas akatsoulas deleted the block-sibling-visibility branch January 22, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants