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
1c272f6d
Commit
1c272f6d
authored
Nov 21, 2014
by
E. Kolpakov
Committed by
Jonathan Piacenti
Aug 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed changing thread type
parent
65d1ed5b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
5 deletions
+22
-5
lms/djangoapps/django_comment_client/base/views.py
+1
-1
lms/djangoapps/django_comment_client/tests/test_utils.py
+4
-4
lms/djangoapps/django_comment_client/utils.py
+17
-0
No files found.
lms/djangoapps/django_comment_client/base/views.py
View file @
1c272f6d
...
...
@@ -244,7 +244,7 @@ def update_thread(request, course_id, thread_id):
thread
.
thread_type
=
request
.
POST
[
"thread_type"
]
if
"commentable_id"
in
request
.
POST
:
course
=
get_course_with_access
(
request
.
user
,
'load'
,
course_key
)
commentable_ids
=
get_discussion_categories_ids
(
course
,
request
.
user
)
commentable_ids
=
get_discussion_categories_ids
(
course
)
if
request
.
POST
.
get
(
"commentable_id"
)
in
commentable_ids
:
thread
.
commentable_id
=
request
.
POST
[
"commentable_id"
]
else
:
...
...
lms/djangoapps/django_comment_client/tests/test_utils.py
View file @
1c272f6d
...
...
@@ -722,7 +722,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
)
def
test_ids_empty
(
self
):
self
.
assertEqual
(
utils
.
get_discussion_categories_ids
(
self
.
course
,
self
.
user
),
[])
self
.
assertEqual
(
utils
.
get_discussion_categories_ids
(
self
.
course
),
[])
def
test_ids_configured_topics
(
self
):
self
.
course
.
discussion_topics
=
{
...
...
@@ -731,7 +731,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
"Topic C"
:
{
"id"
:
"Topic_C"
}
}
self
.
assertItemsEqual
(
utils
.
get_discussion_categories_ids
(
self
.
course
,
self
.
user
),
utils
.
get_discussion_categories_ids
(
self
.
course
),
[
"Topic_A"
,
"Topic_B"
,
"Topic_C"
]
)
...
...
@@ -743,7 +743,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
self
.
create_discussion
(
"Chapter 2 / Section 1 / Subsection 2"
,
"Discussion"
)
self
.
create_discussion
(
"Chapter 3 / Section 1"
,
"Discussion"
)
self
.
assertItemsEqual
(
utils
.
get_discussion_categories_ids
(
self
.
course
,
self
.
user
),
utils
.
get_discussion_categories_ids
(
self
.
course
),
[
"discussion1"
,
"discussion2"
,
"discussion3"
,
"discussion4"
,
"discussion5"
,
"discussion6"
]
)
...
...
@@ -757,7 +757,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
self
.
create_discussion
(
"Chapter 2"
,
"Discussion"
)
self
.
create_discussion
(
"Chapter 2 / Section 1 / Subsection 1"
,
"Discussion"
)
self
.
assertItemsEqual
(
utils
.
get_discussion_categories_ids
(
self
.
course
,
self
.
user
),
utils
.
get_discussion_categories_ids
(
self
.
course
),
[
"Topic_A"
,
"Topic_B"
,
"Topic_C"
,
"discussion1"
,
"discussion2"
,
"discussion3"
]
)
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
1c272f6d
...
...
@@ -290,6 +290,23 @@ def get_discussion_categories_ids(course, user, include_all=False):
return
course
.
top_level_discussion_topic_ids
+
accessible_discussion_ids
def
get_discussion_categories_ids
(
course
):
"""
Returns a list of available ids of categories for the course.
"""
ids
=
[]
queue
=
[
get_discussion_category_map
(
course
)]
while
queue
:
category_map
=
queue
.
pop
()
for
child
in
category_map
[
"children"
]:
if
child
in
category_map
[
"entries"
]:
ids
.
append
(
category_map
[
"entries"
][
child
][
"id"
])
else
:
queue
.
append
(
category_map
[
"subcategories"
][
child
])
return
ids
class
JsonResponse
(
HttpResponse
):
def
__init__
(
self
,
data
=
None
):
content
=
json
.
dumps
(
data
,
cls
=
i4xEncoder
)
...
...
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