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
5f361bf8
Commit
5f361bf8
authored
Aug 29, 2012
by
Matthew Mongeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move views and models out.
parent
5ec864f7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
109 deletions
+87
-109
lms/djangoapps/django_comment_client/forum/views.py
+0
-1
lms/static/coffee/src/discussion/main.coffee
+0
-108
lms/static/coffee/src/discussion/models/discussion_user.coffee
+10
-0
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+8
-0
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
+61
-0
lms/static/coffee/src/discussion/views/thread_list_item_view.coffee
+8
-0
No files found.
lms/djangoapps/django_comment_client/forum/views.py
View file @
5f361bf8
...
...
@@ -234,7 +234,6 @@ def single_thread(request, course_id, discussion_id, thread_id):
'discussion_id'
:
discussion_id
,
'csrf'
:
csrf
(
request
)[
'csrf_token'
],
'init'
:
''
,
'thread'
:
json
.
dumps
(
utils
.
safe_content
(
thread
)),
'annotated_content_info'
:
json
.
dumps
(
annotated_content_info
),
'content'
:
render_single_thread
(
request
,
discussion_id
,
course_id
,
thread_id
),
'course'
:
course
,
...
...
lms/static/coffee/src/discussion/main.coffee
View file @
5f361bf8
class
@
DiscussionUser
constructor
:
(
content_info
)
->
@
content_info
=
content_info
following
:
(
thread
)
->
@
content_info
[
thread
.
id
][
'subscribed'
]
==
true
voted
:
(
thread
)
->
@
content_info
[
thread
.
id
][
'voted'
]
==
'up'
class
@
ThreadListItemView
extends
Backbone
.
View
tagName
:
"li"
template
:
_
.
template
(
$
(
"#thread-list-item-template"
).
html
())
initialize
:
->
@
model
.
on
"change"
,
@
render
render
:
=>
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
@
class
@
DiscussionThreadListView
extends
Backbone
.
View
render
:
->
@
collection
.
each
@
renderThreadListItem
renderThreadListItem
:
(
thread
)
=>
view
=
new
ThreadListItemView
(
model
:
thread
)
view
.
render
()
@
$el
.
append
(
view
.
el
)
class
@
DiscussionThreadView
extends
Backbone
.
View
events
:
"click .discussion-vote-up"
:
"toggleVote"
"click .dogear"
:
"toggleFollowing"
initialize
:
(
options
)
->
@
user
=
options
[
'user'
]
@
model
.
bind
"change"
,
@
updateModelDetails
updateModelDetails
:
=>
@
$
(
".votes-count-number"
).
html
(
@
model
.
get
(
"votes"
)[
"up_count"
])
render
:
->
if
@
user
.
following
(
@
model
)
@
$
(
".dogear"
).
addClass
(
"is-followed"
)
if
@
user
.
voted
(
@
model
)
@
$
(
".vote-btn"
).
addClass
(
"is-cast"
)
toggleVote
:
->
@
$
(
".vote-btn"
).
toggleClass
(
"is-cast"
)
if
@
$
(
".vote-btn"
).
hasClass
(
"is-cast"
)
@
vote
()
else
@
unvote
()
toggleFollowing
:
(
event
)
->
$elem
=
$
(
event
.
target
)
@
$
(
".dogear"
).
toggleClass
(
"is-followed"
)
url
=
null
if
@
$
(
".dogear"
).
hasClass
(
"is-followed"
)
url
=
@
model
.
urlFor
(
"follow"
)
else
url
=
@
model
.
urlFor
(
"unfollow"
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
type
:
"POST"
vote
:
->
url
=
@
model
.
urlFor
(
"upvote"
)
@
$
(
".votes-count-number"
).
html
(
parseInt
(
@
$
(
".votes-count-number"
).
html
())
+
1
)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-vote"
)
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
response
)
unvote
:
->
url
=
@
model
.
urlFor
(
"unvote"
)
@
$
(
".votes-count-number"
).
html
(
parseInt
(
@
$
(
".votes-count-number"
).
html
())
-
1
)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-vote"
)
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
response
)
$
->
window
.
$
$contents
=
{}
window
.
$
$discussions
=
{}
# $(".discussion-module").each (index, elem) ->
# view = new DiscussionModuleView(el: elem)
# $("section.discussion").each (index, elem) ->
# discussionData = DiscussionUtil.getDiscussionData($(elem).attr("_id"))
# discussion = new Discussion()
# discussion.reset(discussionData, {silent: false})
# view = new DiscussionView(el: elem, model: discussion)
# if window.$$annotated_content_info?
# DiscussionUtil.bulkUpdateContentInfo(window.$$annotated_content_info)
# $userProfile = $(".discussion-sidebar>.user-profile")
# if $userProfile.length
# console.log "initialize user profile"
# view = new DiscussionUserProfileView(el: $userProfile[0])
lms/static/coffee/src/discussion/models/discussion_user.coffee
0 → 100644
View file @
5f361bf8
class
@
DiscussionUser
constructor
:
(
content_info
)
->
@
content_info
=
content_info
following
:
(
thread
)
->
@
content_info
[
thread
.
id
][
'subscribed'
]
==
true
voted
:
(
thread
)
->
@
content_info
[
thread
.
id
][
'voted'
]
==
'up'
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
0 → 100644
View file @
5f361bf8
class
@
DiscussionThreadListView
extends
Backbone
.
View
render
:
->
@
collection
.
each
@
renderThreadListItem
@
renderThreadListItem
:
(
thread
)
=>
view
=
new
ThreadListItemView
(
model
:
thread
)
view
.
render
()
@
$el
.
append
(
view
.
el
)
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
0 → 100644
View file @
5f361bf8
class
@
DiscussionThreadView
extends
Backbone
.
View
events
:
"click .discussion-vote-up"
:
"toggleVote"
"click .dogear"
:
"toggleFollowing"
initialize
:
(
options
)
->
@
user
=
options
[
'user'
]
@
model
.
bind
"change"
,
@
updateModelDetails
updateModelDetails
:
=>
@
$
(
".votes-count-number"
).
html
(
@
model
.
get
(
"votes"
)[
"up_count"
])
render
:
->
if
@
user
.
following
(
@
model
)
@
$
(
".dogear"
).
addClass
(
"is-followed"
)
if
@
user
.
voted
(
@
model
)
@
$
(
".vote-btn"
).
addClass
(
"is-cast"
)
@
toggleVote
:
->
@
$
(
".vote-btn"
).
toggleClass
(
"is-cast"
)
if
@
$
(
".vote-btn"
).
hasClass
(
"is-cast"
)
@
vote
()
else
@
unvote
()
toggleFollowing
:
(
event
)
->
$elem
=
$
(
event
.
target
)
@
$
(
".dogear"
).
toggleClass
(
"is-followed"
)
url
=
null
if
@
$
(
".dogear"
).
hasClass
(
"is-followed"
)
url
=
@
model
.
urlFor
(
"follow"
)
else
url
=
@
model
.
urlFor
(
"unfollow"
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
type
:
"POST"
vote
:
->
url
=
@
model
.
urlFor
(
"upvote"
)
@
$
(
".votes-count-number"
).
html
(
parseInt
(
@
$
(
".votes-count-number"
).
html
())
+
1
)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-vote"
)
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
response
)
unvote
:
->
url
=
@
model
.
urlFor
(
"unvote"
)
@
$
(
".votes-count-number"
).
html
(
parseInt
(
@
$
(
".votes-count-number"
).
html
())
-
1
)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-vote"
)
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
response
)
lms/static/coffee/src/discussion/views/thread_list_item_view.coffee
0 → 100644
View file @
5f361bf8
class
@
ThreadListItemView
extends
Backbone
.
View
tagName
:
"li"
template
:
_
.
template
(
$
(
"#thread-list-item-template"
).
html
())
initialize
:
->
@
model
.
on
"change"
,
@
render
render
:
=>
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
@
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