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
af0cbfb7
Commit
af0cbfb7
authored
Aug 23, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make similar posts url working
parent
7f6ac9c0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
34 deletions
+44
-34
lms/djangoapps/django_comment_client/base/views.py
+6
-3
lms/djangoapps/django_comment_client/helpers.py
+1
-15
lms/djangoapps/django_comment_client/utils.py
+17
-0
lms/static/coffee/src/discussion/discussion.coffee
+10
-11
lms/templates/discussion/_similar_posts.html
+9
-0
lms/templates/discussion/mustache/_new_post.mustache
+1
-5
No files found.
lms/djangoapps/django_comment_client/base/views.py
View file @
af0cbfb7
...
...
@@ -298,10 +298,13 @@ def search_similar_threads(request, course_id, commentable_id):
'text'
:
text
,
'commentable_id'
:
commentable_id
,
}
result
=
cc
.
search_similar_threads
(
course_id
,
recursive
=
False
,
query_params
=
query_params
)
return
JsonResponse
(
result
)
threads
=
cc
.
search_similar_threads
(
course_id
,
recursive
=
False
,
query_params
=
query_params
)
else
:
return
JsonResponse
([])
theads
=
[]
context
=
{
'threads'
:
map
(
utils
.
extend_content
,
threads
)
}
return
JsonResponse
({
'html'
:
render_to_string
(
'discussion/_similar_posts.html'
,
context
)
})
@require_GET
def
tags_autocomplete
(
request
,
course_id
):
...
...
lms/djangoapps/django_comment_client/helpers.py
View file @
af0cbfb7
...
...
@@ -33,24 +33,10 @@ def include_mustache_templates():
file_contents
=
map
(
read_file
,
filter
(
valid_file_name
,
os
.
listdir
(
mustache_dir
)))
return
'
\n
'
.
join
(
map
(
wrap_in_tag
,
map
(
strip_file_name
,
file_contents
)))
def
permalink
(
content
):
if
content
[
'type'
]
==
'thread'
:
return
reverse
(
'django_comment_client.forum.views.single_thread'
,
args
=
[
content
[
'course_id'
],
content
[
'commentable_id'
],
content
[
'id'
]])
else
:
return
reverse
(
'django_comment_client.forum.views.single_thread'
,
args
=
[
content
[
'course_id'
],
content
[
'commentable_id'
],
content
[
'thread_id'
]])
+
'#'
+
content
[
'id'
]
def
render_content
(
content
,
additional_context
=
{}):
content_info
=
{
'displayed_title'
:
content
.
get
(
'highlighted_title'
)
or
content
.
get
(
'title'
,
''
),
'displayed_body'
:
content
.
get
(
'highlighted_body'
)
or
content
.
get
(
'body'
,
''
),
'raw_tags'
:
','
.
join
(
content
.
get
(
'tags'
,
[])),
'permalink'
:
permalink
(
content
),
}
context
=
{
'content'
:
merge_dict
(
content
,
content_info
),
'content'
:
extend_content
(
content
),
content
[
'type'
]:
True
,
}
context
=
merge_dict
(
context
,
additional_context
)
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
af0cbfb7
...
...
@@ -197,3 +197,20 @@ def url_for_tags(course_id, tags):
def
render_mustache
(
template_name
,
dictionary
,
*
args
,
**
kwargs
):
template
=
middleware
.
lookup
[
'main'
]
.
get_template
(
template_name
)
.
source
return
pystache
.
render
(
template
,
dictionary
)
def
permalink
(
content
):
if
content
[
'type'
]
==
'thread'
:
return
reverse
(
'django_comment_client.forum.views.single_thread'
,
args
=
[
content
[
'course_id'
],
content
[
'commentable_id'
],
content
[
'id'
]])
else
:
return
reverse
(
'django_comment_client.forum.views.single_thread'
,
args
=
[
content
[
'course_id'
],
content
[
'commentable_id'
],
content
[
'thread_id'
]])
+
'#'
+
content
[
'id'
]
def
extend_content
(
content
):
content_info
=
{
'displayed_title'
:
content
.
get
(
'highlighted_title'
)
or
content
.
get
(
'title'
,
''
),
'displayed_body'
:
content
.
get
(
'highlighted_body'
)
or
content
.
get
(
'body'
,
''
),
'raw_tags'
:
','
.
join
(
content
.
get
(
'tags'
,
[])),
'permalink'
:
permalink
(
content
),
}
return
merge_dict
(
content
,
content_info
)
lms/static/coffee/src/discussion/discussion.coffee
View file @
af0cbfb7
...
...
@@ -61,17 +61,16 @@ if Backbone?
$elem
=
$
(
event
.
target
)
url
=
DiscussionUtil
.
urlFor
'search_similar_threads'
,
@
model
.
id
data
=
{
text
:
@
$
(
".new-post-title"
).
val
()
}
DiscussionUtil
.
get
$elem
,
url
,
data
,
(
response
,
textStatus
)
=>
$similarPosts
.
empty
()
if
$
.
type
(
response
)
==
"array"
and
response
.
length
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
data
:
data
dataType
:
'json'
success
:
(
response
,
textStatus
)
=>
$wrapper
.
html
(
response
.
html
)
$wrapper
.
show
()
for
thread
in
response
$similarPost
=
$
(
"<a>"
).
addClass
(
"similar-post"
)
.
html
(
thread
[
"title"
])
.
attr
(
"href"
,
"javascript:void(0)"
)
#TODO
.
appendTo
(
$similarPosts
)
else
$wrapper
.
hide
()
$wrapper
.
find
(
".hide-similar-posts"
).
click
=>
$wrapper
.
hide
()
else
$wrapper
.
hide
()
$title
.
attr
(
"prev-text"
,
text
)
...
...
@@ -131,7 +130,7 @@ if Backbone?
@
$
(
".new-post-similar-posts"
).
empty
()
@
$
(
".new-post-similar-posts-wrapper"
).
hide
()
@
$
(
".new-post-title"
).
val
(
""
)
@
$
(
".new-post-title"
).
val
(
""
)
.
attr
(
"prev-text"
,
""
)
DiscussionUtil
.
setWmdContent
@
$el
,
$
.
proxy
(
@
$
,
@
),
"new-post-body"
,
""
@
$
(
".new-post-tags"
).
val
(
""
)
@
$
(
".new-post-tags"
).
importTags
(
""
)
...
...
lms/templates/discussion/_similar_posts.html
0 → 100644
View file @
af0cbfb7
% if len(threads) > 0:
Similar Posts:
<a
class=
"hide-similar-posts"
href=
"javascript:void(0)"
>
Hide
</a>
<div
class=
"new-post-similar-posts"
>
% for thread in threads:
<a
class=
"similar-post"
href=
"${thread['permalink']}"
>
${thread['title']}
</a>
% endfor
</div>
% endif
lms/templates/discussion/mustache/_new_post.mustache
View file @
af0cbfb7
<form
class=
"new-post-form collapsed"
id=
"new-post-form"
style=
"display: block; "
>
<ul
class=
"new-post-form-errors discussion-errors"
></ul>
<input
type=
"text"
class=
"new-post-title title-input"
placeholder=
"Title"
/>
<div
class=
"new-post-similar-posts-wrapper"
style=
"display: none"
>
Similar Posts:
<a
class=
"hide-similar-posts"
href=
"javascript:void(0)"
>
Hide
</a>
<div
class=
"new-post-similar-posts"
></div>
</div>
<div
class=
"new-post-similar-posts-wrapper"
style=
"display: none"
></div>
<div
class=
"new-post-body reply-body"
></div>
<input
class=
"new-post-tags"
placeholder=
"Tags"
/>
<div
class=
"post-options"
>
...
...
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