Commit ac45850d by Aamish Baloch

YONK-691: Configurable profile image sizes

parent c6e08517
...@@ -501,3 +501,10 @@ HELP_TOKENS_BOOKS = ENV_TOKENS.get('HELP_TOKENS_BOOKS', HELP_TOKENS_BOOKS) ...@@ -501,3 +501,10 @@ HELP_TOKENS_BOOKS = ENV_TOKENS.get('HELP_TOKENS_BOOKS', HELP_TOKENS_BOOKS)
############## Settings for CourseGraph ############################ ############## Settings for CourseGraph ############################
COURSEGRAPH_JOB_QUEUE = ENV_TOKENS.get('COURSEGRAPH_JOB_QUEUE', LOW_PRIORITY_QUEUE) COURSEGRAPH_JOB_QUEUE = ENV_TOKENS.get('COURSEGRAPH_JOB_QUEUE', LOW_PRIORITY_QUEUE)
############## Settings for Profile Image Size ######################
PROFILE_IMAGE_SIZES_MAP = ENV_TOKENS.get(
'PROFILE_IMAGE_SIZES_MAP',
PROFILE_IMAGE_SIZES_MAP
)
...@@ -1335,3 +1335,12 @@ RECALCULATE_GRADES_ROUTING_KEY = LOW_PRIORITY_QUEUE ...@@ -1335,3 +1335,12 @@ RECALCULATE_GRADES_ROUTING_KEY = LOW_PRIORITY_QUEUE
############## Settings for CourseGraph ############################ ############## Settings for CourseGraph ############################
COURSEGRAPH_JOB_QUEUE = LOW_PRIORITY_QUEUE COURSEGRAPH_JOB_QUEUE = LOW_PRIORITY_QUEUE
############## Settings for Profile Image Size ######################
PROFILE_IMAGE_SIZES_MAP = {
'full': 500,
'large': 120,
'medium': 50,
'small': 30
}
...@@ -1005,3 +1005,10 @@ ICP_LICENSE = ENV_TOKENS.get('ICP_LICENSE', None) ...@@ -1005,3 +1005,10 @@ ICP_LICENSE = ENV_TOKENS.get('ICP_LICENSE', None)
############## Settings for CourseGraph ############################ ############## Settings for CourseGraph ############################
COURSEGRAPH_JOB_QUEUE = ENV_TOKENS.get('COURSEGRAPH_JOB_QUEUE', LOW_PRIORITY_QUEUE) COURSEGRAPH_JOB_QUEUE = ENV_TOKENS.get('COURSEGRAPH_JOB_QUEUE', LOW_PRIORITY_QUEUE)
############## Settings for Profile Image Size ######################
PROFILE_IMAGE_SIZES_MAP = ENV_TOKENS.get(
'PROFILE_IMAGE_SIZES_MAP',
PROFILE_IMAGE_SIZES_MAP
)
...@@ -3202,3 +3202,12 @@ COURSES_API_CACHE_TIMEOUT = 3600 # Value is in seconds ...@@ -3202,3 +3202,12 @@ COURSES_API_CACHE_TIMEOUT = 3600 # Value is in seconds
############## Settings for CourseGraph ############################ ############## Settings for CourseGraph ############################
COURSEGRAPH_JOB_QUEUE = LOW_PRIORITY_QUEUE COURSEGRAPH_JOB_QUEUE = LOW_PRIORITY_QUEUE
############## Settings for Profile Image Size ######################
PROFILE_IMAGE_SIZES_MAP = {
'full': 500,
'large': 120,
'medium': 50,
'small': 30
}
...@@ -14,13 +14,8 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_ ...@@ -14,13 +14,8 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_
PROFILE_IMAGE_FILE_EXTENSION = 'jpg' # All processed profile images are converted to JPEGs PROFILE_IMAGE_FILE_EXTENSION = 'jpg' # All processed profile images are converted to JPEGs
PROFILE_IMAGE_SIZES_MAP = {
'full': 500, _PROFILE_IMAGE_SIZES = settings.PROFILE_IMAGE_SIZES_MAP.values()
'large': 120,
'medium': 50,
'small': 30
}
_PROFILE_IMAGE_SIZES = PROFILE_IMAGE_SIZES_MAP.values()
def get_profile_image_storage(): def get_profile_image_storage():
...@@ -60,7 +55,7 @@ def _get_profile_image_urls(name, storage, file_extension=PROFILE_IMAGE_FILE_EXT ...@@ -60,7 +55,7 @@ def _get_profile_image_urls(name, storage, file_extension=PROFILE_IMAGE_FILE_EXT
) )
return '{}?v={}'.format(url, version) if version is not None else url return '{}?v={}'.format(url, version) if version is not None else url
return {size_display_name: _make_url(size) for size_display_name, size in PROFILE_IMAGE_SIZES_MAP.items()} return {size_display_name: _make_url(size) for size_display_name, size in settings.PROFILE_IMAGE_SIZES_MAP.items()}
def get_profile_image_names(username): def get_profile_image_names(username):
......
...@@ -246,7 +246,7 @@ class TestAccountApi(UserSettingsEventTestMixin, TestCase): ...@@ -246,7 +246,7 @@ class TestAccountApi(UserSettingsEventTestMixin, TestCase):
@attr(shard=2) @attr(shard=2)
@patch('openedx.core.djangoapps.user_api.accounts.image_helpers._PROFILE_IMAGE_SIZES', [50, 10]) @patch('openedx.core.djangoapps.user_api.accounts.image_helpers._PROFILE_IMAGE_SIZES', [50, 10])
@patch.dict( @patch.dict(
'openedx.core.djangoapps.user_api.accounts.image_helpers.PROFILE_IMAGE_SIZES_MAP', 'django.conf.settings.PROFILE_IMAGE_SIZES_MAP',
{'full': 50, 'small': 10}, {'full': 50, 'small': 10},
clear=True clear=True
) )
......
...@@ -18,7 +18,7 @@ TEST_PROFILE_IMAGE_UPLOAD_DT = datetime.datetime(2002, 1, 9, 15, 43, 01, tzinfo= ...@@ -18,7 +18,7 @@ TEST_PROFILE_IMAGE_UPLOAD_DT = datetime.datetime(2002, 1, 9, 15, 43, 01, tzinfo=
@attr(shard=2) @attr(shard=2)
@patch.dict('openedx.core.djangoapps.user_api.accounts.image_helpers.PROFILE_IMAGE_SIZES_MAP', TEST_SIZES, clear=True) @patch.dict('django.conf.settings.PROFILE_IMAGE_SIZES_MAP', TEST_SIZES, clear=True)
@skip_unless_lms @skip_unless_lms
class ProfileImageUrlTestCase(TestCase): class ProfileImageUrlTestCase(TestCase):
""" """
......
...@@ -200,7 +200,7 @@ class TestOwnUsernameAPI(CacheIsolationTestCase, UserAPITestCase): ...@@ -200,7 +200,7 @@ class TestOwnUsernameAPI(CacheIsolationTestCase, UserAPITestCase):
@skip_unless_lms @skip_unless_lms
@patch('openedx.core.djangoapps.user_api.accounts.image_helpers._PROFILE_IMAGE_SIZES', [50, 10]) @patch('openedx.core.djangoapps.user_api.accounts.image_helpers._PROFILE_IMAGE_SIZES', [50, 10])
@patch.dict( @patch.dict(
'openedx.core.djangoapps.user_api.accounts.image_helpers.PROFILE_IMAGE_SIZES_MAP', 'django.conf.settings.PROFILE_IMAGE_SIZES_MAP',
{'full': 50, 'small': 10}, {'full': 50, 'small': 10},
clear=True clear=True
) )
...@@ -608,7 +608,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): ...@@ -608,7 +608,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase):
verify_change_info(name_change_info[1], "Mickey Mouse", self.user.username, "Donald Duck") verify_change_info(name_change_info[1], "Mickey Mouse", self.user.username, "Donald Duck")
@patch.dict( @patch.dict(
'openedx.core.djangoapps.user_api.accounts.image_helpers.PROFILE_IMAGE_SIZES_MAP', 'django.conf.settings.PROFILE_IMAGE_SIZES_MAP',
{'full': 50, 'medium': 30, 'small': 10}, {'full': 50, 'medium': 30, 'small': 10},
clear=True clear=True
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment