Commit 384f0191 by Ibrahim Awwal

Rename discussion_data to threads.

parent afb2e3b7
...@@ -139,7 +139,7 @@ def forum_form_discussion(request, course_id): ...@@ -139,7 +139,7 @@ def forum_form_discussion(request, course_id):
if request.is_ajax(): if request.is_ajax():
return utils.JsonResponse({ return utils.JsonResponse({
'discussion_data': context['threads'], # TODO: Standardize on 'discussion_data' vs 'threads' 'threads': context['threads'],
'annotated_content_info': context['annotated_content_info'], 'annotated_content_info': context['annotated_content_info'],
'num_pages': query_params['num_pages'], 'num_pages': query_params['num_pages'],
'page': query_params['page'], 'page': query_params['page'],
...@@ -218,7 +218,7 @@ def user_profile(request, course_id, user_id): ...@@ -218,7 +218,7 @@ def user_profile(request, course_id, user_id):
if request.is_ajax(): if request.is_ajax():
return utils.JsonResponse({ return utils.JsonResponse({
'discussion_data': context['threads'], 'threads': context['threads'],
'page': page, 'page': page,
'num_pages': num_pages, 'num_pages': num_pages,
'annotated_content_info': context['annotated_content_info'], 'annotated_content_info': context['annotated_content_info'],
...@@ -252,13 +252,7 @@ def followed_threads(request, course_id, user_id): ...@@ -252,13 +252,7 @@ def followed_threads(request, course_id, user_id):
threads, page, num_pages = profiled_user.subscribed_threads(query_params) threads, page, num_pages = profiled_user.subscribed_threads(query_params)
context = threads_context(request.user, threads, course_id, page, num_pages) context = threads_context(request.user, threads, course_id, page, num_pages)
#return utils.JsonResponse(extract(context, ['annotated_content_info', 'threads', 'page', 'num_pages'])) return utils.JsonResponse(extract(context, ['annotated_content_info', 'threads', 'page', 'num_pages']))
return utils.JsonResponse({
'annotated_content_info': context['annotated_content_info'],
'discussion_data': context['threads'],
'page': page,
'num_pages': num_pages,
})
except (cc.utils.CommentClientError, cc.utils.CommentClientUnknownError) as err: except (cc.utils.CommentClientError, cc.utils.CommentClientUnknownError) as err:
raise Http404 raise Http404
...@@ -66,7 +66,7 @@ if Backbone? ...@@ -66,7 +66,7 @@ if Backbone?
dataType: 'json' dataType: 'json'
success: (response, textStatus) => success: (response, textStatus) =>
models = @models models = @models
new_threads = [new Thread(data) for data in response.discussion_data][0] new_threads = [new Thread(data) for data in response.threads][0]
new_collection = _.union(models, new_threads) new_collection = _.union(models, new_threads)
Content.loadContentInfos(response.annotated_content_info) Content.loadContentInfos(response.annotated_content_info)
@reset new_collection @reset new_collection
......
...@@ -72,8 +72,8 @@ if Backbone? ...@@ -72,8 +72,8 @@ if Backbone?
allow_anonymous_to_peers = response.allow_anonymous_to_peers allow_anonymous_to_peers = response.allow_anonymous_to_peers
# $elem.html("Hide Discussion") # $elem.html("Hide Discussion")
@discussion = new Discussion() @discussion = new Discussion()
@discussion.reset(response.discussion_data, {silent: false}) @discussion.reset(response.threads, {silent: false})
$discussion = $(Mustache.render $("script#_inline_discussion").html(), {'threads':response.discussion_data, 'discussionId': discussionId, 'allow_anonymous_to_peers': allow_anonymous_to_peers, 'allow_anonymous': allow_anonymous}) $discussion = $(Mustache.render $("script#_inline_discussion").html(), {'threads':response.threads, 'discussionId': discussionId, 'allow_anonymous_to_peers': allow_anonymous_to_peers, 'allow_anonymous': allow_anonymous})
if @$('section.discussion').length if @$('section.discussion').length
@$('section.discussion').replaceWith($discussion) @$('section.discussion').replaceWith($discussion)
else else
......
...@@ -274,7 +274,7 @@ if Backbone? ...@@ -274,7 +274,7 @@ if Backbone?
success: (response, textStatus) => success: (response, textStatus) =>
@collection.current_page = response.page @collection.current_page = response.page
@collection.pages = response.num_pages @collection.pages = response.num_pages
@collection.reset(response.discussion_data) @collection.reset(response.threads)
Content.loadContentInfos(response.annotated_content_info) Content.loadContentInfos(response.annotated_content_info)
@displayedCollection.reset(@collection.models)# Don't think this is necessary because it's called on collection.reset @displayedCollection.reset(@collection.models)# Don't think this is necessary because it's called on collection.reset
if callback? if callback?
...@@ -337,7 +337,7 @@ if Backbone? ...@@ -337,7 +337,7 @@ if Backbone?
success: (response, textStatus) => success: (response, textStatus) =>
if textStatus == 'success' if textStatus == 'success'
# TODO: Augment existing collection? # TODO: Augment existing collection?
@collection.reset(response.discussion_data) @collection.reset(response.threads)
Content.loadContentInfos(response.annotated_content_info) Content.loadContentInfos(response.annotated_content_info)
@collection.current_page = response.page @collection.current_page = response.page
@collection.pages = response.num_pages @collection.pages = response.num_pages
......
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