Commit 44f7b37b by Rocky Duan

refactored comment_client working

parent b7d33618
......@@ -59,7 +59,7 @@ def render_discussion(request, course_id, threads, discussion_id=None, \
context = {
'threads': threads,
'discussion_id': discussion_id,
'user_info': dict(cc.User.from_django_user(request.user)),#comment_client.get_user_info(request.user.id, raw=True),
'user_info': json.dumps(cc.User.from_django_user(request.user).to_dict()),
'course_id': course_id,
'request': request,
'performed_search': _should_perform_search(request),
......@@ -90,7 +90,6 @@ def get_threads(request, course_id, discussion_id):
'course_id': course_id,
}
import pdb; pdb.set_trace()
threads, page, num_pages = cc.Thread.search(query_params)
#if _should_perform_search(request):
......@@ -172,16 +171,16 @@ def get_annotated_content_infos(course_id, thread, user, is_thread=True):
def render_single_thread(request, discussion_id, course_id, thread_id):
thread = cc.Thread.find(thread_id).retrieve_with_comments()
thread = cc.Thread.find(thread_id).retrieve(recursive=True)
#comment_client.get_thread(thread_id, recursive=True)
annotated_content_info = get_annotated_content_infos(course_id, thread=dict(thread), \
annotated_content_info = get_annotated_content_infos(course_id, thread=thread.to_dict(), \
user=request.user, is_thread=True)
context = {
'discussion_id': discussion_id,
'thread': thread,
'user_info': dict(cc.User.from_django_user(request.user)),#get_user_info(request.user.id, raw=True),
'user_info': cc.User.from_django_user(request.user).to_dict(),#get_user_info(request.user.id, raw=True),
'annotated_content_info': json.dumps(annotated_content_info),
'course_id': course_id,
'request': request,
......@@ -192,9 +191,9 @@ def single_thread(request, course_id, discussion_id, thread_id):
if request.is_ajax():
thread = cc.Thread.find(thread_id).retrieve_with_comments()#comment_client.get_thread(thread_id, recursive=True)
thread = cc.Thread.find(thread_id).retrieve(recursive=True)
annotated_content_info = get_annotated_content_infos(course_id, thread, request.user)
context = {'thread': dict(thread)}
context = {'thread': thread.to_dict()}
html = render_to_string('discussion/_ajax_single_thread.html', context)
return utils.JsonResponse({
......
......@@ -183,8 +183,6 @@ initializeFollowThread = (thread) ->
handleEndorse = (elem, endorsed) ->
url = Discussion.urlFor('endorse_comment', id)
console.log endorsed
console.log url
Discussion.safeAjax
$elem: $(elem)
url: url
......
......@@ -79,7 +79,6 @@ initializeFollowDiscussion = (discussion) ->
data:
text: $local(".new-post-title").val()
success: (response, textStatus) ->
console.log "request"
$similarPosts.empty()
if $.type(response) == "array" and response.length
$wrapper.show()
......
......@@ -116,7 +116,6 @@ wmdEditors = {}
appended_id = "-#{cls_identifier}-#{id}"
imageUploadUrl = Discussion.urlFor('upload')
editor = Markdown.makeWmdEditor elem, appended_id, imageUploadUrl, Discussion.postMathJaxProcessor
console.log editor
wmdEditors["#{cls_identifier}-#{id}"] = editor
$input = $("#wmd-input-#{cls_identifier}-#{id}")
$input.attr("placeholder", "post a new topic...").bind 'focus', (e) ->
......
<%namespace name="renderer" file="_thread.html"/>
<%! from django.template.defaultfilters import escapejs %>
<section class="discussion inline-discussion" _id="${discussion_id}">
......@@ -27,18 +28,11 @@
<%include file="_paginator.html" />
</section>
<%!
def escape_quotes(text):
return text.replace('\"', '\\\"').replace("\'", "\\\'")
%>
<script type="text/javascript">
var $$user_info = JSON.parse('${user_info | escape_quotes}');
var $$course_id = "${course_id}";
var $$user_info = JSON.parse("${user_info | escapejs}");
var $$course_id = "${course_id | escapejs}";
if (typeof $$annotated_content_info === undefined || $$annotated_content_info === null) {
var $$annotated_content_info = {};
}
$$annotated_content_info = $.extend($$annotated_content_info, JSON.parse("${annotated_content_info | escape_quotes}"));
$$annotated_content_info = $.extend($$annotated_content_info, JSON.parse("${annotated_content_info | escapejs}"));
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment