GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add a public filter to the kolibri-public's ChannelMetadata viewset by taoerman · Pull Request #5486 · learningequality/studio

Conversation

@taoerman

@taoerman taoerman commented Oct 21, 2025

Copy link
Copy Markdown
Contributor

Summary

Added a public filter to the ChannelMetadataViewSet that defaults to only returning public channels, preventing community channels from appearing in Kolibri's main Library listing. The filter allows explicit access to community channels via ?public=false while maintaining backward compatibility.

Added comprehensive tests to verify the filtering behavior works correctly for both public and community channels.

I also used postman and local Kolibri to manually test public filter.

References

#5263

Reviewer guidance

run unit tests.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
taoerman and others added 5 commits October 20, 2025 18:52
@taoerman
Add a public filter to the kolibri-public's ChannelMetadata viewset
50da379
@pre-commit-ci-lite
[pre-commit.ci lite] apply automatic fixes
34b8262
@taoerman
fix test_channelmetadata_viewset.py
ba64300
@taoerman
Merge branch 'add-public-filter' of https://github.com/taoerman/studio …
e912480
…into add-public-filter

fix bug
@pre-commit-ci-lite
[pre-commit.ci lite] apply automatic fixes
0ff1f8a
@AlexVelezLl AlexVelezLl self-assigned this Oct 21, 2025
AlexVelezLl
AlexVelezLl reviewed Oct 23, 2025
View reviewed changes

@AlexVelezLl AlexVelezLl left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks @taoerman! This solution looks good, and it is fixing the error of returning the Community Channels in the public channels endpoint! I just noticed one potential improvement in the channelmetadata viewset test suite, and a question to get a more idiomatic implementation for the default filter value. Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread contentcuration/kolibri_public/tests/test_channelmetadata_viewset.py

@AlexVelezLl AlexVelezLl Oct 23, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The tests in this test suite are meant to be run for Community Library channels (e.g. they are being set the countries field, but this only makes sense in Community Library Channels); therefore, instead of setting the channels' public field to true, I think a better option would be to update the client.get method to filter by public channels with the public field set to false. What do you think?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@taoerman taoerman Oct 23, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks Alex, I've update the client.get method.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread contentcuration/kolibri_public/tests/test_content_app.py
self.assertEqual(response.data[0]["name"], community_metadata.name)
self.assertFalse(response.data[0]["public"])

def test_channelmetadata_public_filter_mixed_channels(self):

@AlexVelezLl AlexVelezLl Oct 23, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Great!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread contentcuration/kolibri_public/views.py Outdated
Comment on lines +169 to +174
queryset = models.ChannelMetadata.objects.all()
# By default, only return public channels unless explicitly filtered
request = getattr(self, "request", None)
if request is not None and "public" not in request.query_params:
return queryset.filter(public=True)
return queryset

@AlexVelezLl AlexVelezLl Oct 23, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

(Non-blocking) Did you have a chance to look at the using initial values as default for Filterset fields? It seems like a more idiomatic way to set the public filter if it's not present. Let's chat! If this doesn't look like the best solution, I think a better option would be to implement this in filter_queryset rather than in the get_queryset? Just to declare the intention of filtering the queryset more idiomatically.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@taoerman taoerman Oct 23, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks, I've added a new filter according to the document and added default value as well.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
taoerman and others added 5 commits October 23, 2025 09:43
@taoerman
fix code according to comments
8d55585
@pre-commit-ci-lite
[pre-commit.ci lite] apply automatic fixes
03a3872
@taoerman
fix linting
f4ff08b
@taoerman
fix linting
8129285
@pre-commit-ci-lite
[pre-commit.ci lite] apply automatic fixes
76677ba
AlexVelezLl
AlexVelezLl approved these changes Oct 24, 2025
View reviewed changes

@AlexVelezLl AlexVelezLl left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Code changes look good, tests provide good confidence, and manual QA checks out. Thanks @taoerman!

Image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AlexVelezLl
AlexVelezLl merged commit 3918b3a into learningequality:unstable Oct 24, 2025
@AlexVelezLl AlexVelezLl mentioned this pull request Oct 24, 2025
ESoCC: Add a public filter to the kolibri-public's ChannelMetadata viewset #5263
Closed
1 task
AllanOXDi pushed a commit to AllanOXDi/studio that referenced this pull request Nov 20, 2025
@taoerman @pre-commit-ci-lite @AllanOXDi
Add a public filter to the kolibri-public's ChannelMetadata viewset (l…
5b1d5b2
…earningequality#5486)

* Add a public filter to the kolibri-public's ChannelMetadata viewset

* [pre-commit.ci lite] apply automatic fixes

* fix test_channelmetadata_viewset.py

* [pre-commit.ci lite] apply automatic fixes

* fix code according to comments

* [pre-commit.ci lite] apply automatic fixes

* fix linting

* fix linting

* [pre-commit.ci lite] apply automatic fixes

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AlexVelezLl AlexVelezLl AlexVelezLl approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@AlexVelezLl AlexVelezLl

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@taoerman @AlexVelezLl
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.