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
a06cc229
Commit
a06cc229
authored
Jul 24, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
watch/unwatch threads; display current vote
parent
8c3931ba
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
134 additions
and
35 deletions
+134
-35
lms/djangoapps/django_comment_client/base/urls.py
+10
-3
lms/djangoapps/django_comment_client/base/views.py
+40
-1
lms/djangoapps/django_comment_client/forum/views.py
+8
-5
lms/static/coffee/src/discussion.coffee
+71
-20
lms/static/sass/_discussion.scss
+3
-0
lms/templates/discussion/index.html
+2
-3
lms/templates/discussion/thread.html
+0
-3
No files found.
lms/djangoapps/django_comment_client/base/urls.py
View file @
a06cc229
...
...
@@ -2,16 +2,23 @@ from django.conf.urls.defaults import url, patterns
import
django_comment_client.base.views
urlpatterns
=
patterns
(
'django_comment_client.base.views'
,
url
(
r'(?P<commentable_id>[\w\-]+)/threads/create$'
,
'create_thread'
,
name
=
'create_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/update$'
,
'update_thread'
,
name
=
'update_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/reply$'
,
'create_comment'
,
name
=
'create_comment'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/delete'
,
'delete_thread'
,
name
=
'delete_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/upvote$'
,
'vote_for_thread'
,
{
'value'
:
'up'
},
name
=
'upvote_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/downvote$'
,
'vote_for_thread'
,
{
'value'
:
'down'
},
name
=
'downvote_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/watch$'
,
'watch_thread'
,
name
=
'watch_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/unwatch$'
,
'unwatch_thread'
,
name
=
'unwatch_thread'
),
url
(
r'comments/(?P<comment_id>[\w\-]+)/update$'
,
'update_comment'
,
name
=
'update_comment'
),
url
(
r'comments/(?P<comment_id>[\w\-]+)/endorse$'
,
'endorse_comment'
,
name
=
'endorse_comment'
),
url
(
r'comments/(?P<comment_id>[\w\-]+)/reply$'
,
'create_sub_comment'
,
name
=
'create_sub_comment'
),
url
(
r'comments/(?P<comment_id>[\w\-]+)/delete$'
,
'delete_comment'
,
name
=
'delete_comment'
),
url
(
r'comments/(?P<comment_id>[\w\-]+)/upvote$'
,
'vote_for_comment'
,
{
'value'
:
'up'
},
name
=
'upvote_comment'
),
url
(
r'comments/(?P<comment_id>[\w\-]+)/downvote$'
,
'vote_for_comment'
,
{
'value'
:
'down'
},
name
=
'downvote_comment'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/upvote$'
,
'vote_for_thread'
,
{
'value'
:
'up'
},
name
=
'upvote_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/downvote$'
,
'vote_for_thread'
,
{
'value'
:
'down'
},
name
=
'downvote_thread'
),
url
(
r'(?P<commentable_id>[\w\-]+)/threads/create$'
,
'create_thread'
,
name
=
'create_thread'
),
url
(
r'(?P<commentable_id>[\w\-]+)/watch$'
,
'watch_commentable'
,
name
=
'watch_commentable'
),
url
(
r'(?P<commentable_id>[\w\-]+)/unwatch$'
,
'unwatch_commentable'
,
name
=
'unwatch_commentable'
),
)
lms/djangoapps/django_comment_client/base/views.py
View file @
a06cc229
...
...
@@ -129,8 +129,47 @@ def vote_for_thread(request, thread_id, value):
response
=
comment_client
.
vote_for_thread
(
thread_id
,
user_id
,
value
)
return
JsonResponse
(
response
)
#undo vote: disabled for now
@login_required
@require_POST
def
watch_thread
(
request
,
thread_id
):
user_id
=
request
.
user
.
id
response
=
comment_client
.
subscribe_thread
(
user_id
,
thread_id
)
return
JsonResponse
(
response
)
@login_required
@require_POST
def
watch_commentable
(
request
,
commentable_id
):
user_id
=
request
.
user
.
id
response
=
comment_client
.
subscribe_commentable
(
user_id
,
commentable_id
)
return
JsonResponse
(
response
)
@login_required
@require_POST
def
follow
(
request
,
followed_user_id
):
user_id
=
request
.
user
.
id
response
=
comment_client
.
follow
(
user_id
,
followed_user_id
)
return
JsonResponse
(
response
)
@login_required
@require_POST
def
unwatch_thread
(
request
,
thread_id
):
user_id
=
request
.
user
.
id
response
=
comment_client
.
unsubscribe_thread
(
user_id
,
thread_id
)
return
JsonResponse
(
response
)
@login_required
@require_POST
def
unwatch_commentable
(
request
,
commentable_id
):
user_id
=
request
.
user
.
id
response
=
comment_client
.
unsubscribe_commentable
(
user_id
,
commentable_id
)
return
JsonResponse
(
response
)
@login_required
@require_POST
def
unfollow
(
request
,
followed_user_id
):
user_id
=
request
.
user
.
id
response
=
comment_client
.
unfollow
(
user_id
,
followed_user_id
)
return
JsonResponse
(
response
)
@login_required
@require_GET
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
a06cc229
...
...
@@ -22,6 +22,7 @@ from datehelper import time_ago_in_words
import
operator
import
itertools
import
json
_FULLMODULES
=
None
_DISCUSSIONINFO
=
None
...
...
@@ -80,11 +81,12 @@ def get_categorized_discussion_info(request, user, course, course_name, url_cour
return
_DISCUSSIONINFO
def
render_accordion
(
request
,
course
,
discussion_info
,
discussion_id
):
context
=
dict
([
(
'course'
,
course
),
(
'discussion_info'
,
discussion_info
),
(
'active'
,
discussion_id
),
# TODO change this later
(
'csrf'
,
csrf
(
request
)[
'csrf_token'
])])
context
=
{
'course'
:
course
,
'discussion_info'
:
discussion_info
,
'active'
:
discussion_id
,
'csrf'
:
csrf
(
request
)[
'csrf_token'
],
}
return
render_to_string
(
'discussion/accordion.html'
,
context
)
...
...
@@ -147,6 +149,7 @@ def single_thread(request, thread_id):
'init'
:
''
,
'content'
:
render_single_thread
(
request
,
thread_id
),
'accordion'
:
''
,
'user_info'
:
json
.
dumps
(
comment_client
.
get_user_info
(
request
.
user
.
id
)),
}
return
render_to_response
(
'discussion/index.html'
,
context
)
...
...
lms/static/coffee/src/discussion.coffee
View file @
a06cc229
...
...
@@ -9,38 +9,93 @@ $ ->
$
(
'#open_close_accordion a'
).
click
@
toggle
$
(
'#accordion'
).
show
()
$
(
"section.discussion"
).
each
(
index
,
discussion
)
->
Discussion
.
bindDiscussionEvents
(
discussion
)
Discussion
.
initializeDiscussion
(
discussion
)
generateLocal
=
(
elem
)
->
(
selector
)
->
$
(
elem
).
find
(
selector
)
generateDiscussionLink
=
(
cls
,
txt
,
handler
)
->
$
(
"<a>"
).
addClass
(
"discussion-link"
).
attr
(
"href"
,
"javascript:void(0)"
).
addClass
(
cls
).
html
(
txt
).
click
(
->
handler
(
this
))
Discussion
=
urlFor
:
(
name
,
param
)
->
{
create_thread
:
"/discussions/
#{
param
}
/threads/create"
update_thread
:
"/discussions/threads/
#{
param
}
/update"
create_comment
:
"/discussions/threads/
#{
param
}
/reply"
delete_thread
:
"/discussions/threads/
#{
param
}
/delete"
update_comment
:
"/discussions/comments/
#{
param
}
/update"
endorse_comment
:
"/discussions/comments/
#{
param
}
/endorse"
create_sub_comment
:
"/discussions/comments/
#{
param
}
/reply"
delete_comment
:
"/discussions/comments/
#{
param
}
/delete"
upvote_comment
:
"/discussions/comments/
#{
param
}
/upvote"
downvote_comment
:
"/discussions/comments/
#{
param
}
/downvote"
upvote_thread
:
"/discussions/threads/
#{
param
}
/upvote"
downvote_thread
:
"/discussions/threads/
#{
param
}
/downvote"
search
:
"/discussions/forum/search"
watch_commentable
:
"/discussions/
#{
param
}
/watch"
unwatch_commentable
:
"/discussions/
#{
param
}
/unwatch"
create_thread
:
"/discussions/
#{
param
}
/threads/create"
update_thread
:
"/discussions/threads/
#{
param
}
/update"
create_comment
:
"/discussions/threads/
#{
param
}
/reply"
delete_thread
:
"/discussions/threads/
#{
param
}
/delete"
upvote_thread
:
"/discussions/threads/
#{
param
}
/upvote"
downvote_thread
:
"/discussions/threads/
#{
param
}
/downvote"
watch_thread
:
"/discussions/threads/
#{
param
}
/watch"
unwatch_thread
:
"/discussions/threads/
#{
param
}
/unwatch"
update_comment
:
"/discussions/comments/
#{
param
}
/update"
endorse_comment
:
"/discussions/comments/
#{
param
}
/endorse"
create_sub_comment
:
"/discussions/comments/
#{
param
}
/reply"
delete_comment
:
"/discussions/comments/
#{
param
}
/delete"
upvote_comment
:
"/discussions/comments/
#{
param
}
/upvote"
downvote_comment
:
"/discussions/comments/
#{
param
}
/downvote"
search
:
"/discussions/forum/search"
}[
name
]
handleAnchorAndReload
:
(
response
)
->
#window.location = window.location.pathname + "#" + response['id']
window
.
location
.
reload
()
initializeDiscussion
:
(
discussion
)
->
initializeVote
=
(
index
,
content
)
->
$content
=
$
(
content
)
$local
=
generateLocal
(
$content
.
children
(
".discussion-content"
))
id
=
$content
.
attr
(
"_id"
)
if
id
in
user_info
.
upvoted_ids
$local
(
".discussion-vote-up"
).
addClass
(
"voted"
)
else
if
id
in
user_info
.
downvoted_ids
$local
(
".discussion-vote-down"
).
addClass
(
"voted"
)
initializeWatchThreads
=
(
index
,
thread
)
->
$thread
=
$
(
thread
)
id
=
$thread
.
attr
(
"_id"
)
$local
=
generateLocal
(
$thread
.
children
(
".discussion-content"
))
handleWatchThread
=
(
elem
)
->
url
=
Discussion
.
urlFor
(
'watch_thread'
,
id
)
console
.
log
url
$
.
post
url
,
{},
(
response
,
textStatus
)
->
if
textStatus
==
"success"
Discussion
.
handleAnchorAndReload
(
response
)
,
'json'
handleUnwatchThread
=
(
elem
)
->
url
=
Discussion
.
urlFor
(
'unwatch_thread'
,
id
)
$
.
post
url
,
{},
(
response
,
textStatus
)
->
if
textStatus
==
"success"
Discussion
.
handleAnchorAndReload
(
response
)
,
'json'
if
id
in
user_info
.
subscribed_thread_ids
unwatchThread
=
generateDiscussionLink
(
"discussion-unwatch-thread"
,
"Unwatch"
,
handleUnwatchThread
)
$local
(
".info"
).
append
(
unwatchThread
)
else
watchThread
=
generateDiscussionLink
(
"discussion-watch-thread"
,
"Watch"
,
handleWatchThread
)
$local
(
".info"
).
append
(
watchThread
)
if
user_info
?
$
(
discussion
).
find
(
".comment"
).
each
(
initializeVote
)
$
(
discussion
).
find
(
".thread"
).
each
(
initializeVote
).
each
(
initializeWatchThreads
)
bindContentEvents
:
(
content
)
->
$content
=
$
(
content
)
$discussionContent
=
$content
.
children
(
".discussion-content"
)
$local
=
(
selector
)
->
$discussionContent
.
find
(
selector
)
$local
=
generateLocal
(
$discussionContent
)
discussionContentHoverIn
=
->
status
=
$discussionContent
.
attr
(
"status"
)
||
"normal"
...
...
@@ -58,11 +113,7 @@ Discussion =
$discussionContent
.
hover
(
discussionContentHoverIn
,
discussionContentHoverOut
)
generateDiscussionLink
=
(
cls
,
txt
,
handler
)
->
$
(
"<a>"
).
addClass
(
"discussion-link"
).
attr
(
"href"
,
"javascript:void(0)"
).
addClass
(
cls
).
html
(
txt
).
click
(
->
handler
(
this
))
handleReply
=
(
elem
)
->
editView
=
$local
(
".discussion-content-edit"
)
...
...
lms/static/sass/_discussion.scss
View file @
a06cc229
...
...
@@ -66,6 +66,9 @@ $discussion_input_width: 60%;
&
.discussion-vote-down
{
margin-top
:
3px
;
}
&
.voted
{
color
:
#1d9dd9
;
}
}
}
.discussion-right-wrapper
{
...
...
lms/templates/discussion/index.html
View file @
a06cc229
...
...
@@ -8,11 +8,10 @@
</
%
block>
<
%
block
name=
"js_extra"
>
<!-- TODO: http://docs.jquery.com/Plugins/Validation -->
<script
type=
"text/javascript"
>
document
.
write
(
'
\
x3Cscript type="text/javascript" src="'
+
document
.
location
.
protocol
+
'//www.youtube.com/player_api">
\
x3C/script>'
);
var
user_info
=
JSON
.
parse
(
'${user_info}'
);
</script>
</
%
block>
##
<
%
include
file=
"../course_navigation.html"
args=
"active_page='discussion'"
/>
...
...
lms/templates/discussion/thread.html
View file @
a06cc229
...
...
@@ -2,8 +2,6 @@
<
%!
from
datehelper
import
time_ago_in_words
%
>
<
%!
from
dateutil
.
parser
import
parse
%
>
<
%
def
name=
"render_thread(thread, edit_thread=False, show_comments=False)"
>
<
%
if
show_comments:
...
...
@@ -24,7 +22,6 @@
% if edit_thread:
${render_reply()}
${render_edit()}
${render_watch_thread()}
% endif
</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