Skip to content

Conversation

shanbady
Copy link
Contributor

@shanbady shanbady commented Sep 26, 2025

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/8516?issue=mitodl%7Chq%7C8519

Description (What does it do?)

This PR includes changes that resolve the visibility in canvas archives according to the following rules:

file is not ingested when:

  • If the "files" section in the sidebar is hidden and the file in not embedded on any page
  • If the file is marked published but resides in a folder that is hidden or locked and it is also not embedded anywhere

file is ingested when:

  • it is explicitly marked as published and parent folder is not locked/hidden and files navbar is visible.
  • it is embedded/linked to on a module, assignment, or any html content.

This PR also includes some code cleanup and consolidation of methods into canvas_utils.py

note for reviewer: the majority of the functional changes are in the newly introduced get_published_items method

How can this be tested?

  1. checkout this branch
  2. ingest course id 14566 (https://canvas.mit.edu/courses/14566) where the "files" in the sidebar is hidden to students ./manage.py backpopulate_canvas_courses --canvas-id 14566
  3. note that the only contentfiles for the course are files embedded on assignment pages:
from learning_resources.models import *
LearningResource.objects.get(readable_id__istartswith="14566").runs.first().content_files.all().values_list("source_path")

@shanbady shanbady marked this pull request as ready for review September 27, 2025 01:50
@shanbady shanbady added the Needs Review An open Pull Request that is ready for review label Sep 27, 2025
@mbertrand mbertrand self-assigned this Sep 29, 2025
Copy link
Member

@mbertrand mbertrand left a comment

Choose a reason for hiding this comment

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

👍

@mbertrand mbertrand added Waiting on author and removed Needs Review An open Pull Request that is ready for review labels Sep 29, 2025
@shanbady shanbady merged commit cb77e7b into main Sep 29, 2025
13 checks passed
@shanbady shanbady deleted the shanbady/visibility-of-orphaned-canvas-files branch September 29, 2025 17:50
This was referenced Sep 30, 2025
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.

2 participants