From 32ccf51e97caa784b5336f5dc63fec1bcafd2dcc Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Tue, 4 Sep 2012 01:13:55 -0700 Subject: [PATCH] Embedded discussions displayed with the new style but without replying yet. Needs different CSS to make it more appropriate in the embedded view. --- .../django_comment_client/forum/views.py | 15 +++++---- .../src/discussion/discussion_module.coffee | 11 +++++-- lms/static/coffee/src/discussion/utils.coffee | 2 ++ .../views/discussion_thread_view.coffee | 2 +- lms/static/sass/_discussion.scss | 33 +++++-------------- .../discussion/_discussion_module.html | 2 ++ .../discussion/_underscore_templates.html | 8 ++--- .../mustache/_inline_discussion.mustache | 6 ++++ 8 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 lms/templates/discussion/mustache/_inline_discussion.mustache diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 77883ae898..84739ceffc 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -123,12 +123,14 @@ def get_threads(request, course_id, discussion_id=None): # discussion per page is fixed for now def inline_discussion(request, course_id, discussion_id): threads, query_params = get_threads(request, course_id, discussion_id) - html = render_inline_discussion(request, course_id, threads, discussion_id=discussion_id, \ - query_params=query_params) - + # TODO: Remove all of this stuff or switch back to server side rendering once templates are mustache again +# html = render_inline_discussion(request, course_id, threads, discussion_id=discussion_id, \ +# query_params=query_params) + user_info = cc.User.from_django_user(request.user).to_dict() return utils.JsonResponse({ - 'html': html, +# 'html': html, 'discussion_data': map(utils.safe_content, threads), + 'user_info': user_info, }) def render_search_bar(request, course_id, discussion_id=None, text=''): @@ -207,10 +209,11 @@ def single_thread(request, course_id, discussion_id, thread_id): thread = cc.Thread.find(thread_id).retrieve(recursive=True) annotated_content_info = utils.get_annotated_content_infos(course_id, thread, request.user, user_info=user_info) context = {'thread': thread.to_dict(), 'course_id': course_id} - html = render_to_string('discussion/_ajax_single_thread.html', context) + # TODO: Remove completely or switch back to server side rendering +# html = render_to_string('discussion/_ajax_single_thread.html', context) return utils.JsonResponse({ - 'html': html, +# 'html': html, 'content': utils.safe_content(thread.to_dict()), 'annotated_content_info': annotated_content_info, }) diff --git a/lms/static/coffee/src/discussion/discussion_module.coffee b/lms/static/coffee/src/discussion/discussion_module.coffee index 8306d4d2ae..f0f54bada7 100644 --- a/lms/static/coffee/src/discussion/discussion_module.coffee +++ b/lms/static/coffee/src/discussion/discussion_module.coffee @@ -23,12 +23,17 @@ if Backbone? type: "GET" dataType: 'json' success: (response, textStatus) => - @$el.append(response.html) - $discussion = @$el.find("section.discussion") + #@$el.append(response.html) + window.user = new DiscussionUser(response.user_info) $(event.target).html("Hide Discussion") discussion = new Discussion() discussion.reset(response.discussion_data, {silent: false}) - view = new DiscussionView(el: $discussion[0], model: discussion) + $discussion = $(Mustache.render $("script#_inline_discussion").html(), {'threads':response.discussion_data}) + $(".discussion-module").append($discussion) + discussion.each (thread) -> + element = $("article#thread_#{thread.id}") + dtv = new DiscussionThreadView el: element, model: thread + dtv.render() DiscussionUtil.bulkUpdateContentInfo(window.$$annotated_content_info) @retrieved = true @showed = true diff --git a/lms/static/coffee/src/discussion/utils.coffee b/lms/static/coffee/src/discussion/utils.coffee index fa0bbda5e8..4beec4734d 100644 --- a/lms/static/coffee/src/discussion/utils.coffee +++ b/lms/static/coffee/src/discussion/utils.coffee @@ -1,4 +1,6 @@ $ -> + if !window.$$contents + window.$$contents = {} $.fn.extend loading: -> @$_loading = $("") diff --git a/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee b/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee index 441929a05f..b8447d81bb 100644 --- a/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee +++ b/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee @@ -29,7 +29,7 @@ class @DiscussionThreadView extends Backbone.View renderResponses: -> DiscussionUtil.safeAjax - url: @model.id + url: "/courses/#{$$course_id}/discussion/forum/#{@model.get('commentable_id')}/threads/#{@model.id}" success: (data, textStatus, xhr) => @$(".loading").remove() comments = new Comments(data['content']['children']) diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 6e92d8deed..61bc4ef77e 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -1389,13 +1389,6 @@ body.discussion { - - - - - - - .global-discussion-actions { height: 60px; @include linear-gradient(top, #ebebeb, #d9d9d9); @@ -1403,21 +1396,13 @@ body.discussion { border-bottom: 1px solid #bcbcbc; } +.discussion-module { + @extend .discussion-body +} - - - - - - - - - - - - - - - - - +/* For some reason I have to do this to get the SCSS to compile, can't stick it under the above .discussion-module */ +.discussion-module { + .discussion-reply-new { + display:none + } +} diff --git a/lms/templates/discussion/_discussion_module.html b/lms/templates/discussion/_discussion_module.html index b9e69cc0ad..99c0602b41 100644 --- a/lms/templates/discussion/_discussion_module.html +++ b/lms/templates/discussion/_discussion_module.html @@ -1,3 +1,5 @@ +<%include file="_underscore_templates.html" /> +
Show Discussion
diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index 1a28843271..76461c1560 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -6,7 +6,7 @@ + ${'<%- votes["up_count"] %>'}

${'<%- title %>'}

- sometime by + ${'<%- created_at %>'} by ${'<%- username %>'}

@@ -17,7 +17,7 @@
-
+

Post a response:

@@ -38,14 +38,14 @@
  1. - +