From 4cdbd94c229a30128b268d883aa329630af35066 Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Thu, 24 Oct 2024 14:33:27 +1030 Subject: [PATCH] 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. --- openedx_learning/apps/authoring/contents/models.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/openedx_learning/apps/authoring/contents/models.py b/openedx_learning/apps/authoring/contents/models.py index 214c2d27..3c4cab42 100644 --- a/openedx_learning/apps/authoring/contents/models.py +++ b/openedx_learning/apps/authoring/contents/models.py @@ -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 @@ -19,6 +20,9 @@ from ....lib.managers import WithRelationsManager from ..publishing.models import LearningPackage + +logger = getLogger() + __all__ = [ "MediaType", "Content", @@ -316,8 +320,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 as err: + logger.exception(err) return None def read_file(self) -> File: