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
3ffc2706
Commit
3ffc2706
authored
Sep 13, 2012
by
Matthew Mongeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paging wip
parent
30d0d9d2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
7 deletions
+49
-7
lms/djangoapps/django_comment_client/forum/views.py
+2
-1
lms/static/coffee/src/discussion/discussion.coffee
+21
-1
lms/static/coffee/src/discussion/main.coffee
+2
-1
lms/static/coffee/src/discussion/utils.coffee
+1
-0
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+22
-3
lms/templates/discussion/index.html
+1
-1
No files found.
lms/djangoapps/django_comment_client/forum/views.py
View file @
3ffc2706
...
...
@@ -22,7 +22,7 @@ import django_comment_client.utils as utils
import
comment_client
as
cc
import
xml.sax.saxutils
as
saxutils
THREADS_PER_PAGE
=
2
00
THREADS_PER_PAGE
=
2
INLINE_THREADS_PER_PAGE
=
5
PAGES_NEARBY_DELTA
=
2
escapedict
=
{
'"'
:
'"'
}
...
...
@@ -224,6 +224,7 @@ def forum_form_discussion(request, course_id):
#'trending_tags': trending_tags,
'staff_access'
:
has_access
(
request
.
user
,
course
,
'staff'
),
'threads'
:
saxutils
.
escape
(
json
.
dumps
(
threads
),
escapedict
),
'thread_pages'
:
query_params
[
'num_pages'
],
'user_info'
:
saxutils
.
escape
(
json
.
dumps
(
user_info
),
escapedict
),
'annotated_content_info'
:
saxutils
.
escape
(
json
.
dumps
(
annotated_content_info
),
escapedict
),
'course_id'
:
course
.
id
,
...
...
lms/static/coffee/src/discussion/discussion.coffee
View file @
3ffc2706
...
...
@@ -2,7 +2,9 @@ if Backbone?
class
@
Discussion
extends
Backbone
.
Collection
model
:
Thread
initialize
:
->
initialize
:
(
models
,
options
)
->
@
pages
=
options
[
'pages'
]
||
1
@
current_page
=
1
@
bind
"add"
,
(
item
)
=>
item
.
discussion
=
@
@
comparator
=
@
sortByDateRecentFirst
...
...
@@ -12,12 +14,30 @@ if Backbone?
find
:
(
id
)
->
_
.
first
@
where
(
id
:
id
)
hasMorePages
:
->
@
current_page
<
@
pages
addThread
:
(
thread
,
options
)
->
options
||=
{}
model
=
new
Thread
thread
@
add
model
model
retrieveAnotherPage
:
->
@
current_page
+=
1
url
=
DiscussionUtil
.
urlFor
'threads'
data
=
{
page
:
@
current_page
}
DiscussionUtil
.
safeAjax
$elem
:
@
$el
url
:
url
data
:
data
dataType
:
'json'
success
:
(
response
,
textStatus
)
=>
models
=
@
models
new_threads
=
[
new
Thread
(
data
)
for
data
in
response
.
discussion_data
][
0
]
new_collection
=
_
.
union
(
models
,
new_threads
)
@
reset
new_collection
sortByDate
:
(
thread
)
->
thread
.
get
(
"created_at"
)
...
...
lms/static/coffee/src/discussion/main.coffee
View file @
3ffc2706
...
...
@@ -7,10 +7,11 @@ if Backbone?
window
.
$
$course_id
=
element
.
data
(
"course-id"
)
user_info
=
element
.
data
(
"user-info"
)
threads
=
element
.
data
(
"threads"
)
thread_pages
=
element
.
data
(
"thread-pages"
)
content_info
=
element
.
data
(
"content-info"
)
window
.
user
=
new
DiscussionUser
(
user_info
)
Content
.
loadContentInfos
(
content_info
)
discussion
=
new
Discussion
(
threads
)
discussion
=
new
Discussion
(
threads
,
pages
:
thread_pages
)
new
DiscussionRouter
({
discussion
:
discussion
})
Backbone
.
history
.
start
({
pushState
:
true
,
root
:
"/courses/
#{
$$course_id
}
/discussion/forum/"
})
DiscussionProfileApp
=
...
...
lms/static/coffee/src/discussion/utils.coffee
View file @
3ffc2706
...
...
@@ -66,6 +66,7 @@ class @DiscussionUtil
permanent_link_thread
:
"/courses/
#{
$$course_id
}
/discussion/forum/
#{
param
}
/threads/
#{
param1
}
"
permanent_link_comment
:
"/courses/
#{
$$course_id
}
/discussion/forum/
#{
param
}
/threads/
#{
param1
}
#
#{
param2
}
"
user_profile
:
"/courses/
#{
$$course_id
}
/discussion/forum/users/
#{
param
}
"
threads
:
"/courses/
#{
$$course_id
}
/discussion/forum"
}[
name
]
@
safeAjax
:
(
params
)
->
...
...
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
View file @
3ffc2706
...
...
@@ -7,11 +7,20 @@ if Backbone?
"click .sort-bar a"
:
"sortThreads"
"click .browse-topic-drop-menu"
:
"filterTopic"
"click .browse-topic-drop-search-input"
:
"ignoreClick"
"click .post-list a"
:
"threadSelected"
"click .post-list .list-item a"
:
"threadSelected"
"click .post-list .more-pages a"
:
"loadMorePages"
initialize
:
->
@
displayedCollection
=
new
Discussion
(
@
collection
.
models
)
@
displayedCollection
=
new
Discussion
(
@
collection
.
models
,
pages
:
@
collection
.
pages
)
@
collection
.
on
"change"
,
@
reloadDisplayedCollection
@
collection
.
on
"reset"
,
(
discussion
)
=>
board
=
$
(
".current-board"
).
html
()
@
displayedCollection
.
current_page
=
discussion
.
current_page
@
displayedCollection
.
reset
discussion
.
models
# TODO: filter correctly
# target = _.filter($("a.topic:contains('#{board}')"), (el) -> el.innerText == "General" || el.innerHTML == "General")
# if target.length > 0
# @filterTopic($.Event("filter", {'target': target[0]}))
@
collection
.
on
"add"
,
@
addAndSelectThread
@
sidebar_padding
=
10
@
sidebar_header_height
=
87
...
...
@@ -96,11 +105,21 @@ if Backbone?
for
thread
in
@
displayedCollection
.
models
content
=
@
renderThread
(
thread
)
rendered
.
append
content
content
.
wrap
(
"<li data-id='
#{
thread
.
get
(
'id'
)
}
' />"
)
content
.
wrap
(
"<li
class='list-item'
data-id='
#{
thread
.
get
(
'id'
)
}
' />"
)
@
$
(
".post-list"
).
html
(
rendered
.
html
())
@
renderMorePages
()
@
trigger
"threads:rendered"
renderMorePages
:
->
if
@
displayedCollection
.
hasMorePages
()
@
$
(
".post-list"
).
append
(
"<li class='more-pages'><a href='#'>Load more</a></li>"
)
loadMorePages
:
->
@
$
(
".more-pages"
).
html
(
'<div class="loading-animation"></div>'
)
@
$
(
".more-pages"
).
addClass
(
"loading"
)
@
collection
.
retrieveAnotherPage
()
renderThread
:
(
thread
)
=>
content
=
$
(
_
.
template
(
$
(
"#thread-list-item-template"
).
html
())(
thread
.
toJSON
()))
if
thread
.
get
(
'subscribed'
)
...
...
lms/templates/discussion/index.html
View file @
3ffc2706
...
...
@@ -23,7 +23,7 @@
<script
type=
"text/javascript"
src=
"${static.url('js/discussions-temp.js')}"
></script>
<section
class=
"discussion container"
id=
"discussion-container"
data-roles=
"${roles}"
data-course-id=
"${course_id}"
data-user-info=
"${user_info}"
data-threads=
"${threads}"
>
<section
class=
"discussion container"
id=
"discussion-container"
data-roles=
"${roles}"
data-course-id=
"${course_id}"
data-user-info=
"${user_info}"
data-threads=
"${threads}"
data-thread-pages=
"${thread_pages}"
>
<div
class=
"discussion-body"
>
<div
class=
"sidebar"
></div>
<div
class=
"discussion-column"
>
...
...
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