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
b0247f17
Commit
b0247f17
authored
Aug 20, 2015
by
Adam
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9408 from edx/hotfix/2015-08-20
Fix Forum Update Issue #TNL-3101
parents
f17df2d0
c8090659
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
lms/djangoapps/django_comment_client/base/tests.py
+13
-4
lms/djangoapps/django_comment_client/base/views.py
+2
-1
No files found.
lms/djangoapps/django_comment_client/base/tests.py
View file @
b0247f17
...
...
@@ -316,11 +316,20 @@ class ViewsTestCaseMixin(object):
Issues a request to update a thread and verifies the result.
"""
self
.
_setup_mock_request
(
mock_request
)
response
=
self
.
client
.
post
(
reverse
(
"update_thread"
,
kwargs
=
{
"thread_id"
:
"dummy"
,
"course_id"
:
self
.
course_id
.
to_deprecated_string
()}),
data
=
{
"body"
:
"foo"
,
"title"
:
"foo"
,
"commentable_id"
:
"some_topic"
}
)
# Mock out saving in order to test that content is correctly
# updated. Otherwise, the call to thread.save() receives the
# same mocked request data that the original call to retrieve
# the thread did, overwriting any changes.
with
patch
.
object
(
Thread
,
'save'
):
response
=
self
.
client
.
post
(
reverse
(
"update_thread"
,
kwargs
=
{
"thread_id"
:
"dummy"
,
"course_id"
:
self
.
course_id
.
to_deprecated_string
()}),
data
=
{
"body"
:
"foo"
,
"title"
:
"foo"
,
"commentable_id"
:
"some_topic"
}
)
self
.
assertEqual
(
response
.
status_code
,
200
)
data
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
data
[
'body'
],
'foo'
)
self
.
assertEqual
(
data
[
'title'
],
'foo'
)
self
.
assertEqual
(
data
[
'commentable_id'
],
'some_topic'
)
@ddt.ddt
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
b0247f17
...
...
@@ -243,6 +243,8 @@ def update_thread(request, course_id, thread_id):
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
thread
=
cc
.
Thread
.
find
(
thread_id
)
# Get thread context first in order to be safe from reseting the values of thread object later
thread_context
=
getattr
(
thread
,
"context"
,
"course"
)
thread
.
body
=
request
.
POST
[
"body"
]
thread
.
title
=
request
.
POST
[
"title"
]
# The following checks should avoid issues we've seen during deploys, where end users are hitting an updated server
...
...
@@ -252,7 +254,6 @@ def update_thread(request, course_id, thread_id):
if
"commentable_id"
in
request
.
POST
:
commentable_id
=
request
.
POST
[
"commentable_id"
]
course
=
get_course_with_access
(
request
.
user
,
'load'
,
course_key
)
thread_context
=
getattr
(
thread
,
"context"
,
"course"
)
if
thread_context
==
"course"
and
not
discussion_category_id_access
(
course
,
request
.
user
,
commentable_id
):
return
JsonError
(
_
(
"Topic doesn't exist"
))
else
:
...
...
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