Skip to content

Conversation

@gumaerc
Copy link
Contributor

@gumaerc gumaerc commented Oct 15, 2024

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/5775

Description (What does it do?)

This PR configures filter_queryset on TopicViewSet to exclude topics where channel_url is null, meaning that the Topic has no associated channel. This has the effect of filtering out these topics from API responses, preventing errors related to accessing channel_url where it might not exist.

How can this be tested?

Firstly, make sure you have data backpopulated in your database relating to courses, topics and channels. You will need both a LearningResourceTopic without and with an associated Channel object. The "AR/VR/MR/XR" topic had no channel for me, so either try and use that topic for testing or use a Django shell to ensure that you have the required data. Your user should also be a user with is_staff or is_superuser set to true.

To reproduce the issue:

  • Spin up the main branch of mit-learn
  • Go to the home page and click the list button on any of the featured courses
  • Click the "Create New List" button
  • Name and describe your list however you want, but under topics select the topic you found above with no associated Channel
  • Upon creating the list, you should see the error regarding channel_url
    To see the fix in action:
  • Spin up this branch of mit-learn
  • Repeat the above process and ensure that the topic without a Channel does not even appear in the list of topics you can choose from

@gumaerc gumaerc added the Needs Review An open Pull Request that is ready for review label Oct 15, 2024
@shanbady shanbady self-requested a review October 16, 2024 13:43
Copy link
Contributor

@shanbady shanbady left a comment

Choose a reason for hiding this comment

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

Changes look good and appear to have resolved the bug. 👍

@gumaerc gumaerc merged commit 50e17e1 into main Oct 16, 2024
11 checks passed
This was referenced Oct 16, 2024
@rhysyngsun rhysyngsun deleted the cg/topics-exclude-null-channel-url branch February 7, 2025 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants