Skip to content

OpenConceptLab/ocl_online#742 | A collection's expansions list holds only versions the requester can view - #1034

Merged
snyaggarwal merged 2 commits into
masterfrom
ocl_online-742-expansions-list-viewable-versions
Nov 23, 2026
Merged

snyaggarwal merged 2 commits into
masterfrom
ocl_online-742-expansions-list-viewable-versions

Conversation

@snyaggarwal

Copy link
Copy Markdown
Contributor

For OpenConceptLab/ocl_online#742. /<owner>/collections/<collection>/expansions/ checked view access on the collection's HEAD, then listed the expansions of every version. So anyone who could view a public HEAD also saw a private release's expansions:

  • with includeSummary=true, their concept and mapping counts;
  • with verbose=true, the source versions they were built from.

What changes

CollectionExpansionsView.get_queryset now keeps only the versions the requester can view. It uses Collection.get_viewable_versions_criteria(user) from #1027, the query form of has_view_access. Owners, org members and staff see no change, and staff get no filter at all.

Tests

A new test in CollectionViewsAPITest puts a public HEAD and a private v1 under one org. Anonymous users and outsiders see only HEAD's expansion; an org member and the admin see both. Without the fix, the test fails with v1's expansion listed. All 33 tests in CollectionViewsAPITest pass locally with Redis unreachable, as in CI, and pylint is clean on the changed files.

🤖 Generated with Claude Code

…only expansions of versions the requester can view

@snyaggarwal snyaggarwal left a comment

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.

Verdict: ready to merge once CI passes. One optional nit on a88eb80.

What I checked:

  • The filter: get_viewable_versions_criteria is the query form of has_view_access from #1027. Staff get None, so no filter, which leaves their view as before.
  • Owners and org members: they match through own, so their HEADs and private versions stay listed.
  • Inactive versions: they now drop out for non-staff, as their own routes already answer 404.
  • The HEAD check: unchanged, so a private HEAD still answers 404 to outsiders.
  • The test: it covers anonymous users, an outsider, an org member and staff. It fails without the fix with v1's expansion listed.

Nit (optional): CollectionExpansionsView's docstring still reads "List all expansions across all versions of a collection". "...across the versions of a collection the requester can view" would match what it does now.

…it holds only versions the requester can view
@snyaggarwal

Copy link
Copy Markdown
Contributor Author

The docstring nit is fixed in the latest commit. CollectionExpansionsView now reads "List the expansions across the versions of a collection the requester can view."

@snyaggarwal snyaggarwal left a comment

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.

Verdict: ready to merge once CI passes. No findings on 51e82b1.

  • The docstring fix checks out: CollectionExpansionsView now describes what it returns.
  • The rest of the PR is unchanged since the last review, which found nothing else. The list keeps only versions the requester can view, through the #1027 criteria, and staff, owners and org members see no change. The test fails without the fix.

@snyaggarwal
snyaggarwal requested a review from paynejd November 23, 2026 11:43
@snyaggarwal
snyaggarwal merged commit 7c5b895 into master Nov 23, 2026
3 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_online-742-expansions-list-viewable-versions branch November 23, 2026 11:55
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.

1 participant