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
b5df53f9
Commit
b5df53f9
authored
Sep 04, 2012
by
Tom Giannattasio
Browse files
Options
Browse Files
Download
Plain Diff
fixed merge conflict
parents
5c66924f
8475ffef
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
72 additions
and
38 deletions
+72
-38
lms/djangoapps/django_comment_client/forum/views.py
+11
-11
lms/static/coffee/src/discussion/content.coffee
+8
-0
lms/static/coffee/src/discussion/discussion.coffee
+8
-1
lms/static/coffee/src/discussion/main.coffee
+1
-0
lms/static/coffee/src/discussion/models/discussion_user.coffee
+8
-0
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+6
-7
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
+23
-15
lms/static/coffee/src/discussion/views/thread_response_view.coffee
+1
-1
lms/static/js/discussions-temp.js
+5
-2
lms/templates/discussion/_underscore_templates.html
+1
-1
No files found.
lms/djangoapps/django_comment_client/forum/views.py
View file @
b5df53f9
...
...
@@ -162,22 +162,22 @@ def forum_form_discussion(request, course_id):
'discussion_data'
:
map
(
utils
.
safe_content
,
threads
),
})
else
:
recent_active_threads
=
cc
.
search_recent_active_threads
(
course_id
,
recursive
=
False
,
query_params
=
{
'follower_id'
:
request
.
user
.
id
},
)
trending_tags
=
cc
.
search_trending_tags
(
course_id
,
)
#
recent_active_threads = cc.search_recent_active_threads(
#
course_id,
#
recursive=False,
#
query_params={'follower_id': request.user.id},
#
)
#
trending_tags = cc.search_trending_tags(
#
course_id,
#
)
escapedict
=
{
'"'
:
'"'
}
context
=
{
'csrf'
:
csrf
(
request
)[
'csrf_token'
],
'course'
:
course
,
'content'
:
content
,
'recent_active_threads'
:
recent_active_threads
,
'trending_tags'
:
trending_tags
,
#
'recent_active_threads': recent_active_threads,
#
'trending_tags': trending_tags,
'staff_access'
:
has_access
(
request
.
user
,
course
,
'staff'
),
'threads'
:
saxutils
.
escape
(
json
.
dumps
(
threads
),
escapedict
),
'user_info'
:
saxutils
.
escape
(
json
.
dumps
(
user_info
),
escapedict
),
...
...
lms/static/coffee/src/discussion/content.coffee
View file @
b5df53f9
...
...
@@ -447,6 +447,14 @@ if Backbone?
@
set
(
'subscribed'
,
false
)
@
trigger
"thread:unfollow"
vote
:
->
@
get
(
"votes"
)[
"up_count"
]
=
parseInt
(
@
get
(
"votes"
)[
"up_count"
])
+
1
@
trigger
"change"
unvote
:
->
@
get
(
"votes"
)[
"up_count"
]
=
parseInt
(
@
get
(
"votes"
)[
"up_count"
])
-
1
@
trigger
"change"
display_body
:
->
if
@
has
(
"highlighted_body"
)
String
(
@
get
(
"highlighted_body"
)).
replace
(
/<highlight>/g
,
'<mark>'
).
replace
(
/<\/highlight>/g
,
'</mark>'
)
...
...
lms/static/coffee/src/discussion/discussion.coffee
View file @
b5df53f9
...
...
@@ -5,7 +5,7 @@ if Backbone?
initialize
:
->
@
bind
"add"
,
(
item
)
=>
item
.
discussion
=
@
@
comparator
=
@
sortByDate
@
comparator
=
@
sortByDate
RecentFirst
find
:
(
id
)
->
_
.
first
@
where
(
id
:
id
)
...
...
@@ -19,6 +19,13 @@ if Backbone?
sortByDate
:
(
thread
)
->
thread
.
get
(
"created_at"
)
sortByDateRecentFirst
:
(
thread
)
->
-
(
new
Date
(
thread
.
get
(
"created_at"
)).
getTime
())
#return String.fromCharCode.apply(String,
# _.map(thread.get("created_at").split(""),
# ((c) -> return 0xffff - c.charChodeAt()))
#)
sortByVotes
:
(
thread1
,
thread2
)
->
thread1_count
=
parseInt
(
thread1
.
get
(
"votes"
)[
'up_count'
])
thread2_count
=
parseInt
(
thread2
.
get
(
"votes"
)[
'up_count'
])
...
...
lms/static/coffee/src/discussion/main.coffee
View file @
b5df53f9
...
...
@@ -8,6 +8,7 @@ DiscussionApp =
threads
=
element
.
data
(
"threads"
)
content_info
=
element
.
data
(
"content-info"
)
window
.
user
=
new
DiscussionUser
(
user_info
)
console
.
log
content_info
Content
.
loadContentInfos
(
content_info
)
discussion
=
new
Discussion
(
threads
)
new
DiscussionRouter
({
discussion
:
discussion
})
...
...
lms/static/coffee/src/discussion/models/discussion_user.coffee
View file @
b5df53f9
...
...
@@ -4,3 +4,11 @@ class @DiscussionUser extends Backbone.Model
voted
:
(
thread
)
->
_
.
include
(
@
get
(
'upvoted_ids'
),
thread
.
id
)
vote
:
(
thread
)
->
@
get
(
'upvoted_ids'
).
push
(
thread
.
id
)
thread
.
vote
()
unvote
:
(
thread
)
->
@
set
(
'upvoted_ids'
,
_
.
without
(
@
get
(
'upvoted_ids'
),
thread
.
id
))
thread
.
unvote
()
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
View file @
b5df53f9
...
...
@@ -3,7 +3,7 @@ class @DiscussionThreadListView extends Backbone.View
events
:
"click .search"
:
"showSearch"
"click .browse"
:
"toggleTopicDrop"
"key
up
.post-search-field"
:
"performSearch"
"key
down
.post-search-field"
:
"performSearch"
"click .sort-bar a"
:
"sortThreads"
"click .browse-topic-drop-menu"
:
"filterTopic"
"click .browse-topic-drop-search-input"
:
"ignoreClick"
...
...
@@ -89,7 +89,7 @@ class @DiscussionThreadListView extends Backbone.View
$
(
event
.
target
).
addClass
(
"active"
)
sortBy
=
$
(
event
.
target
).
data
(
"sort"
)
if
sortBy
==
"date"
@
displayedCollection
.
comparator
=
@
displayedCollection
.
sortByDate
@
displayedCollection
.
comparator
=
@
displayedCollection
.
sortByDate
RecentFirst
else
if
sortBy
==
"votes"
@
displayedCollection
.
comparator
=
@
displayedCollection
.
sortByVotes
else
if
sortBy
==
"comments"
...
...
@@ -100,8 +100,9 @@ class @DiscussionThreadListView extends Backbone.View
clearTimeout
(
@
timer
)
@
timer
=
setTimeout
(
callback
,
ms
)
performSearch
:
->
callback
=
=>
performSearch
:
(
event
)
->
if
event
.
which
==
13
event
.
preventDefault
()
url
=
DiscussionUtil
.
urlFor
(
"search"
)
text
=
@
$
(
".post-search-field"
).
val
()
DiscussionUtil
.
safeAjax
...
...
@@ -112,6 +113,4 @@ class @DiscussionThreadListView extends Backbone.View
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
collection
.
reset
(
response
.
discussion_data
)
@
displayedCollection
.
reset
(
@
collection
)
@
delay
(
callback
,
300
)
@
displayedCollection
.
reset
(
@
collection
.
models
)
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
b5df53f9
...
...
@@ -22,22 +22,32 @@ class @DiscussionThreadView extends DiscussionContentView
template
:
_
.
template
(
$
(
"#thread-template"
).
html
())
initialize
:
->
@
model
.
on
"change"
,
@
updateModelDetails
render
:
->
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
@
model
.
bind
"change"
,
@
updateModelDetails
if
window
.
user
.
following
(
@
model
)
@
$
(
".dogear"
).
addClass
(
"is-followed"
)
if
window
.
user
.
voted
(
@
model
)
@
$
(
".vote-btn"
).
addClass
(
"is-cast"
)
@
renderDogear
()
@
renderVoted
()
@
$
(
"span.timeago"
).
timeago
()
Markdown
.
makeWmdEditor
@
$
(
".reply-body"
),
""
,
DiscussionUtil
.
urlFor
(
"upload"
),
(
text
)
->
DiscussionUtil
.
postMathJaxProcessor
(
text
)
@
convertMath
()
@
renderResponses
()
@
renderDogear
:
->
if
window
.
user
.
following
(
@
model
)
@
$
(
".dogear"
).
addClass
(
"is-followed"
)
renderVoted
:
=>
if
window
.
user
.
voted
(
@
model
)
@
$
(
"[data-role=discussion-vote]"
).
addClass
(
"is-cast"
)
else
@
$
(
"[data-role=discussion-vote]"
).
removeClass
(
"is-cast"
)
updateModelDetails
:
=>
@
$
(
".discussion-vote .votes-count-number"
).
html
(
@
model
.
get
(
"votes"
)[
"up_count"
])
@
renderVoted
()
@
$
(
"[data-role=discussion-vote] .votes-count-number"
).
html
(
@
model
.
get
(
"votes"
)[
"up_count"
])
convertMath
:
->
element
=
@
$
(
".post-body"
)
...
...
@@ -64,10 +74,10 @@ class @DiscussionThreadView extends DiscussionContentView
toggleVote
:
(
event
)
->
event
.
preventDefault
()
if
not
@
model
.
get
(
'voted'
)
#@$(".discussion-vote").hasClass("is-cast")
@
vote
()
else
if
window
.
user
.
voted
(
@
model
)
@
unvote
()
else
@
vote
()
toggleFollowing
:
(
event
)
->
$elem
=
$
(
event
.
target
)
...
...
@@ -84,9 +94,8 @@ class @DiscussionThreadView extends DiscussionContentView
type
:
"POST"
vote
:
->
window
.
user
.
vote
(
@
model
)
url
=
@
model
.
urlFor
(
"upvote"
)
@
model
.
set
(
'votes_point'
,
parseInt
(
@
model
.
get
(
'votes_point'
))
+
1
)
#@$(".discussion-vote .votes-count-number").html(parseInt(@$(".discussion-vote .votes-count-number").html()) + 1)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-vote"
)
url
:
url
...
...
@@ -96,9 +105,8 @@ class @DiscussionThreadView extends DiscussionContentView
@
model
.
set
(
response
)
unvote
:
->
window
.
user
.
unvote
(
@
model
)
url
=
@
model
.
urlFor
(
"unvote"
)
@
model
.
set
(
'votes_point'
,
parseInt
(
@
model
.
get
(
'votes_point'
))
-
1
)
#@$(".discussion-vote .votes-count-number").html(parseInt(@$(".discussion-vote .votes-count-number").html()) - 1)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-vote"
)
url
:
url
...
...
@@ -111,7 +119,7 @@ class @DiscussionThreadView extends DiscussionContentView
event
.
preventDefault
()
url
=
@
model
.
urlFor
(
'reply'
)
body
=
@
$
(
"#wmd-input"
).
val
()
response
=
new
Comment
(
body
:
body
,
created_at
:
(
new
Date
()).
toISOString
(),
username
:
window
.
user
.
get
(
"username"
),
votes
:
{
up_count
:
0
},
endorsed
:
false
)
response
=
new
Comment
(
body
:
body
,
created_at
:
(
new
Date
()).
toISOString
(),
username
:
window
.
user
.
get
(
"username"
),
votes
:
{
up_count
:
0
},
endorsed
:
false
,
user_id
:
window
.
user
.
get
(
"id"
)
)
@
renderResponse
(
response
)
@
addComment
()
...
...
lms/static/coffee/src/discussion/views/thread_response_view.coffee
View file @
b5df53f9
...
...
@@ -65,7 +65,7 @@ class @ThreadResponseView extends DiscussionContentView
body
=
@
$
(
".comment-form-input"
).
val
()
if
not
body
.
trim
().
length
return
comment
=
new
Comment
(
body
:
body
,
created_at
:
(
new
Date
()).
toISOString
(),
username
:
window
.
user
.
get
(
"username"
))
comment
=
new
Comment
(
body
:
body
,
created_at
:
(
new
Date
()).
toISOString
(),
username
:
window
.
user
.
get
(
"username"
)
,
user_id
:
window
.
user
.
get
(
"id"
)
)
@
renderComment
(
comment
)
@
trigger
"comment:add"
@
$
(
".comment-form-input"
).
val
(
""
)
...
...
lms/static/js/discussions-temp.js
View file @
b5df53f9
...
...
@@ -69,6 +69,10 @@ $(document).ready(function() {
$
(
window
).
bind
(
'resize'
,
updateSidebar
);
$
(
window
).
bind
(
'scroll'
,
updateSidebar
);
$
(
'.discussion-column'
).
bind
(
"input"
,
function
(
e
)
{
console
.
log
(
"resized"
);
updateSidebar
();
})
updateSidebar
();
});
...
...
@@ -349,4 +353,4 @@ function updateSidebar(e) {
// update title wrappers
var
titleWidth
=
sidebarWidth
-
115
;
$sidebarWidthStyles
.
html
(
'.discussion-body .post-list a .title { width: '
+
titleWidth
+
'px !important; }'
);
}
\ No newline at end of file
}
lms/templates/discussion/_underscore_templates.html
View file @
b5df53f9
...
...
@@ -3,7 +3,7 @@
<
a
href
=
"javascript:void(0)"
class
=
"dogear action-follow"
><
/a
>
<
div
class
=
"discussion-post"
>
<
header
>
<
a
href
=
"#"
class
=
"vote-btn discussion-vote discussion-vote-up"
><
span
class
=
"plus-icon"
>+<
/span> <span class='votes-count-number'>${'<%- votes
[
"up_count"
]
%>'}</
span
><
/a
>
<
a
href
=
"#"
class
=
"vote-btn discussion-vote discussion-vote-up"
data
-
role
=
"discussion-vote"
><
span
class
=
"plus-icon"
>+<
/span> <span class='votes-count-number'>${'<%- votes
[
"up_count"
]
%>'}</
span
><
/a
>
<
h1
>
$
{
'<%- title %>'
}
<
/h1
>
<
p
class
=
"posted-details"
>
<
span
class
=
"timeago"
title
=
"${'<%- created_at %>'}"
>
$
{
'<%- created_at %>'
}
<
/span> b
y
...
...
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