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