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
11e3276e
Commit
11e3276e
authored
Aug 21, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update comment count based on operations
parent
273af4a5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
10 deletions
+30
-10
lms/djangoapps/django_comment_client/mustache_helpers.py
+2
-2
lms/static/coffee/src/backbone_discussion/content.coffee
+24
-4
lms/static/sass/_discussion.scss
+1
-1
lms/templates/discussion/mustache/_content.mustache
+3
-3
No files found.
lms/djangoapps/django_comment_client/mustache_helpers.py
View file @
11e3276e
...
...
@@ -6,9 +6,9 @@ import inspect
def
pluralize
(
content
,
text
):
num
,
word
=
text
.
split
(
' '
)
if
int
(
num
or
'0'
)
>=
2
:
return
num
+
' '
+
word
+
's'
return
word
+
's'
else
:
return
num
+
' '
+
word
return
word
def
url_for_user
(
content
,
user_id
):
return
urlresolvers
.
reverse
(
'django_comment_client.forum.views.user_profile'
,
args
=
[
content
[
'course_id'
],
user_id
])
...
...
lms/static/coffee/src/backbone_discussion/content.coffee
View file @
11e3276e
...
...
@@ -22,17 +22,27 @@ class @Content extends Backbone.Model
@
set
(
'voted'
,
info
.
voted
)
@
set
(
'subscribed'
,
info
.
subscribed
)
addComment
:
(
comment
)
->
addComment
:
(
comment
,
options
)
->
options
||=
{}
if
not
options
.
silent
thread
=
@
get
(
'thread'
)
comments_count
=
parseInt
(
thread
.
get
(
'comments_count'
))
thread
.
set
(
'comments_count'
,
comments_count
+
1
)
@
get
(
'children'
).
push
comment
model
=
new
Comment
$
.
extend
{},
comment
,
{
thread
:
@
get
(
'thread'
)
}
@
get
(
'comments'
).
add
model
model
removeComment
:
(
comment
)
->
thread
=
@
get
(
'thread'
)
comments_count
=
parseInt
(
thread
.
get
(
'comments_count'
))
thread
.
set
(
'comments_count'
,
comments_count
-
1
-
comment
.
getCommentsCount
())
resetComments
:
(
children
)
->
@
set
'children'
,
[]
@
set
'comments'
,
new
Comments
()
for
comment
in
(
children
||
[])
@
addComment
comment
@
addComment
comment
,
{
silent
:
true
}
initialize
:
->
DiscussionUtil
.
addContent
@
id
,
@
...
...
@@ -66,6 +76,9 @@ class @ContentView extends Backbone.View
votes_point
:
(
votes_point
)
->
@
$
(
".discussion-votes-point"
).
html
(
votes_point
)
comments_count
:
(
comments_count
)
->
@
$
(
".comments-count"
).
html
(
comments_count
)
subscribed
:
(
subscribed
)
->
#later
...
...
@@ -270,8 +283,9 @@ class @ContentView extends Backbone.View
if
not
c
return
$elem
=
$
(
event
.
target
)
DiscussionUtil
.
post
$elem
,
url
,
{},
(
response
,
textStatus
)
=>
@
$el
.
remove
()
#TODO also do data-wise operation
DiscussionUtil
.
post
$elem
,
url
,
{},
(
response
,
textStatus
)
=>
@
$el
.
remove
()
@
model
.
get
(
'thread'
).
removeComment
(
@
model
)
events
:
"click .thread-title"
:
"toggleSingleThread"
...
...
@@ -354,6 +368,12 @@ class @Comment extends @Content
discussion_id
=
@
get
(
'thread'
).
get
(
'commentable_id'
)
return
Discussion
.
urlFor
(
"permanent_link_comment"
,
discussion_id
,
thread_id
,
@
id
)
getCommentsCount
:
->
count
=
0
@
get
(
'comments'
).
each
(
comment
)
->
count
+=
comment
.
getCommentsCount
()
+
1
count
class
@
CommentView
extends
@
ContentView
class
@
Comments
extends
Backbone
.
Collection
...
...
lms/static/sass/_discussion.scss
View file @
11e3276e
...
...
@@ -340,7 +340,7 @@ $tag-text-color: #5b614f;
margin-right
:
1em
;
}
.
comment-count
{
.
show-comments-wrapper
{
display
:
inline
;
margin-right
:
20px
;
}
...
...
lms/templates/discussion/mustache/_content.mustache
View file @
11e3276e
...
...
@@ -40,13 +40,13 @@
<a
href=
"
{{#
#
url_for_user
}}{{
content
.
user_id
}}{{/
url_for_user
}}
"
>
{{
content
.
username
}}
</a>
{{/
content
.
anonymous
}}
</div>
<div
class=
"
comment-count
"
>
<div
class=
"
show-comments-wrapper
"
>
{{#
thread
}}
{{#
partial_comments
}}
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments first-time"
>
Show all comments (
{{
content
.
comments_count
}}
total)
</a>
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments first-time"
>
Show all comments (
<span
class=
"comments-count"
>
{{
content
.
comments_count
}}
</span>
total)
</a>
{{/
partial_comments
}}
{{^
partial_comments
}}
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments"
>
Show
{{#
#
pluralize
}}{{
content
.
comments_count
}}
comment
{{/
pluralize
}}
</a>
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments"
>
Show
<span
class=
"comments-count"
>
{{
content
.
comments_count
}}
</span>
{{#
#
pluralize
}}{{
content
.
comments_count
}}
comment
{{/
pluralize
}}
</a>
{{/
partial_comments
}}
{{/
thread
}}
</div>
...
...
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