Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
3f70e8dd
Commit
3f70e8dd
authored
Dec 08, 2016
by
Matthew Piatetsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add logo image urls to search results
parent
be38e066
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
3 deletions
+15
-3
course_discovery/apps/api/serializers.py
+1
-1
course_discovery/apps/api/tests/test_serializers.py
+4
-2
course_discovery/apps/course_metadata/search_indexes.py
+5
-0
course_discovery/apps/course_metadata/tests/factories.py
+5
-0
No files found.
course_discovery/apps/api/serializers.py
View file @
3f70e8dd
...
...
@@ -52,7 +52,7 @@ COURSE_RUN_SEARCH_FIELDS = (
'text'
,
'key'
,
'title'
,
'short_description'
,
'full_description'
,
'start'
,
'end'
,
'enrollment_start'
,
'enrollment_end'
,
'pacing_type'
,
'language'
,
'transcript_languages'
,
'marketing_url'
,
'content_type'
,
'org'
,
'number'
,
'seat_types'
,
'image_url'
,
'type'
,
'level_type'
,
'availability'
,
'published'
,
'partner'
,
'program_types'
,
'authoring_organization_uuids'
,
'subject_uuids'
,
'staff_uuids'
,
'mobile_available'
,
'authoring_organization_uuids'
,
'subject_uuids'
,
'staff_uuids'
,
'mobile_available'
,
'logo_image_urls'
,
)
PROGRAM_FACET_FIELD_OPTIONS
=
{
...
...
course_discovery/apps/api/tests/test_serializers.py
View file @
3f70e8dd
...
...
@@ -1008,11 +1008,12 @@ class AffiliateWindowSerializerTests(TestCase):
class
CourseRunSearchSerializerTests
(
TestCase
):
def
test_data
(
self
):
course_run
=
CourseRunFactory
(
transcript_languages
=
LanguageTag
.
objects
.
filter
(
code__in
=
[
'en-us'
,
'zh-cn'
]))
course_run
=
CourseRunFactory
(
transcript_languages
=
LanguageTag
.
objects
.
filter
(
code__in
=
[
'en-us'
,
'zh-cn'
]),
authoring_organizations
=
[
OrganizationFactory
()])
ProgramFactory
(
courses
=
[
course_run
.
course
])
serializer
=
self
.
serialize_course_run
(
course_run
)
course_run_key
=
CourseKey
.
from_string
(
course_run
.
key
)
orgs
=
course_run
.
authoring_organizations
.
all
()
expected
=
{
'transcript_languages'
:
[
serialize_language
(
l
)
for
l
in
course_run
.
transcript_languages
.
all
()],
'short_description'
:
course_run
.
short_description
,
...
...
@@ -1038,6 +1039,7 @@ class CourseRunSearchSerializerTests(TestCase):
'published'
:
course_run
.
status
==
CourseRunStatus
.
Published
,
'partner'
:
course_run
.
course
.
partner
.
short_code
,
'program_types'
:
course_run
.
program_types
,
'logo_image_urls'
:
[
org
.
logo_image_url
for
org
in
orgs
],
'authoring_organization_uuids'
:
get_uuids
(
course_run
.
authoring_organizations
.
all
()),
'subject_uuids'
:
get_uuids
(
course_run
.
subjects
.
all
()),
'staff_uuids'
:
get_uuids
(
course_run
.
staff
.
all
())
...
...
course_discovery/apps/course_metadata/search_indexes.py
View file @
3f70e8dd
...
...
@@ -65,10 +65,15 @@ class BaseCourseIndex(OrganizationsMixin, BaseIndex):
subjects
=
indexes
.
MultiValueField
(
faceted
=
True
)
organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
authoring_organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
logo_image_urls
=
indexes
.
MultiValueField
()
sponsoring_organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
level_type
=
indexes
.
CharField
(
null
=
True
,
faceted
=
True
)
partner
=
indexes
.
CharField
(
model_attr
=
'partner__short_code'
,
null
=
True
,
faceted
=
True
)
def
prepare_logo_image_urls
(
self
,
obj
):
orgs
=
obj
.
authoring_organizations
.
all
()
return
[
org
.
logo_image_url
for
org
in
orgs
]
def
prepare_subjects
(
self
,
obj
):
return
[
subject
.
name
for
subject
in
obj
.
subjects
.
all
()]
...
...
course_discovery/apps/course_metadata/tests/factories.py
View file @
3f70e8dd
...
...
@@ -142,6 +142,11 @@ class CourseRunFactory(factory.DjangoModelFactory):
if
create
:
# pragma: no cover
add_m2m_data
(
self
.
transcript_languages
,
extracted
)
@factory.post_generation
def
authoring_organizations
(
self
,
create
,
extracted
,
**
kwargs
):
if
create
:
# pragma: no cover
add_m2m_data
(
self
.
authoring_organizations
,
extracted
)
class
OrganizationFactory
(
factory
.
DjangoModelFactory
):
uuid
=
factory
.
LazyFunction
(
uuid4
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment