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
7c9fcfbc
Commit
7c9fcfbc
authored
Aug 03, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajax submit new post
parent
4ceee380
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
22 deletions
+41
-22
lms/djangoapps/django_comment_client/base/views.py
+3
-1
lms/static/coffee/src/discussion/content.coffee
+9
-7
lms/static/coffee/src/discussion/discussion.coffee
+19
-8
lms/templates/discussion/_forum.html
+5
-3
lms/templates/discussion/_inline.html
+5
-3
No files found.
lms/djangoapps/django_comment_client/base/views.py
View file @
7c9fcfbc
...
@@ -65,7 +65,9 @@ def create_thread(request, course_id, commentable_id):
...
@@ -65,7 +65,9 @@ def create_thread(request, course_id, commentable_id):
'thread'
:
response
,
'thread'
:
response
,
}
}
html
=
render_to_string
(
'discussion/ajax_thread_only.html'
,
context
)
html
=
render_to_string
(
'discussion/ajax_thread_only.html'
,
context
)
return
HtmlResponse
(
html
)
return
JsonResponse
({
'html'
:
html
,
})
else
:
else
:
return
JsonResponse
(
response
)
return
JsonResponse
(
response
)
...
...
lms/static/coffee/src/discussion/content.coffee
View file @
7c9fcfbc
...
@@ -66,6 +66,7 @@ Discussion = @Discussion
...
@@ -66,6 +66,7 @@ Discussion = @Discussion
$elem
:
$
(
elem
)
$elem
:
$
(
elem
)
url
:
url
url
:
url
type
:
"POST"
type
:
"POST"
dataType
:
'json'
data
:
data
:
body
:
body
body
:
body
anonymous
:
anonymous
anonymous
:
anonymous
...
@@ -80,7 +81,6 @@ Discussion = @Discussion
...
@@ -80,7 +81,6 @@ Discussion = @Discussion
$local
(
".discussion-reply-new"
).
hide
()
$local
(
".discussion-reply-new"
).
hide
()
$discussionContent
.
attr
(
"status"
,
"normal"
)
$discussionContent
.
attr
(
"status"
,
"normal"
)
)
)
dataType
:
'json'
handleVote
=
(
elem
,
value
)
->
handleVote
=
(
elem
,
value
)
->
contentType
=
if
$content
.
hasClass
(
"thread"
)
then
"thread"
else
"comment"
contentType
=
if
$content
.
hasClass
(
"thread"
)
then
"thread"
else
"comment"
...
@@ -128,10 +128,11 @@ Discussion = @Discussion
...
@@ -128,10 +128,11 @@ Discussion = @Discussion
$
.
ajax
$
.
ajax
url
:
url
url
:
url
type
:
"POST"
type
:
"POST"
dataType
:
'json'
data
:
{
title
:
title
,
body
:
body
,
tags
:
tags
},
data
:
{
title
:
title
,
body
:
body
,
tags
:
tags
},
success
:
Discussion
.
formErrorHandler
$local
(
".discussion-update-errors"
),
(
response
,
textStatus
)
->
success
:
Discussion
.
formErrorHandler
(
$local
(
".discussion-update-errors"
),
(
response
,
textStatus
)
->
Discussion
.
handleAnchorAndReload
(
response
)
Discussion
.
handleAnchorAndReload
(
response
)
dataType
:
'json'
)
handleEditComment
=
(
elem
)
->
handleEditComment
=
(
elem
)
->
$local
(
".discussion-content-wrapper"
).
hide
()
$local
(
".discussion-content-wrapper"
).
hide
()
...
@@ -150,11 +151,12 @@ Discussion = @Discussion
...
@@ -150,11 +151,12 @@ Discussion = @Discussion
body
=
Discussion
.
getWmdContent
$content
,
$local
,
"comment-body-edit"
body
=
Discussion
.
getWmdContent
$content
,
$local
,
"comment-body-edit"
$
.
ajax
$
.
ajax
url
:
url
url
:
url
data
:
{
body
:
body
}
type
:
"POST"
type
:
"POST"
success
:
Discussion
.
formErrorHandler
$local
(
".discussion-update-errors"
),
(
response
,
textStatus
)
->
Discussion
.
handleAnchorAndReload
(
response
)
dataType
:
"json"
dataType
:
"json"
data
:
{
body
:
body
}
success
:
Discussion
.
formErrorHandler
(
$local
(
".discussion-update-errors"
),
(
response
,
textStatus
)
->
Discussion
.
handleAnchorAndReload
(
response
)
)
handleEndorse
=
(
elem
)
->
handleEndorse
=
(
elem
)
->
url
=
Discussion
.
urlFor
(
'endorse_comment'
,
id
)
url
=
Discussion
.
urlFor
(
'endorse_comment'
,
id
)
...
@@ -196,6 +198,7 @@ Discussion = @Discussion
...
@@ -196,6 +198,7 @@ Discussion = @Discussion
$elem
:
$
.
merge
(
$threadTitle
,
$showComments
)
$elem
:
$
.
merge
(
$threadTitle
,
$showComments
)
url
:
url
url
:
url
type
:
"GET"
type
:
"GET"
dataType
:
'json'
success
:
(
response
,
textStatus
)
->
success
:
(
response
,
textStatus
)
->
if
not
$$annotated_content_info
?
if
not
$$annotated_content_info
?
window
.
$
$annotated_content_info
=
{}
window
.
$
$annotated_content_info
=
{}
...
@@ -205,7 +208,6 @@ Discussion = @Discussion
...
@@ -205,7 +208,6 @@ Discussion = @Discussion
Discussion
.
initializeContent
(
comment
)
Discussion
.
initializeContent
(
comment
)
Discussion
.
bindContentEvents
(
comment
)
Discussion
.
bindContentEvents
(
comment
)
rebindHideEvents
()
rebindHideEvents
()
dataType
:
'json'
Discussion
.
bindLocalEvents
$local
,
Discussion
.
bindLocalEvents
$local
,
...
...
lms/static/coffee/src/discussion/discussion.coffee
View file @
7c9fcfbc
...
@@ -94,14 +94,25 @@ initializeFollowThread = (index, thread) ->
...
@@ -94,14 +94,25 @@ initializeFollowThread = (index, thread) ->
body
=
Discussion
.
getWmdContent
$discussion
,
$local
,
"new-post-body"
body
=
Discussion
.
getWmdContent
$discussion
,
$local
,
"new-post-body"
tags
=
$local
(
".new-post-tags"
).
val
()
tags
=
$local
(
".new-post-tags"
).
val
()
url
=
Discussion
.
urlFor
(
'create_thread'
,
$local
(
".new-post-form"
).
attr
(
"_id"
))
url
=
Discussion
.
urlFor
(
'create_thread'
,
$local
(
".new-post-form"
).
attr
(
"_id"
))
$
.
post
url
,
{
title
:
title
,
body
:
body
,
tags
:
tags
},
(
response
,
textStatus
)
->
Discussion
.
safeAjax
if
response
.
errors
$elem
:
$
(
elem
)
errorsField
=
$local
(
".discussion-errors"
).
empty
()
url
:
url
for
error
in
response
.
errors
type
:
"POST"
errorsField
.
append
(
$
(
"<li>"
).
addClass
(
"new-post-form-error"
).
html
(
error
))
dataType
:
'json'
else
data
:
Discussion
.
handleAnchorAndReload
(
response
)
title
:
title
,
'json'
body
:
body
tags
:
tags
success
:
Discussion
.
formErrorHandler
(
$local
(
".new-post-form-error"
),
(
response
,
textStatus
)
->
console
.
log
response
$thread
=
$
(
response
.
html
)
$discussion
.
children
(
".threads"
).
prepend
(
$thread
)
Discussion
.
setWmdContent
$discussion
,
$local
,
"new-post-body"
,
""
Discussion
.
initializeContent
(
$thread
)
Discussion
.
bindContentEvents
(
$thread
)
$
(
".new-post-form"
).
hide
()
$local
(
".discussion-new-post"
).
show
()
)
handleCancelNewPost
=
(
elem
)
->
handleCancelNewPost
=
(
elem
)
->
$local
(
".new-post-form"
).
hide
()
$local
(
".new-post-form"
).
hide
()
...
...
lms/templates/discussion/_forum.html
View file @
7c9fcfbc
...
@@ -15,9 +15,11 @@
...
@@ -15,9 +15,11 @@
<div
class=
"discussion-new-post control-button"
href=
"javascript:void(0)"
>
New Post
</div>
<div
class=
"discussion-new-post control-button"
href=
"javascript:void(0)"
>
New Post
</div>
</div>
</div>
<
%
include
file=
"_sort.html"
/>
<
%
include
file=
"_sort.html"
/>
% for thread in threads:
<div
class=
"threads"
>
${renderer.render_thread(course_id, thread, edit_thread=False, show_comments=False)}
% for thread in threads:
% endfor
${renderer.render_thread(course_id, thread, edit_thread=False, show_comments=False)}
% endfor
</div>
<
%
include
file=
"_paginator.html"
/>
<
%
include
file=
"_paginator.html"
/>
</section>
</section>
...
...
lms/templates/discussion/_inline.html
View file @
7c9fcfbc
...
@@ -8,9 +8,11 @@
...
@@ -8,9 +8,11 @@
<div
class=
"discussion-new-post control-button"
href=
"javascript:void(0)"
>
New Post
</div>
<div
class=
"discussion-new-post control-button"
href=
"javascript:void(0)"
>
New Post
</div>
<
%
include
file=
"_sort.html"
/>
<
%
include
file=
"_sort.html"
/>
</div>
</div>
% for thread in threads:
<div
class=
"threads"
>
${renderer.render_thread(course_id, thread, edit_thread=False, show_comments=False)}
% for thread in threads:
% endfor
${renderer.render_thread(course_id, thread, edit_thread=False, show_comments=False)}
% endfor
</div>
<
%
include
file=
"_paginator.html"
/>
<
%
include
file=
"_paginator.html"
/>
</section>
</section>
...
...
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