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
d084506d
Commit
d084506d
authored
Aug 23, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #525 from MITx/feature/arjun/comment_depth
Limiting depth of comments
parents
ec94d751
d1a8cd3f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
2 deletions
+25
-2
lms/djangoapps/django_comment_client/base/views.py
+8
-1
lms/djangoapps/django_comment_client/helpers.py
+8
-0
lms/djangoapps/django_comment_client/utils.py
+2
-0
lms/envs/common.py
+4
-0
lms/templates/discussion/mustache/_content.mustache
+3
-1
No files found.
lms/djangoapps/django_comment_client/base/views.py
View file @
d084506d
...
...
@@ -8,6 +8,8 @@ import functools
import
comment_client
as
cc
import
django_comment_client.utils
as
utils
import
django_comment_client.settings
as
cc_settings
from
django.core
import
exceptions
from
django.contrib.auth.decorators
import
login_required
...
...
@@ -15,7 +17,6 @@ from django.views.decorators.http import require_POST, require_GET
from
django.views.decorators
import
csrf
from
django.core.files.storage
import
get_storage_class
from
django.utils.translation
import
ugettext
as
_
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
...
...
@@ -114,6 +115,9 @@ def _create_comment(request, course_id, thread_id=None, parent_id=None):
@login_required
@permitted
def
create_comment
(
request
,
course_id
,
thread_id
):
if
cc_settings
.
MAX_COMMENT_DEPTH
is
not
None
:
if
cc_settings
.
MAX_COMMENT_DEPTH
<
0
:
return
JsonError
(
"Comment level too deep"
)
return
_create_comment
(
request
,
course_id
,
thread_id
=
thread_id
)
@require_POST
...
...
@@ -158,6 +162,9 @@ def openclose_thread(request, course_id, thread_id):
@login_required
@permitted
def
create_sub_comment
(
request
,
course_id
,
comment_id
):
if
cc_settings
.
MAX_COMMENT_DEPTH
is
not
None
:
if
cc_settings
.
MAX_COMMENT_DEPTH
<=
cc
.
Comment
.
find
(
comment_id
)
.
depth
:
return
JsonError
(
"Comment level too deep"
)
return
_create_comment
(
request
,
course_id
,
parent_id
=
comment_id
)
@require_POST
...
...
lms/djangoapps/django_comment_client/helpers.py
View file @
d084506d
...
...
@@ -6,6 +6,7 @@ from django.core.urlresolvers import reverse
from
functools
import
partial
from
utils
import
*
import
django_comment_client.settings
as
cc_settings
import
pystache_custom
as
pystache
import
urllib
...
...
@@ -39,6 +40,13 @@ def render_content(content, additional_context={}):
'content'
:
extend_content
(
content
),
content
[
'type'
]:
True
,
}
if
cc_settings
.
MAX_COMMENT_DEPTH
is
not
None
:
if
content
[
'type'
]
==
'thread'
:
if
cc_settings
.
MAX_COMMENT_DEPTH
<
0
:
context
[
'max_depth'
]
=
True
elif
content
[
'type'
]
==
'comment'
:
if
cc_settings
.
MAX_COMMENT_DEPTH
<=
content
[
'depth'
]:
context
[
'max_depth'
]
=
True
context
=
merge_dict
(
context
,
additional_context
)
partial_mustache_helpers
=
{
k
:
partial
(
v
,
content
)
for
k
,
v
in
mustache_helpers
.
items
()}
context
=
merge_dict
(
context
,
partial_mustache_helpers
)
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
d084506d
...
...
@@ -21,6 +21,8 @@ import pystache_custom as pystache
_FULLMODULES
=
None
_DISCUSSIONINFO
=
None
def
extract
(
dic
,
keys
):
return
{
k
:
dic
.
get
(
k
)
for
k
in
keys
}
...
...
lms/envs/common.py
View file @
d084506d
...
...
@@ -38,6 +38,10 @@ ASKBOT_ENABLED = False
GENERATE_RANDOM_USER_CREDENTIALS
=
False
PERFSTATS
=
False
DISCUSSION_SETTINGS
=
{
'MAX_COMMENT_DEPTH'
:
2
,
}
# Features
MITX_FEATURES
=
{
'SAMPLE'
:
False
,
...
...
lms/templates/discussion/mustache/_content.mustache
View file @
d084506d
...
...
@@ -51,7 +51,9 @@
{{/
thread
}}
</div>
<ul
class=
"discussion-actions"
>
<li><a
class=
"discussion-link discussion-reply discussion-reply-
{{
content
.
type
}}
"
href=
"javascript:void(0)"
>
Reply
</a></li>
{{^
max_depth
}}
<li><a
class=
"discussion-link discussion-reply discussion-reply-
{{
content
.
type
}}
"
href=
"javascript:void(0)"
>
Reply
</a></li>
{{/
max_depth
}}
{{#
thread
}}
<li><div
class=
"follow-wrapper"
><a
class=
"discussion-link discussion-follow-thread"
href=
"javascript:void(0)"
>
Follow
</a></div></li>
{{/
thread
}}
...
...
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