Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PADV-1558 add default storage instances on utils.py #11

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions edx_sga/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ def get_default_storage():
# If settings not defined, use default_storage from Django
return django_default_storage

default_storage = get_default_storage()

def utcnow():
"""
Get current date and time in UTC
Expand Down Expand Up @@ -67,7 +65,7 @@ def get_file_modified_time_utc(file_path):
else pytz.utc
)

file_time = default_storage.get_modified_time(file_path)
file_time = get_default_storage().get_modified_time(file_path)

if file_time.tzinfo is None:
return file_timezone.localize(file_time).astimezone(pytz.utc)
Expand Down Expand Up @@ -99,5 +97,5 @@ def file_contents_iter(file_path):
"""
Returns an iterator over the contents of a file located at the given file path
"""
file_descriptor = default_storage.open(file_path)
file_descriptor = get_default_storage().open(file_path)
return iter(partial(file_descriptor.read, BLOCK_SIZE), b"")
Loading