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
4ac3eebc
Commit
4ac3eebc
authored
Aug 03, 2012
by
Brittany Cheng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:dementrock/mitx into discussion2
parents
ec258a63
9b2578c7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
22 deletions
+50
-22
lms/djangoapps/django_comment_client/base/views.py
+23
-5
lms/djangoapps/django_comment_client/forum/views.py
+1
-1
lms/static/coffee/src/discussion/content.coffee
+7
-10
lms/static/coffee/src/discussion/discussion.coffee
+1
-1
lms/static/coffee/src/discussion/utils.coffee
+18
-5
lms/templates/discussion/ajax_create_comment.html
+0
-0
lms/templates/discussion/ajax_create_thread.html
+0
-0
No files found.
lms/djangoapps/django_comment_client/base/views.py
View file @
4ac3eebc
...
@@ -38,7 +38,7 @@ def comment_author_only(fn):
...
@@ -38,7 +38,7 @@ def comment_author_only(fn):
return
JsonError
(
"unauthorized"
)
return
JsonError
(
"unauthorized"
)
return
verified_fn
return
verified_fn
def
instructor_only
(
fn
):
#TODO add instructor verification
def
instructor_only
(
fn
):
def
verified_fn
(
request
,
*
args
,
**
kwargs
):
def
verified_fn
(
request
,
*
args
,
**
kwargs
):
if
not
request
.
user
.
is_staff
:
if
not
request
.
user
.
is_staff
:
return
JsonError
(
"unauthorized"
)
return
JsonError
(
"unauthorized"
)
...
@@ -46,8 +46,6 @@ def instructor_only(fn): #TODO add instructor verification
...
@@ -46,8 +46,6 @@ def instructor_only(fn): #TODO add instructor verification
return
fn
(
request
,
*
args
,
**
kwargs
)
return
fn
(
request
,
*
args
,
**
kwargs
)
return
verified_fn
return
verified_fn
@login_required
@login_required
@require_POST
@require_POST
def
create_thread
(
request
,
course_id
,
commentable_id
):
def
create_thread
(
request
,
course_id
,
commentable_id
):
...
@@ -64,9 +62,10 @@ def create_thread(request, course_id, commentable_id):
...
@@ -64,9 +62,10 @@ def create_thread(request, course_id, commentable_id):
'course_id'
:
course_id
,
'course_id'
:
course_id
,
'thread'
:
response
,
'thread'
:
response
,
}
}
html
=
render_to_string
(
'discussion/ajax_
thread_only
.html'
,
context
)
html
=
render_to_string
(
'discussion/ajax_
create_thread
.html'
,
context
)
return
JsonResponse
({
return
JsonResponse
({
'html'
:
html
,
'html'
:
html
,
'content'
:
response
,
})
})
else
:
else
:
return
JsonResponse
(
response
)
return
JsonResponse
(
response
)
...
@@ -77,6 +76,15 @@ def create_thread(request, course_id, commentable_id):
...
@@ -77,6 +76,15 @@ def create_thread(request, course_id, commentable_id):
def
update_thread
(
request
,
course_id
,
thread_id
):
def
update_thread
(
request
,
course_id
,
thread_id
):
attributes
=
extract
(
request
.
POST
,
[
'body'
,
'title'
,
'tags'
])
attributes
=
extract
(
request
.
POST
,
[
'body'
,
'title'
,
'tags'
])
response
=
comment_client
.
update_thread
(
thread_id
,
attributes
)
response
=
comment_client
.
update_thread
(
thread_id
,
attributes
)
if
response
.
is_ajax
():
context
=
{
'thread'
:
response
,
}
html
=
render_to_string
(
'discussion/ajax_update_thread.html'
,
context
)
return
JsonResponse
({
'html'
:
html
,
'content'
:
response
,
})
return
JsonResponse
(
response
)
return
JsonResponse
(
response
)
def
_create_comment
(
request
,
course_id
,
_response_from_attributes
):
def
_create_comment
(
request
,
course_id
,
_response_from_attributes
):
...
@@ -92,9 +100,10 @@ def _create_comment(request, course_id, _response_from_attributes):
...
@@ -92,9 +100,10 @@ def _create_comment(request, course_id, _response_from_attributes):
context
=
{
context
=
{
'comment'
:
response
,
'comment'
:
response
,
}
}
html
=
render_to_string
(
'discussion/ajax_c
omment_only
.html'
,
context
)
html
=
render_to_string
(
'discussion/ajax_c
reate_comment
.html'
,
context
)
return
JsonResponse
({
return
JsonResponse
({
'html'
:
html
,
'html'
:
html
,
'content'
:
response
,
})
})
else
:
else
:
return
JsonResponse
(
response
)
return
JsonResponse
(
response
)
...
@@ -119,6 +128,15 @@ def delete_thread(request, course_id, thread_id):
...
@@ -119,6 +128,15 @@ def delete_thread(request, course_id, thread_id):
def
update_comment
(
request
,
course_id
,
comment_id
):
def
update_comment
(
request
,
course_id
,
comment_id
):
attributes
=
extract
(
request
.
POST
,
[
'body'
])
attributes
=
extract
(
request
.
POST
,
[
'body'
])
response
=
comment_client
.
update_comment
(
comment_id
,
attributes
)
response
=
comment_client
.
update_comment
(
comment_id
,
attributes
)
if
response
.
is_ajax
():
context
=
{
'comment'
:
response
,
}
html
=
render_to_string
(
'discussion/ajax_update_comment.html'
,
context
)
return
JsonResponse
({
'html'
:
html
,
'content'
:
response
,
})
return
JsonResponse
(
response
)
return
JsonResponse
(
response
)
@instructor_only
@instructor_only
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
4ac3eebc
...
@@ -19,7 +19,7 @@ import comment_client
...
@@ -19,7 +19,7 @@ import comment_client
import
dateutil
import
dateutil
THREADS_PER_PAGE
=
20
THREADS_PER_PAGE
=
5
PAGES_NEARBY_DELTA
=
2
PAGES_NEARBY_DELTA
=
2
def
render_accordion
(
request
,
course
,
discussion_id
):
def
render_accordion
(
request
,
course
,
discussion_id
):
...
...
lms/static/coffee/src/discussion/content.coffee
View file @
4ac3eebc
...
@@ -25,10 +25,9 @@ Discussion = @Discussion
...
@@ -25,10 +25,9 @@ Discussion = @Discussion
}
}
$discussionContent
.
append
Mustache
.
render
Discussion
.
replyTemplate
,
view
$discussionContent
.
append
Mustache
.
render
Discussion
.
replyTemplate
,
view
Discussion
.
makeWmdEditor
$content
,
$local
,
"reply-body"
Discussion
.
makeWmdEditor
$content
,
$local
,
"reply-body"
$local
(
".discussion-reply"
).
hide
()
$local
(
".discussion-submit-post"
).
click
->
handleSubmitReply
(
this
)
$local
(
".discussion-submit-post"
).
click
->
handleSubmitReply
(
this
)
$local
(
".discussion-cancel-post"
).
click
->
handleCancelReply
(
this
)
$local
(
".discussion-cancel-post"
).
click
->
handleCancelReply
(
this
)
$local
(
".discussion-link"
).
hide
()
$discussionContent
.
attr
(
"status"
,
"reply"
)
handleCancelReply
=
(
elem
)
->
handleCancelReply
=
(
elem
)
->
$replyView
=
$local
(
".discussion-reply-new"
)
$replyView
=
$local
(
".discussion-reply-new"
)
...
@@ -36,7 +35,7 @@ Discussion = @Discussion
...
@@ -36,7 +35,7 @@ Discussion = @Discussion
$replyView
.
hide
()
$replyView
.
hide
()
#reply = Discussion.generateDiscussionLink("discussion-reply", "Reply", handleReply)
#reply = Discussion.generateDiscussionLink("discussion-reply", "Reply", handleReply)
#$(elem).replaceWith(reply)
#$(elem).replaceWith(reply)
$
discussionContent
.
attr
(
"status"
,
"normal"
)
$
local
(
".discussion-reply"
).
show
(
)
handleSubmitReply
=
(
elem
)
->
handleSubmitReply
=
(
elem
)
->
if
$content
.
hasClass
(
"thread"
)
if
$content
.
hasClass
(
"thread"
)
...
@@ -61,13 +60,14 @@ Discussion = @Discussion
...
@@ -61,13 +60,14 @@ Discussion = @Discussion
anonymous
:
anonymous
anonymous
:
anonymous
autowatch
:
autowatch
autowatch
:
autowatch
success
:
Discussion
.
formErrorHandler
(
$local
(
".discussion-errors"
),
(
response
,
textStatus
)
->
success
:
Discussion
.
formErrorHandler
(
$local
(
".discussion-errors"
),
(
response
,
textStatus
)
->
console
.
log
response
$comment
=
$
(
response
.
html
)
$comment
=
$
(
response
.
html
)
$content
.
children
(
".comments"
).
prepend
(
$comment
)
$content
.
children
(
".comments"
).
prepend
(
$comment
)
Discussion
.
setWmdContent
$content
,
$local
,
"reply-body"
,
""
Discussion
.
setWmdContent
$content
,
$local
,
"reply-body"
,
""
Discussion
.
setContentInfo
response
.
content
[
'id'
],
'editable'
,
true
Discussion
.
initializeContent
(
$comment
)
Discussion
.
initializeContent
(
$comment
)
Discussion
.
bindContentEvents
(
$comment
)
Discussion
.
bindContentEvents
(
$comment
)
$local
(
".discussion-reply-new"
).
hide
()
$local
(
".discussion-reply-new"
).
hide
()
$local
(
".discussion-reply"
).
show
()
$discussionContent
.
attr
(
"status"
,
"normal"
)
$discussionContent
.
attr
(
"status"
,
"normal"
)
)
)
...
@@ -189,9 +189,7 @@ Discussion = @Discussion
...
@@ -189,9 +189,7 @@ Discussion = @Discussion
type
:
"GET"
type
:
"GET"
dataType
:
'json'
dataType
:
'json'
success
:
(
response
,
textStatus
)
->
success
:
(
response
,
textStatus
)
->
if
not
$$annotated_content_info
?
Discussion
.
bulkExtendContentInfo
response
[
'annotated_content_info'
]
window
.
$
$annotated_content_info
=
{}
window
.
$
$annotated_content_info
=
$
.
extend
$$annotated_content_info
,
response
[
'annotated_content_info'
]
$content
.
append
(
response
[
'html'
])
$content
.
append
(
response
[
'html'
])
$content
.
find
(
".comment"
).
each
(
index
,
comment
)
->
$content
.
find
(
".comment"
).
each
(
index
,
comment
)
->
Discussion
.
initializeContent
(
comment
)
Discussion
.
initializeContent
(
comment
)
...
@@ -240,6 +238,5 @@ Discussion = @Discussion
...
@@ -240,6 +238,5 @@ Discussion = @Discussion
$contentBody
.
html
(
converter
.
makeHtml
(
raw_text
))
$contentBody
.
html
(
converter
.
makeHtml
(
raw_text
))
MathJax
.
Hub
.
Queue
[
"Typeset"
,
MathJax
.
Hub
,
$contentBody
.
attr
(
"id"
)]
MathJax
.
Hub
.
Queue
[
"Typeset"
,
MathJax
.
Hub
,
$contentBody
.
attr
(
"id"
)]
id
=
$content
.
attr
(
"_id"
)
id
=
$content
.
attr
(
"_id"
)
if
$$annotated_content_info
?
if
not
Discussion
.
getContentInfo
id
,
'editable'
if
not
(
$$annotated_content_info
[
id
]
||
[])[
'editable'
]
$local
(
".discussion-edit"
).
remove
()
$local
(
".discussion-edit"
).
remove
()
lms/static/coffee/src/discussion/discussion.coffee
View file @
4ac3eebc
...
@@ -104,10 +104,10 @@ initializeFollowThread = (index, thread) ->
...
@@ -104,10 +104,10 @@ initializeFollowThread = (index, thread) ->
body
:
body
body
:
body
tags
:
tags
tags
:
tags
success
:
Discussion
.
formErrorHandler
(
$local
(
".new-post-form-error"
),
(
response
,
textStatus
)
->
success
:
Discussion
.
formErrorHandler
(
$local
(
".new-post-form-error"
),
(
response
,
textStatus
)
->
console
.
log
response
$thread
=
$
(
response
.
html
)
$thread
=
$
(
response
.
html
)
$discussion
.
children
(
".threads"
).
prepend
(
$thread
)
$discussion
.
children
(
".threads"
).
prepend
(
$thread
)
Discussion
.
setWmdContent
$discussion
,
$local
,
"new-post-body"
,
""
Discussion
.
setWmdContent
$discussion
,
$local
,
"new-post-body"
,
""
Discussion
.
setContentInfo
response
.
content
[
'id'
],
'editable'
,
true
Discussion
.
initializeContent
(
$thread
)
Discussion
.
initializeContent
(
$thread
)
Discussion
.
bindContentEvents
(
$thread
)
Discussion
.
bindContentEvents
(
$thread
)
$
(
".new-post-form"
).
hide
()
$
(
".new-post-form"
).
hide
()
...
...
lms/static/coffee/src/discussion/utils.coffee
View file @
4ac3eebc
...
@@ -26,8 +26,8 @@ wmdEditors = {}
...
@@ -26,8 +26,8 @@ wmdEditors = {}
delete_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/delete"
delete_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/delete"
upvote_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/upvote"
upvote_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/upvote"
downvote_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/downvote"
downvote_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/downvote"
follow_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/follow"
follow_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/follow"
unfollow_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/unfollow"
unfollow_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/unfollow"
update_comment
:
"/courses/
#{
$$course_id
}
/discussion/comments/
#{
param
}
/update"
update_comment
:
"/courses/
#{
$$course_id
}
/discussion/comments/
#{
param
}
/update"
endorse_comment
:
"/courses/
#{
$$course_id
}
/discussion/comments/
#{
param
}
/endorse"
endorse_comment
:
"/courses/
#{
$$course_id
}
/discussion/comments/
#{
param
}
/endorse"
create_sub_comment
:
"/courses/
#{
$$course_id
}
/discussion/comments/
#{
param
}
/reply"
create_sub_comment
:
"/courses/
#{
$$course_id
}
/discussion/comments/
#{
param
}
/reply"
...
@@ -92,7 +92,6 @@ wmdEditors = {}
...
@@ -92,7 +92,6 @@ wmdEditors = {}
imageUploadUrl
=
Discussion
.
urlFor
(
'upload'
)
imageUploadUrl
=
Discussion
.
urlFor
(
'upload'
)
editor
=
Markdown
.
makeWmdEditor
elem
,
appended_id
,
imageUploadUrl
editor
=
Markdown
.
makeWmdEditor
elem
,
appended_id
,
imageUploadUrl
wmdEditors
[
"
#{
cls_identifier
}
-
#{
id
}
"
]
=
editor
wmdEditors
[
"
#{
cls_identifier
}
-
#{
id
}
"
]
=
editor
console
.
log
wmdEditors
editor
editor
getWmdEditor
:
(
$content
,
$local
,
cls_identifier
)
->
getWmdEditor
:
(
$content
,
$local
,
cls_identifier
)
->
...
@@ -106,6 +105,20 @@ wmdEditors = {}
...
@@ -106,6 +105,20 @@ wmdEditors = {}
setWmdContent
:
(
$content
,
$local
,
cls_identifier
,
text
)
->
setWmdContent
:
(
$content
,
$local
,
cls_identifier
,
text
)
->
id
=
$content
.
attr
(
"_id"
)
id
=
$content
.
attr
(
"_id"
)
$local
(
"#wmd-input-
#{
cls_identifier
}
-
#{
id
}
"
).
val
(
text
)
$local
(
"#wmd-input-
#{
cls_identifier
}
-
#{
id
}
"
).
val
(
text
)
console
.
log
wmdEditors
console
.
log
"
#{
cls_identifier
}
-
#{
id
}
"
wmdEditors
[
"
#{
cls_identifier
}
-
#{
id
}
"
].
refreshPreview
()
wmdEditors
[
"
#{
cls_identifier
}
-
#{
id
}
"
].
refreshPreview
()
getContentInfo
:
(
id
,
attr
)
->
if
not
window
.
$
$annotated_content_info
?
window
.
$
$annotated_content_info
=
{}
(
window
.
$
$annotated_content_info
[
id
]
||
{})[
attr
]
setContentInfo
:
(
id
,
attr
,
value
)
->
if
not
window
.
$
$annotated_content_info
?
window
.
$
$annotated_content_info
=
{}
window
.
$
$annotated_content_info
[
id
]
||=
{}
window
.
$
$annotated_content_info
[
id
][
attr
]
=
value
bulkExtendContentInfo
:
(
newInfos
)
->
if
not
window
.
$
$annotated_content_info
?
window
.
$
$annotated_content_info
=
{}
window
.
$
$annotated_content_info
=
$
.
extend
window
.
$
$annotated_content_info
,
newInfos
lms/templates/discussion/ajax_c
omment_only
.html
→
lms/templates/discussion/ajax_c
reate_comment
.html
View file @
4ac3eebc
File moved
lms/templates/discussion/ajax_
thread_only
.html
→
lms/templates/discussion/ajax_
create_thread
.html
View file @
4ac3eebc
File moved
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