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
a49b6380
Commit
a49b6380
authored
Sep 11, 2012
by
Arjun Singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Edit post works now.
parent
79775c6e
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
176 additions
and
23 deletions
+176
-23
lms/djangoapps/django_comment_client/forum/views.py
+4
-1
lms/static/coffee/src/discussion/views/discussion_thread_edit_view.coffee
+26
-0
lms/static/coffee/src/discussion/views/discussion_thread_show_view.coffee
+3
-5
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
+83
-9
lms/static/sass/_discussion.scss
+40
-8
lms/templates/discussion/_underscore_templates.html
+20
-0
No files found.
lms/djangoapps/django_comment_client/forum/views.py
View file @
a49b6380
import
json
import
logging
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.auth.decorators
import
login_required
from
django.views.decorators.http
import
require_POST
from
django.views.decorators.http
import
require_POST
from
django.http
import
HttpResponse
,
Http404
from
django.http
import
HttpResponse
,
Http404
...
@@ -15,7 +18,6 @@ from operator import methodcaller
...
@@ -15,7 +18,6 @@ from operator import methodcaller
from
django_comment_client.permissions
import
check_permissions_by_view
from
django_comment_client.permissions
import
check_permissions_by_view
from
django_comment_client.utils
import
merge_dict
,
extract
,
strip_none
,
strip_blank
,
get_courseware_context
from
django_comment_client.utils
import
merge_dict
,
extract
,
strip_none
,
strip_blank
,
get_courseware_context
import
json
import
django_comment_client.utils
as
utils
import
django_comment_client.utils
as
utils
import
comment_client
as
cc
import
comment_client
as
cc
import
xml.sax.saxutils
as
saxutils
import
xml.sax.saxutils
as
saxutils
...
@@ -24,6 +26,7 @@ THREADS_PER_PAGE = 200
...
@@ -24,6 +26,7 @@ THREADS_PER_PAGE = 200
INLINE_THREADS_PER_PAGE
=
5
INLINE_THREADS_PER_PAGE
=
5
PAGES_NEARBY_DELTA
=
2
PAGES_NEARBY_DELTA
=
2
log
=
logging
.
getLogger
(
"edx.discussions"
)
def
_general_discussion_id
(
course_id
):
def
_general_discussion_id
(
course_id
):
return
course_id
.
replace
(
'/'
,
'_'
)
.
replace
(
'.'
,
'_'
)
return
course_id
.
replace
(
'/'
,
'_'
)
.
replace
(
'.'
,
'_'
)
...
...
lms/static/coffee/src/discussion/views/discussion_thread_edit_view.coffee
0 → 100644
View file @
a49b6380
class
@
DiscussionThreadEditView
extends
Backbone
.
View
events
:
"click .post-update"
:
"update"
"click .post-cancel"
:
"cancel_edit"
template
:
_
.
template
(
$
(
"#thread-edit-template"
).
html
())
$
:
(
selector
)
->
@
$el
.
find
(
selector
)
initialize
:
->
super
()
render
:
->
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
@
delegateEvents
()
DiscussionUtil
.
makeWmdEditor
@
$el
,
$
.
proxy
(
@
$
,
@
),
"edit-post-body"
@
$
(
".edit-post-tags"
).
tagsInput
DiscussionUtil
.
tagsInputOptions
()
@
update
:
(
event
)
->
@
trigger
"thread:update"
,
event
cancel_edit
:
(
event
)
->
@
trigger
"thread:cancel_edit"
,
event
lms/static/coffee/src/discussion/views/discussion_thread_show_view.coffee
View file @
a49b6380
...
@@ -57,7 +57,6 @@ class @DiscussionThreadShowView extends DiscussionContentView
...
@@ -57,7 +57,6 @@ class @DiscussionThreadShowView extends DiscussionContentView
toggleFollowing
:
(
event
)
->
toggleFollowing
:
(
event
)
->
$elem
=
$
(
event
.
target
)
$elem
=
$
(
event
.
target
)
url
=
null
url
=
null
console
.
log
"follow"
if
not
@
model
.
get
(
'subscribed'
)
if
not
@
model
.
get
(
'subscribed'
)
@
model
.
follow
()
@
model
.
follow
()
url
=
@
model
.
urlFor
(
"follow"
)
url
=
@
model
.
urlFor
(
"follow"
)
...
@@ -113,12 +112,11 @@ class @DiscussionThreadShowView extends DiscussionContentView
...
@@ -113,12 +112,11 @@ class @DiscussionThreadShowView extends DiscussionContentView
comment
.
updateInfo
(
data
.
annotated_content_info
)
comment
.
updateInfo
(
data
.
annotated_content_info
)
comment
.
set
(
data
.
content
)
comment
.
set
(
data
.
content
)
edit
:
->
edit
:
(
event
)
->
@
trigger
"thread:edit"
@
trigger
"thread:edit"
,
event
window
.
showView
=
@
delete
:
(
event
)
->
delete
:
(
event
)
->
@
trigger
"thread:delete"
@
trigger
"thread:delete"
,
event
toggleClosed
:
(
event
)
->
toggleClosed
:
(
event
)
->
$elem
=
$
(
event
.
target
)
$elem
=
$
(
event
.
target
)
...
...
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
a49b6380
...
@@ -11,18 +11,13 @@ if Backbone?
...
@@ -11,18 +11,13 @@ if Backbone?
initialize
:
->
initialize
:
->
super
()
super
()
@
showView
=
new
DiscussionThreadShowView
(
model
:
@
model
)
@
createShowView
()
@
showView
.
bind
"thread:delete"
,
@
delete
@
showView
.
bind
"thread:edit"
,
@
edit
render
:
->
render
:
->
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
@
delegateEvents
()
@
delegateEvents
()
@
showView
.
setElement
(
@
$
(
'.thread-content-wrapper'
))
@
renderShowView
()
@
showView
.
render
()
@
showView
.
delegateEvents
()
@
renderAttrs
()
@
renderAttrs
()
@
$
(
"span.timeago"
).
timeago
()
@
$
(
"span.timeago"
).
timeago
()
@
makeWmdEditor
"reply-body"
@
makeWmdEditor
"reply-body"
...
@@ -76,15 +71,94 @@ if Backbone?
...
@@ -76,15 +71,94 @@ if Backbone?
comment
.
updateInfo
(
data
.
annotated_content_info
)
comment
.
updateInfo
(
data
.
annotated_content_info
)
comment
.
set
(
data
.
content
)
comment
.
set
(
data
.
content
)
edit
:
->
edit
:
(
event
)
=>
@
createEditView
()
@
renderEditView
()
update
:
(
event
)
=>
newTitle
=
@
editView
.
$
(
".edit-post-title"
).
val
()
newTags
=
@
editView
.
$
(
".edit-post-tags"
).
val
()
newBody
=
@
editView
.
$
(
".edit-post-body textarea"
).
val
()
url
=
DiscussionUtil
.
urlFor
(
'update_thread'
,
@
model
.
id
)
DiscussionUtil
.
safeAjax
$elem
:
$
(
event
.
target
)
$loading
:
$
(
event
.
target
)
if
event
url
:
url
type
:
"POST"
dataType
:
'json'
async
:
false
# TODO when the rest of the stuff below is made to work properly..
data
:
title
:
newTitle
body
:
newBody
tags
:
newTags
error
:
DiscussionUtil
.
formErrorHandler
(
@
$
(
".edit-post-form-errors"
))
success
:
(
response
,
textStatus
)
=>
# TODO: Move this out of the callback, this makes it feel sluggish
@
editView
.
$
(
".edit-post-title"
).
val
(
""
).
attr
(
"prev-text"
,
""
)
@
editView
.
$
(
".edit-post-body textarea"
).
val
(
""
).
attr
(
"prev-text"
,
""
)
@
editView
.
$
(
".edit-post-tags"
).
val
(
""
)
@
editView
.
$
(
".edit-post-tags"
).
importTags
(
""
)
@
editView
.
$
(
".wmd-preview p"
).
html
(
""
)
@
model
.
set
title
:
newTitle
body
:
newBody
tags
:
newTags
@
createShowView
()
@
renderShowView
()
createEditView
:
()
->
if
@
showView
?
@
showView
.
undelegateEvents
()
@
showView
.
$el
.
empty
()
@
showView
=
null
@
editView
=
new
DiscussionThreadEditView
(
model
:
@
model
)
@
editView
.
bind
"thread:update"
,
@
update
@
editView
.
bind
"thread:cancel_edit"
,
@
cancelEdit
renderEditView
:
()
->
@
editView
.
setElement
(
@
$
(
'.thread-content-wrapper'
))
@
editView
.
render
()
@
editView
.
delegateEvents
()
createShowView
:
()
->
if
@
editView
?
@
editView
.
undelegateEvents
()
@
editView
.
$el
.
empty
()
@
editView
=
null
@
showView
=
new
DiscussionThreadShowView
(
model
:
@
model
)
@
showView
.
bind
"thread:delete"
,
@
delete
@
showView
.
bind
"thread:edit"
,
@
edit
renderShowView
:
()
->
@
showView
.
setElement
(
@
$
(
'.thread-content-wrapper'
))
@
showView
.
render
()
@
showView
.
delegateEvents
()
cancelEdit
:
(
event
)
=>
@
createShowView
()
@
renderShowView
()
delete
:
(
event
)
-
>
delete
:
(
event
)
=
>
url
=
@
model
.
urlFor
(
'delete'
)
url
=
@
model
.
urlFor
(
'delete'
)
if
not
@
model
.
can
(
'can_delete'
)
if
not
@
model
.
can
(
'can_delete'
)
return
return
if
not
confirm
"Are you sure to delete thread
\"
#{
@
model
.
get
(
'title'
)
}
\"
?"
if
not
confirm
"Are you sure to delete thread
\"
#{
@
model
.
get
(
'title'
)
}
\"
?"
return
return
@
model
.
remove
()
@
model
.
remove
()
@
showView
.
undelegateEvents
()
@
undelegateEvents
()
@
$el
.
empty
()
@
$el
.
empty
()
$elem
=
$
(
event
.
target
)
$elem
=
$
(
event
.
target
)
DiscussionUtil
.
safeAjax
DiscussionUtil
.
safeAjax
...
...
lms/static/sass/_discussion.scss
View file @
a49b6380
...
@@ -270,6 +270,46 @@ body.discussion {
...
@@ -270,6 +270,46 @@ body.discussion {
}
}
}
}
.edit-post-form
{
width
:
100%
;
margin-bottom
:
20px
;
@include
clearfix
;
.post-cancel
{
@include
white-button
;
border-color
:
#444
;
float
:
left
;
margin
:
10px
0
0
15px
;
}
.post-update
{
@include
blue-button
;
float
:
left
;
height
:
37px
;
margin-top
:
10px
;
border-color
:
#333
;
padding-bottom
:
2px
;
&
:hover
{
border-color
:
#222
;
}
}
.edit-post-title
,
.edit-post-tags
{
width
:
100%
;
height
:
40px
;
padding
:
0
10px
;
box-sizing
:
border-box
;
border-radius
:
3px
;
border
:
1px
solid
#333
;
font-size
:
16px
;
font-family
:
'Open Sans'
,
sans-serif
;
color
:
#333
;
box-shadow
:
0
1px
3px
rgba
(
0
,
0
,
0
,
0
.3
)
inset
;
}
}
.new-post-form
{
.new-post-form
{
width
:
100%
;
width
:
100%
;
margin-bottom
:
20px
;
margin-bottom
:
20px
;
...
@@ -369,14 +409,6 @@ body.discussion {
...
@@ -369,14 +409,6 @@ body.discussion {
&
:hover
{
&
:hover
{
border-color
:
#222
;
border-color
:
#222
;
}
}
.author-moderator
:after
{
content
:
" (moderator)"
}
.author-administrator
:after
{
content
:
" (instructor)"
}
}
}
.new-post-cancel
{
.new-post-cancel
{
...
...
lms/templates/discussion/_underscore_templates.html
View file @
a49b6380
...
@@ -50,6 +50,26 @@
...
@@ -50,6 +50,26 @@
<
/div
>
<
/div
>
</script>
</script>
<script
type=
"text/template"
id=
"thread-edit-template"
>
<
div
class
=
"discussion-post edit-post-form"
>
<
h1
>
Editing
post
<
/h1
>
<
ul
class
=
"edit-post-form-errors"
><
/ul
>
<
div
class
=
"form-row"
>
<
input
type
=
"text"
class
=
"edit-post-title"
name
=
"title"
value
=
$
{
"<%-title %>"
}
placeholder
=
"Title"
>
<
/div
>
<
div
class
=
"form-row"
>
<
div
class
=
"edit-post-body"
name
=
"body"
>
$
{
"<%- body %>"
}
<
/div
>
<
/div
>
<
div
class
=
"form-row"
>
<
input
type
=
"text"
class
=
"edit-post-tags"
name
=
"tags"
placeholder
=
"Tags"
value
=
$
{
"<%- tags %>"
}
>
<
/div
>
<
input
type
=
"submit"
class
=
"post-update"
value
=
"Update post"
>
<
a
href
=
"#"
class
=
"post-cancel"
>
Cancel
<
/a
>
<
/div
>
</script>
<script
type=
"text/template"
id=
"thread-response-template"
>
<script
type=
"text/template"
id=
"thread-response-template"
>
<
header
class
=
"response-local"
>
<
header
class
=
"response-local"
>
<
a
href
=
"javascript:void(0)"
class
=
"vote-btn"
data
-
tooltip
=
"vote"
><
span
class
=
"plus-icon"
><
/span><span class="votes-count-number">${"<%- votes
[
'up_count'
]
%>"}</
span
><
/a
>
<
a
href
=
"javascript:void(0)"
class
=
"vote-btn"
data
-
tooltip
=
"vote"
><
span
class
=
"plus-icon"
><
/span><span class="votes-count-number">${"<%- votes
[
'up_count'
]
%>"}</
span
><
/a
>
...
...
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