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
013b7f46
Commit
013b7f46
authored
Aug 18, 2016
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow ProgramSearchSerializer to deal with missing organization bodies
parent
98c38ede
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
course_discovery/apps/api/serializers.py
+1
-1
course_discovery/apps/api/tests/test_serializers.py
+20
-0
No files found.
course_discovery/apps/api/serializers.py
View file @
013b7f46
...
...
@@ -547,7 +547,7 @@ class ProgramSearchSerializer(HaystackSerializer):
def
get_authoring_organizations
(
self
,
program
):
organizations
=
program
.
organization_bodies
return
[
json
.
loads
(
organization
)
for
organization
in
organizations
]
return
[
json
.
loads
(
organization
)
for
organization
in
organizations
]
if
organizations
else
[]
class
Meta
:
field_aliases
=
COMMON_SEARCH_FIELD_ALIASES
...
...
course_discovery/apps/api/tests/test_serializers.py
View file @
013b7f46
...
...
@@ -548,3 +548,23 @@ class ProgramSearchSerializerTests(TestCase):
'status'
:
program
.
status
,
}
self
.
assertDictEqual
(
serializer
.
data
,
expected
)
def
test_organization_bodies_missing
(
self
):
program
=
ProgramFactory
()
result
=
SearchQuerySet
()
.
models
(
Program
)
.
filter
(
uuid
=
program
.
uuid
)[
0
]
result
.
organization_bodies
=
None
serializer
=
ProgramSearchSerializer
(
result
)
expected
=
{
'uuid'
:
str
(
program
.
uuid
),
'title'
:
program
.
title
,
'subtitle'
:
program
.
subtitle
,
'type'
:
program
.
type
.
name
,
'marketing_url'
:
program
.
marketing_url
,
'authoring_organizations'
:
[],
'content_type'
:
'program'
,
'card_image_url'
:
program
.
card_image_url
,
'status'
:
program
.
status
,
}
self
.
assertDictEqual
(
serializer
.
data
,
expected
)
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