openedx / openedx-learning

GNU Affero General Public License v3.0
5 stars 8 forks source link

File Uploads + media_server app #33

Closed ormsbee closed 1 year ago

ormsbee commented 1 year ago

Allow Content data to be stored as FileFields backed by django-storages, and serve those assets via a simple internal app.

I'm afraid I muddled this PR a bit. I needed to fix the dependencies, and I got that muddled in with my actual code changes (though they're in separate commits). I also ended up running black on the Python files I touched, meaning there are some unrelated formatting issues higher up in the files that got caught. I can break this up if it's too much to sort through.

From the commit message:

This alters the data model in the components app in a number of ways in
order to support static assets, along with some refactoring:

* Content has been renamed to RawContent to make it more clear when we
  are talking about "content" as a general concept and the actual data
  model that holds the raw bytes.
* RawContent now uses FileField instead of BinaryField, giving us more
  cheaply scalable storage in exchange for higher latency. This is
  offset by the new TextContent model that will be used to store the
  text versions of RawContent that needs low-latency access (like XBlock
  OLX).
* A primitive media_server app now exists to view static assets during
  development. It is NOT safe to use on a running site yet.
ormsbee commented 1 year ago

The part I'm struggling with the most here are the asset download permissions. I had that encoded into the RawContent at one point, and then backed it out to the ContentVersionRawContent through model. But thinking on it more, it feels more like it should live outside the versioning workflow altogether–since if you accidentally left something public, you wouldn't want to leave old versions of it public when you lock the current version down.

bradenmacdonald commented 1 year ago

To what extent is learning core responsible for permissions? Are we going with is_public content is CDN cacheable and public, and everything else requires a signed URL, which can be retrieved by (e.g. the LMS) and given to authorized users, but Learning Core doesn't know anything beyond that?

Edit: lol never mind, I see you answered that above.

ormsbee commented 1 year ago

@bradenmacdonald, @kdmccormick, @feanil: Ready for review.

ormsbee commented 1 year ago

Rebased to resolve some dependency conflicts.