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
41173fef
Commit
41173fef
authored
Jul 29, 2015
by
cahrens
Committed by
Andy Armstrong
Aug 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only verify course access for threads with course context.
parent
63da1907
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
8 deletions
+38
-8
lms/djangoapps/django_comment_client/forum/tests.py
+37
-2
lms/djangoapps/django_comment_client/forum/views.py
+1
-6
No files found.
lms/djangoapps/django_comment_client/forum/tests.py
View file @
41173fef
...
...
@@ -176,6 +176,7 @@ def make_mock_request_impl(
thread_id
=
thread_id
,
num_children
=
num_thread_responses
,
group_id
=
group_id
,
commentable_id
=
commentable_id
)
elif
"/users/"
in
url
:
data
=
{
...
...
@@ -336,8 +337,8 @@ class SingleThreadQueryCountTestCase(ModuleStoreTestCase):
@ddt.data
(
# old mongo with cache
(
ModuleStoreEnum
.
Type
.
mongo
,
1
,
7
,
5
,
14
,
8
),
(
ModuleStoreEnum
.
Type
.
mongo
,
50
,
7
,
5
,
14
,
8
),
(
ModuleStoreEnum
.
Type
.
mongo
,
1
,
6
,
4
,
14
,
8
),
(
ModuleStoreEnum
.
Type
.
mongo
,
50
,
6
,
4
,
14
,
8
),
# split mongo: 3 queries, regardless of thread response size.
(
ModuleStoreEnum
.
Type
.
split
,
1
,
3
,
3
,
14
,
8
),
(
ModuleStoreEnum
.
Type
.
split
,
50
,
3
,
3
,
14
,
8
),
...
...
@@ -668,6 +669,40 @@ class SingleThreadContentGroupTestCase(ContentGroupTestCase):
self
.
assert_can_access
(
self
.
non_cohorted_user
,
self
.
beta_module
.
discussion_id
,
thread_id
,
False
)
def
test_course_context_respected
(
self
,
mock_request
):
"""
Verify that course threads go through discussion_category_id_access method.
"""
thread_id
=
"test_thread_id"
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
"dummy content"
,
thread_id
=
thread_id
)
# Beta user does not have access to alpha_module.
self
.
assert_can_access
(
self
.
beta_user
,
self
.
alpha_module
.
discussion_id
,
thread_id
,
False
)
def
test_standalone_context_respected
(
self
,
mock_request
):
"""
Verify that standalone threads don't go through discussion_category_id_access method.
"""
# For this rather pathological test, we are assigning the alpha module discussion_id (commentable_id)
# to a team so that we can verify that standalone threads don't go through discussion_category_id_access.
thread_id
=
"test_thread_id"
CourseTeamFactory
(
name
=
"A team"
,
course_id
=
self
.
course
.
id
,
topic_id
=
'topic_id'
,
discussion_topic_id
=
self
.
alpha_module
.
discussion_id
)
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
"dummy content"
,
thread_id
=
thread_id
,
commentable_id
=
self
.
alpha_module
.
discussion_id
)
# If a thread returns context other than "course", the access check is not done, and the beta user
# can see the alpha discussion module.
self
.
assert_can_access
(
self
.
beta_user
,
self
.
alpha_module
.
discussion_id
,
thread_id
,
True
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
class
InlineDiscussionContextTestCase
(
ModuleStoreTestCase
):
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
41173fef
...
...
@@ -320,10 +320,6 @@ def single_thread(request, course_key, discussion_id, thread_id):
user_info
=
cc_user
.
to_dict
()
is_moderator
=
has_permission
(
request
.
user
,
"see_all_cohorts"
,
course_key
)
# Verify that the student has access to this thread if belongs to a discussion module
if
discussion_id
not
in
utils
.
get_discussion_categories_ids
(
course
,
request
.
user
):
raise
Http404
# Currently, the front end always loads responses via AJAX, even for this
# page; it would be a nice optimization to avoid that extra round trip to
# the comments service.
...
...
@@ -340,8 +336,7 @@ def single_thread(request, course_key, discussion_id, thread_id):
raise
# Verify that the student has access to this thread if belongs to a course discussion module
thread_context
=
getattr
(
thread
,
"context"
,
"course"
)
if
thread_context
==
"course"
and
not
utils
.
discussion_category_id_access
(
course
,
request
.
user
,
discussion_id
):
if
thread
.
context
==
"course"
and
not
utils
.
discussion_category_id_access
(
course
,
request
.
user
,
discussion_id
):
raise
Http404
# verify that the thread belongs to the requesting student's cohort
...
...
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