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
96b98181
Commit
96b98181
authored
Aug 18, 2016
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restrict serialized program organizations to authoring ones only
parent
555bc751
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
course_discovery/apps/api/serializers.py
+1
-1
course_discovery/apps/api/tests/test_serializers.py
+3
-3
course_discovery/apps/course_metadata/search_indexes.py
+4
-5
No files found.
course_discovery/apps/api/serializers.py
View file @
96b98181
...
...
@@ -577,7 +577,7 @@ class ProgramSearchSerializer(HaystackSerializer):
authoring_organizations
=
serializers
.
SerializerMethodField
()
def
get_authoring_organizations
(
self
,
program
):
organizations
=
program
.
organization_bodies
organizations
=
program
.
authoring_
organization_bodies
return
[
json
.
loads
(
organization
)
for
organization
in
organizations
]
if
organizations
else
[]
class
Meta
:
...
...
course_discovery/apps/api/tests/test_serializers.py
View file @
96b98181
...
...
@@ -548,8 +548,8 @@ class ProgramSearchSerializerTests(TestCase):
program
.
authoring_organizations
.
add
(
authoring_organization
)
program
.
credit_backing_organizations
.
add
(
crediting_organization
)
program
.
save
()
expected_organizations
=
[
OrganizationSerializer
(
org
)
.
data
for
org
in
(
authoring_organization
,
crediting_organization
)
expected_
authoring_
organizations
=
[
OrganizationSerializer
(
authoring_organization
)
.
data
,
]
# NOTE: This serializer expects SearchQuerySet results, so we run a search on the newly-created object
...
...
@@ -563,7 +563,7 @@ class ProgramSearchSerializerTests(TestCase):
'subtitle'
:
program
.
subtitle
,
'type'
:
program
.
type
.
name
,
'marketing_url'
:
program
.
marketing_url
,
'authoring_organizations'
:
expected_organizations
,
'authoring_organizations'
:
expected_
authoring_
organizations
,
'content_type'
:
'program'
,
'card_image_url'
:
program
.
card_image_url
,
'status'
:
program
.
status
,
...
...
course_discovery/apps/course_metadata/search_indexes.py
View file @
96b98181
...
...
@@ -124,8 +124,8 @@ class ProgramIndex(BaseIndex, indexes.Indexable, OrganizationsMixin):
marketing_url
=
indexes
.
CharField
(
null
=
True
)
organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
authoring_organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
authoring_organization_bodies
=
indexes
.
MultiValueField
()
credit_backing_organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
organization_bodies
=
indexes
.
MultiValueField
()
card_image_url
=
indexes
.
CharField
(
model_attr
=
'card_image_url'
,
null
=
True
)
status
=
indexes
.
CharField
(
model_attr
=
'status'
,
faceted
=
True
)
partner
=
indexes
.
CharField
(
model_attr
=
'partner__short_code'
,
null
=
True
,
faceted
=
True
)
...
...
@@ -136,12 +136,11 @@ class ProgramIndex(BaseIndex, indexes.Indexable, OrganizationsMixin):
def
prepare_authoring_organizations
(
self
,
obj
):
return
[
self
.
format_organization
(
organization
)
for
organization
in
obj
.
authoring_organizations
.
all
()]
def
prepare_authoring_organization_bodies
(
self
,
obj
):
return
[
self
.
format_organization_body
(
organization
)
for
organization
in
obj
.
authoring_organizations
.
all
()]
def
prepare_credit_backing_organizations
(
self
,
obj
):
return
[
self
.
format_organization
(
organization
)
for
organization
in
obj
.
credit_backing_organizations
.
all
()]
def
prepare_organization_bodies
(
self
,
obj
):
organizations
=
obj
.
authoring_organizations
.
all
()
|
obj
.
credit_backing_organizations
.
all
()
return
[
self
.
format_organization_body
(
organization
)
for
organization
in
organizations
]
def
prepare_marketing_url
(
self
,
obj
):
return
obj
.
marketing_url
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