Skip to content

Commit

Permalink
Fix minor asset storage admin issue [FC-0062] (#247)
Browse files Browse the repository at this point in the history
* fix: wrap call to storage path in NotImplementedError
  Admin page calls contents.os_path(), and if the storage backend doesn't support `path`, we can't even load the admin page for that asset.
* chore: bump version to 0.16.2
  • Loading branch information
pomegranited authored Oct 25, 2024
1 parent f65c4c2 commit 7e3ad5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion openedx_learning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Open edX Learning ("Learning Core").
"""

__version__ = "0.16.1"
__version__ = "0.16.2"
10 changes: 8 additions & 2 deletions openedx_learning/apps/authoring/contents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import annotations

from functools import cache, cached_property
from logging import getLogger

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured, ValidationError
Expand All @@ -19,6 +20,8 @@
from ....lib.managers import WithRelationsManager
from ..publishing.models import LearningPackage

logger = getLogger()

__all__ = [
"MediaType",
"Content",
Expand Down Expand Up @@ -316,8 +319,11 @@ def os_path(self):
This will return ``None`` if there is no backing file (has_file=False).
"""
if self.has_file:
return get_storage().path(self.path)
try:
if self.has_file:
return get_storage().path(self.path)
except NotImplementedError:
logger.warning("Storage backend does not support path()")
return None

def read_file(self) -> File:
Expand Down

0 comments on commit 7e3ad5c

Please sign in to comment.