Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
6a9b4359
Commit
6a9b4359
authored
Jun 19, 2015
by
Greg Price
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8563 from edx/gprice/discussion-api-missing-pinned
Fix discussion_api to handle old threads
parents
84753740
65057133
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
lms/djangoapps/discussion_api/serializers.py
+4
-0
lms/djangoapps/discussion_api/tests/test_serializers.py
+11
-0
No files found.
lms/djangoapps/discussion_api/serializers.py
View file @
6a9b4359
...
...
@@ -180,6 +180,10 @@ class ThreadSerializer(_ContentSerializer):
# type is an invalid class attribute name, so we must declare a
# different name above and modify it here
self
.
fields
[
"type"
]
=
self
.
fields
.
pop
(
"type_"
)
# Compensate for the fact that some threads in the comments service do
# not have the pinned field set
if
self
.
object
and
self
.
object
.
get
(
"pinned"
)
is
None
:
self
.
object
[
"pinned"
]
=
False
def
get_group_name
(
self
,
obj
):
"""Returns the name of the group identified by the thread's group_id."""
...
...
lms/djangoapps/discussion_api/tests/test_serializers.py
View file @
6a9b4359
...
...
@@ -212,6 +212,17 @@ class ThreadSerializerSerializationTest(SerializerTestMixin, ModuleStoreTestCase
})
self
.
assertEqual
(
self
.
serialize
(
thread
),
expected
)
def
test_pinned_missing
(
self
):
"""
Make sure that older threads in the comments service without the pinned
field do not break serialization
"""
thread_data
=
self
.
make_cs_content
({})
del
thread_data
[
"pinned"
]
self
.
register_get_thread_response
(
thread_data
)
serialized
=
self
.
serialize
(
Thread
(
id
=
thread_data
[
"id"
]))
self
.
assertEqual
(
serialized
[
"pinned"
],
False
)
def
test_group
(
self
):
cohort
=
CohortFactory
.
create
(
course_id
=
self
.
course
.
id
)
serialized
=
self
.
serialize
(
self
.
make_cs_content
({
"group_id"
:
cohort
.
id
}))
...
...
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