Merge pull request #36846 from raccoongang/rg/axm-course-catalog-add-org-image-url-indexing
feat: [FC-86] add org_image_url to course_discovery index FC-86
This commit is contained in:
@@ -14,7 +14,7 @@ from search.search_engine_base import SearchEngine
|
||||
|
||||
from cms.djangoapps.contentstore.course_group_config import GroupConfiguration
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
from openedx.core.lib.courses import course_image_url
|
||||
from openedx.core.lib.courses import course_image_url, course_organization_image_url
|
||||
from xmodule.annotator_mixin import html_to_text # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.library_tools import normalize_key_for_search # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order
|
||||
@@ -612,6 +612,7 @@ class CourseAboutSearchIndexer(CoursewareSearchIndexer):
|
||||
'course': course_id,
|
||||
'content': {},
|
||||
'image_url': course_image_url(course),
|
||||
'org_image_url': course_organization_image_url(course),
|
||||
}
|
||||
|
||||
# load data for all of the 'about' blocks for this course into a dictionary
|
||||
|
||||
@@ -2913,3 +2913,9 @@ SOCIAL_MEDIA_LOGO_URLS = {
|
||||
'linkedin': 'http://email-media.s3.amazonaws.com/edX/2021/social_3_linkedin.png',
|
||||
'facebook': 'http://email-media.s3.amazonaws.com/edX/2021/social_1_fb.png',
|
||||
}
|
||||
|
||||
# .. setting_name: DEFAULT_ORG_LOGO_URL
|
||||
# .. setting_default: Derived(lambda settings: settings.STATIC_URL + 'images/logo.png')
|
||||
# .. setting_description: The default logo url for organizations that do not have a logo set.
|
||||
# .. setting_warning: This url is used as a placeholder for organizations that do not have a logo set.
|
||||
DEFAULT_ORG_LOGO_URL = Derived(lambda settings: settings.STATIC_URL + 'images/logo.png')
|
||||
|
||||
@@ -8,6 +8,7 @@ from django.http import Http404
|
||||
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.locator import CourseKey
|
||||
from organizations.models import Organization
|
||||
from xmodule.assetstore.assetmgr import AssetManager
|
||||
from xmodule.contentstore.content import StaticContent
|
||||
from xmodule.contentstore.django import contentstore
|
||||
@@ -38,6 +39,12 @@ def course_image_url(course, image_key='course_image'):
|
||||
return url
|
||||
|
||||
|
||||
def course_organization_image_url(course):
|
||||
"""Return the course organization image URL or the default image URL."""
|
||||
org = Organization.objects.filter(short_name=course.id.org).first()
|
||||
return org.logo.url if org and org.logo else settings.DEFAULT_ORG_LOGO_URL
|
||||
|
||||
|
||||
def create_course_image_thumbnail(course, dimensions):
|
||||
"""Create a course image thumbnail and return the URL.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user