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
dd054237
Commit
dd054237
authored
Jul 21, 2014
by
Greg Price
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-render forum responses when marked as answer
parent
aaa2f353
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
8 deletions
+23
-8
common/static/coffee/spec/discussion/discussion_spec_helper.coffee
+1
-1
common/static/coffee/spec/discussion/view/thread_response_show_view_spec.coffee
+11
-0
common/static/coffee/src/discussion/views/thread_response_show_view.coffee
+11
-7
No files found.
common/static/coffee/spec/discussion/discussion_spec_helper.coffee
View file @
dd054237
...
...
@@ -3,4 +3,4 @@ class @DiscussionSpecHelper
@
setUpGlobals
=
->
DiscussionUtil
.
loadRoles
({
"Moderator"
:
[],
"Administrator"
:
[],
"Community TA"
:
[]})
window
.
$
$course_id
=
"edX/999/test"
window
.
user
=
new
DiscussionUser
({
id
:
"567"
,
upvoted_ids
:
[]})
window
.
user
=
new
DiscussionUser
({
username
:
"test_user"
,
id
:
"567"
,
upvoted_ids
:
[]})
common/static/coffee/spec/discussion/view/thread_response_show_view_spec.coffee
View file @
dd054237
...
...
@@ -97,3 +97,14 @@ describe "ThreadResponseShowView", ->
@
view
.
render
()
expect
(
@
view
.
$
(
".posted-details"
).
text
()).
toMatch
(
"marked as answer less than a minute ago"
)
expect
(
@
view
.
$
(
".posted-details"
).
text
()).
not
.
toMatch
(
" by "
)
it
"re-renders correctly when endorsement changes"
,
->
@
thread
.
set
(
"thread_type"
,
"question"
)
@
comment
.
updateInfo
({
"ability"
:
{
"can_endorse"
:
true
}})
expect
(
@
view
.
$
(
".posted-details"
).
text
()).
not
.
toMatch
(
"marked as answer"
)
@
view
.
$
(
".action-endorse"
).
click
()
expect
(
@
view
.
$
(
".posted-details"
).
text
()).
toMatch
(
"marked as answer less than a minute ago by "
+
user
.
get
(
"username"
)
)
@
view
.
$
(
".action-endorse"
).
click
()
expect
(
@
view
.
$
(
".posted-details"
).
text
()).
not
.
toMatch
(
"marked as answer"
)
common/static/coffee/src/discussion/views/thread_response_show_view.coffee
View file @
dd054237
...
...
@@ -17,7 +17,7 @@ if Backbone?
initialize
:
->
super
()
@
model
.
on
"change"
,
@
updateModelDetails
@
listenTo
(
@
model
,
"change"
,
@
render
)
renderTemplate
:
->
@
template
=
_
.
template
(
$
(
"#thread-response-show-template"
).
html
())
...
...
@@ -60,8 +60,16 @@ if Backbone?
$elem
=
$
(
event
.
target
)
url
=
@
model
.
urlFor
(
'endorse'
)
endorsed
=
@
model
.
get
(
'endorsed'
)
data
=
{
endorsed
:
not
endorsed
}
@
model
.
set
(
'endorsed'
,
not
endorsed
)
new_endorsed
=
not
endorsed
data
=
{
endorsed
:
new_endorsed
}
endorsement
=
{
"username"
:
window
.
user
.
get
(
"username"
),
"time"
:
new
Date
().
toISOString
()
}
@
model
.
set
(
"endorsed"
:
new_endorsed
"endorsement"
:
if
new_endorsed
then
endorsement
else
null
)
@
trigger
"comment:endorse"
,
not
endorsed
DiscussionUtil
.
safeAjax
$elem
:
$elem
...
...
@@ -86,7 +94,3 @@ if Backbone?
@
$
(
"[data-role=thread-flag]"
).
addClass
(
"notflagged"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"aria-pressed"
,
"false"
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
gettext
(
"Report Misuse"
))
updateModelDetails
:
=>
@
renderVote
()
@
renderFlagged
()
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