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
9dedd532
Commit
9dedd532
authored
Aug 20, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some progress
parent
9ac26715
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
60 additions
and
14 deletions
+60
-14
lms/djangoapps/django_comment_client/forum/views.py
+3
-3
lms/djangoapps/django_comment_client/middleware.py
+1
-0
lms/lib/comment_client/models.py
+3
-0
lms/static/coffee/src/backbone_discussion/content.coffee
+43
-3
lms/templates/discussion/_content.mustache
+1
-1
lms/templates/discussion/_content_renderer.html
+1
-1
lms/templates/discussion/_forum.html
+2
-2
lms/templates/discussion/_inline.html
+1
-1
lms/templates/discussion/_paginator.html
+1
-1
lms/templates/discussion/_single_thread.html
+3
-1
lms/templates/discussion/_sort.html
+1
-1
No files found.
lms/djangoapps/django_comment_client/forum/views.py
View file @
9dedd532
...
@@ -164,9 +164,9 @@ def forum_form_discussion(request, course_id):
...
@@ -164,9 +164,9 @@ def forum_form_discussion(request, course_id):
def
render_single_thread
(
request
,
discussion_id
,
course_id
,
thread_id
):
def
render_single_thread
(
request
,
discussion_id
,
course_id
,
thread_id
):
thread
=
cc
.
Thread
.
find
(
thread_id
)
.
retrieve
(
recursive
=
True
)
thread
=
cc
.
Thread
.
find
(
thread_id
)
.
retrieve
(
recursive
=
True
)
.
to_dict
()
annotated_content_info
=
utils
.
get_annotated_content_infos
(
course_id
,
thread
=
thread
.
to_dict
()
,
user
=
request
.
user
)
annotated_content_info
=
utils
.
get_annotated_content_infos
(
course_id
,
thread
=
thread
,
user
=
request
.
user
)
context
=
{
context
=
{
'discussion_id'
:
discussion_id
,
'discussion_id'
:
discussion_id
,
...
@@ -175,6 +175,7 @@ def render_single_thread(request, discussion_id, course_id, thread_id):
...
@@ -175,6 +175,7 @@ def render_single_thread(request, discussion_id, course_id, thread_id):
'annotated_content_info'
:
json
.
dumps
(
annotated_content_info
),
'annotated_content_info'
:
json
.
dumps
(
annotated_content_info
),
'course_id'
:
course_id
,
'course_id'
:
course_id
,
'request'
:
request
,
'request'
:
request
,
'discussion_data'
:
json
.
dumps
({
discussion_id
:
[
thread
]
}),
}
}
return
render_to_string
(
'discussion/_single_thread.html'
,
context
)
return
render_to_string
(
'discussion/_single_thread.html'
,
context
)
...
@@ -201,7 +202,6 @@ def single_thread(request, course_id, discussion_id, thread_id):
...
@@ -201,7 +202,6 @@ def single_thread(request, course_id, discussion_id, thread_id):
'csrf'
:
csrf
(
request
)[
'csrf_token'
],
'csrf'
:
csrf
(
request
)[
'csrf_token'
],
'init'
:
''
,
'init'
:
''
,
'content'
:
render_single_thread
(
request
,
discussion_id
,
course_id
,
thread_id
),
'content'
:
render_single_thread
(
request
,
discussion_id
,
course_id
,
thread_id
),
'accordion'
:
render_accordion
(
request
,
course
,
discussion_id
),
'course'
:
course
,
'course'
:
course
,
'course_id'
:
course
.
id
,
'course_id'
:
course
.
id
,
}
}
...
...
lms/djangoapps/django_comment_client/middleware.py
View file @
9dedd532
...
@@ -4,6 +4,7 @@ import json
...
@@ -4,6 +4,7 @@ import json
class
AjaxExceptionMiddleware
(
object
):
class
AjaxExceptionMiddleware
(
object
):
def
process_exception
(
self
,
request
,
exception
):
def
process_exception
(
self
,
request
,
exception
):
import
pdb
;
pdb
.
set_trace
()
if
isinstance
(
exception
,
CommentClientError
)
and
request
.
is_ajax
():
if
isinstance
(
exception
,
CommentClientError
)
and
request
.
is_ajax
():
return
JsonError
(
json
.
loads
(
exception
.
message
))
return
JsonError
(
json
.
loads
(
exception
.
message
))
return
None
return
None
lms/lib/comment_client/models.py
View file @
9dedd532
...
@@ -43,6 +43,9 @@ class Model(object):
...
@@ -43,6 +43,9 @@ class Model(object):
raise
KeyError
(
"Field {0} does not exist"
.
format
(
key
))
raise
KeyError
(
"Field {0} does not exist"
.
format
(
key
))
self
.
attributes
.
__setitem__
(
key
,
value
)
self
.
attributes
.
__setitem__
(
key
,
value
)
def
items
(
self
,
*
args
,
**
kwargs
):
return
self
.
attributes
.
items
(
*
args
,
**
kwargs
)
def
get
(
self
,
*
args
,
**
kwargs
):
def
get
(
self
,
*
args
,
**
kwargs
):
return
self
.
attributes
.
get
(
*
args
,
**
kwargs
)
return
self
.
attributes
.
get
(
*
args
,
**
kwargs
)
...
...
lms/static/coffee/src/backbone_discussion/content.coffee
View file @
9dedd532
...
@@ -29,6 +29,32 @@ class @ContentView extends Backbone.View
...
@@ -29,6 +29,32 @@ class @ContentView extends Backbone.View
@
$local
.
find
(
selector
)
@
$local
.
find
(
selector
)
showSingleThread
:
(
event
)
->
showSingleThread
:
(
event
)
->
if
@
showed
@
$el
.
children
(
".comments"
).
hide
()
@
showed
=
false
$showComments
=
@
$
(
".discussion-show-comments"
)
prevHtml
=
$showComments
.
html
()
$showComments
.
html
prevHtml
.
replace
"Hide"
,
"Show"
else
if
@
retrieved
@
$el
.
children
(
".comments"
).
show
()
@
showed
=
true
else
discussion_id
=
@
model
.
discussion
.
id
url
=
DiscussionUtil
.
urlFor
(
'retrieve_single_thread'
,
discussion_id
,
@
model
.
id
)
DiscussionUtil
.
safeAjax
$elem
:
$
.
merge
@
$
(
".thread-title"
),
@
$
(
".discussion-show-comments"
)
url
:
url
type
:
"GET"
dataType
:
'json'
success
:
(
response
,
textStatus
)
=>
DiscussionUtil
.
bulkExtendContentInfo
response
[
'annotated_content_info'
]
@
retrieved
=
true
@
showed
=
true
@
$el
.
append
(
response
[
'html'
])
@
model
.
get
(
'comments'
).
reset
response
.
content
.
children
,
{
silent
:
false
}
@
initCommentViews
()
return
$threadTitle
=
@
$
(
".thread-title"
)
$threadTitle
=
@
$
(
".thread-title"
)
$showComments
=
@
$
(
".discussion-show-comments"
)
$showComments
=
@
$
(
".discussion-show-comments"
)
...
@@ -133,15 +159,15 @@ class @ContentView extends Backbone.View
...
@@ -133,15 +159,15 @@ class @ContentView extends Backbone.View
@
$
(
".discussion-votes-point"
).
html
response
.
votes
.
point
@
$
(
".discussion-votes-point"
).
html
response
.
votes
.
point
endorse
:
(
event
)
->
endorse
:
(
event
)
->
url
=
DiscussionUtil
.
urlFor
(
'endorse_comment'
,
id
)
url
=
DiscussionUtil
.
urlFor
(
'endorse_comment'
,
@
model
.
id
)
endorsed
=
not
@
model
.
get
(
'endorsed'
)
endorsed
=
not
@
$el
.
hasClass
(
"endorsed"
)
Discussion
.
safeAjax
Discussion
.
safeAjax
$elem
:
$
(
event
.
target
)
$elem
:
$
(
event
.
target
)
url
:
url
url
:
url
type
:
"POST"
type
:
"POST"
dataType
:
"json"
dataType
:
"json"
data
:
{
endorsed
:
endorsed
}
data
:
{
endorsed
:
endorsed
}
success
:
(
response
,
textStatus
)
-
>
success
:
(
response
,
textStatus
)
=
>
if
textStatus
==
"success"
if
textStatus
==
"success"
if
endorsed
if
endorsed
@
$el
.
addClass
(
"endorsed"
)
@
$el
.
addClass
(
"endorsed"
)
...
@@ -211,6 +237,7 @@ class @ContentView extends Backbone.View
...
@@ -211,6 +237,7 @@ class @ContentView extends Backbone.View
Discussion
.
extendContentInfo
response
.
content
[
'id'
],
response
[
'annotated_content_info'
]
Discussion
.
extendContentInfo
response
.
content
[
'id'
],
response
[
'annotated_content_info'
]
Discussion
.
initializeContent
(
$content
)
Discussion
.
initializeContent
(
$content
)
Discussion
.
bindContentEvents
(
$content
)
Discussion
.
bindContentEvents
(
$content
)
delete
:
->
delete
:
->
if
$content
.
hasClass
(
"thread"
)
if
$content
.
hasClass
(
"thread"
)
url
=
Discussion
.
urlFor
(
'delete_thread'
,
id
)
url
=
Discussion
.
urlFor
(
'delete_thread'
,
id
)
...
@@ -274,12 +301,25 @@ class @ContentView extends Backbone.View
...
@@ -274,12 +301,25 @@ class @ContentView extends Backbone.View
initTimeago
:
->
initTimeago
:
->
@
$
(
"span.timeago"
).
timeago
()
@
$
(
"span.timeago"
).
timeago
()
initPermalink
:
->
if
@
model
.
get
(
'type'
)
==
'thread'
discussion_id
=
@
model
.
get
(
'commentable_id'
)
permalink
=
Discussion
.
urlFor
(
"permanent_link_thread"
,
discussion_id
,
@
model
.
id
)
else
thread_id
=
@
model
.
get
(
'thread_id'
)
discussion_id
=
@
$el
.
parents
(
".thread"
).
attr
(
"_discussion_id"
)
permalink
=
Discussion
.
urlFor
(
"permanent_link_comment"
,
discussion_id
,
thread_id
,
@
model
.
id
)
@
$
(
".discussion-permanent-link"
).
attr
"href"
,
permalink
initialize
:
->
initialize
:
->
@
model
.
view
=
@
@
model
.
view
=
@
@
initLocal
()
@
initLocal
()
@
initVote
()
@
initVote
()
@
initTimeago
()
@
initTimeago
()
@
initBody
()
@
initBody
()
@
initPermalink
()
@
initActions
()
@
initActions
()
@
initCommentViews
()
@
initCommentViews
()
...
...
lms/templates/discussion/_content.mustache
View file @
9dedd532
<div
class=
"discussion-content"
>
<div
class=
"discussion-content
local
"
>
<div
class=
"discussion-content-wrapper"
>
<div
class=
"discussion-content-wrapper"
>
<div
class=
"discussion-votes"
>
<div
class=
"discussion-votes"
>
<a
class=
"discussion-vote discussion-vote-up"
href=
"javascript:void(0)"
value=
"up"
>
▲
</a>
<a
class=
"discussion-vote discussion-vote-up"
href=
"javascript:void(0)"
value=
"up"
>
▲
</a>
...
...
lms/templates/discussion/_content_renderer.html
View file @
9dedd532
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<
%
def
name=
"render_content_with_comments(content)"
>
<
%
def
name=
"render_content_with_comments(content)"
>
<div
class=
"${content['type']}${helpers.show_if(' endorsed', content.get('endorsed'))}"
_id=
"${content['id']}"
_discussion_id=
"${content.get('commentable_id', '')}"
_author_id=
"${helpers.show_if(content['user_id'], not content.get('anonymous'))}"
>
<div
class=
"${content['type']}${helpers.show_if(' endorsed', content.get('endorsed'))}"
_id=
"${content['id']}"
_discussion_id=
"${content.get('commentable_id', '')}"
_author_id=
"${helpers.show_if(content['user_id'], not content.get('anonymous'))}"
>
<div
class=
"local"
>
${render_content(content)}
</div>
${render_content(content)}
% if content.get('children') is not None:
% if content.get('children') is not None:
${render_comments(content['children'])}
${render_comments(content['children'])}
% endif
% endif
...
...
lms/templates/discussion/_forum.html
View file @
9dedd532
...
@@ -13,13 +13,13 @@
...
@@ -13,13 +13,13 @@
</div>
</div>
<div
class=
"threads"
></div>
<div
class=
"threads"
></div>
% else:
% else:
<
div
class=
"local"
><
%
include
file=
"_sort.html"
/></div
>
<
%
include
file=
"_sort.html"
/
>
<div
class=
"threads"
>
<div
class=
"threads"
>
% for thread in threads:
% for thread in threads:
${renderer.render_content_with_comments(thread)}
${renderer.render_content_with_comments(thread)}
% endfor
% endfor
</div>
</div>
<
div
class=
"local"
><
%
include
file=
"_paginator.html"
/></div
>
<
%
include
file=
"_paginator.html"
/
>
% endif
% endif
</section>
</section>
...
...
lms/templates/discussion/_inline.html
View file @
9dedd532
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
% endfor
% endfor
</div>
</div>
<
div
class=
"local"
><
%
include
file=
"_paginator.html"
/></div
>
<
%
include
file=
"_paginator.html"
/
>
</section>
</section>
<
%
include
file=
"_js_data.html"
/>
<
%
include
file=
"_js_data.html"
/>
lms/templates/discussion/_paginator.html
View file @
9dedd532
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
% endfor
% endfor
</
%
def>
</
%
def>
<div
class=
"discussion-${discussion_type}-paginator discussion-paginator"
>
<div
class=
"discussion-${discussion_type}-paginator discussion-paginator
local
"
>
<div
class=
"prev-page"
>
<div
class=
"prev-page"
>
% if page > 1:
% if page > 1:
${link_to_page(page - 1, "
<
Previous page")}
${link_to_page(page - 1, "
<
Previous page")}
...
...
lms/templates/discussion/_single_thread.html
View file @
9dedd532
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
<section
class=
"discussion"
_id=
"${discussion_id}"
>
<section
class=
"discussion"
_id=
"${discussion_id}"
>
<a
class=
"discussion-title"
href=
"javascript:void(0)"
>
Discussion
</a>
<a
class=
"discussion-title"
href=
"javascript:void(0)"
>
Discussion
</a>
${renderer.render_content_with_comments(thread)}
<div
class=
"threads"
>
${renderer.render_content_with_comments(thread)}
</div>
</section>
</section>
<
%
include
file=
"_js_data.html"
/>
<
%
include
file=
"_js_data.html"
/>
lms/templates/discussion/_sort.html
View file @
9dedd532
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
<a
class=
"discussion-sort-link ${cls}"
href=
"javascript:void(0)"
sort-url=
"${url_for_sort(key, order)}"
>
${title}
</a>
<a
class=
"discussion-sort-link ${cls}"
href=
"javascript:void(0)"
sort-url=
"${url_for_sort(key, order)}"
>
${title}
</a>
</
%
def>
</
%
def>
<div
class=
"discussion-sort
discussion-
local"
>
<div
class=
"discussion-sort local"
>
<span
class=
"discussion-label"
>
Sort by:
</span>
<span
class=
"discussion-label"
>
Sort by:
</span>
${link_to_sort('activity', 'top')}
${link_to_sort('activity', 'top')}
...
...
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