-
Notifications
You must be signed in to change notification settings - Fork 108
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
feat: add support for picking storage config from settings #344
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -9,10 +9,34 @@ | |||||||
|
||||||||
import pytz | ||||||||
from django.conf import settings | ||||||||
from django.core.files.storage import default_storage | ||||||||
from django.core.files.storage import default_storage as django_default_storage, get_storage_class | ||||||||
from edx_sga.constants import BLOCK_SIZE | ||||||||
|
||||||||
|
||||||||
def get_default_storage(): | ||||||||
""" | ||||||||
Get config for storage from settings, use Django's default_storage if no such settings are defined | ||||||||
""" | ||||||||
# .. setting_name: SGA_STORAGE_SETTINGS | ||||||||
# .. setting_default: {} | ||||||||
# .. setting_description: Specifies the storage class and keyword arguments to use in the constructor | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might be a better description.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||
# Default storage will be used if this settings in not specified. | ||||||||
# .. setting_example: { | ||||||||
# STORAGE_CLASS: 'storage', | ||||||||
# STORAGE_KWARGS: {} | ||||||||
# } | ||||||||
sga_storage_settings = getattr(settings, "SGA_STORAGE_SETTINGS", None) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this introducing a new configuration setting to edx-platform for this xBlock? Please follow the guidelines in OEP-17 for adding annotations for settings and flags. In the annotation, please include an example of the data structure for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes introducing new configuration, added the annotations |
||||||||
|
||||||||
if sga_storage_settings: | ||||||||
return get_storage_class( | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have two things in mind regarding this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||
sga_storage_settings['STORAGE_CLASS'] | ||||||||
)(**sga_storage_settings['STORAGE_KWARGS']) | ||||||||
|
||||||||
# 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 | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write a simple test for this? That would go in test_utils.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added