Commit b64236f6 by Ibrahim Awwal Committed by Matthew Mongeau

Embedded discussions displayed with the new style but without replying yet.

Needs different CSS to make it more appropriate in the embedded view.
parent 7ad88c64
......@@ -148,20 +148,19 @@ def get_threads(request, course_id, discussion_id=None):
# discussion per page is fixed for now
def inline_discussion(request, course_id, discussion_id):
<<<<<<< HEAD
try:
threads, query_params = get_threads(request, course_id, discussion_id)
user_info = cc.User.from_django_user(request.user).to_dict()
except (cc.utils.CommentClientError, cc.utils.CommentClientUnknownError) as err:
# TODO (vshnayder): since none of this code seems to be aware of the fact that
# sometimes things go wrong, I suspect that the js client is also not
# checking for errors on request. Check and fix as needed.
raise Http404
html = render_inline_discussion(request, course_id, threads, discussion_id=discussion_id, \
query_params=query_params)
return utils.JsonResponse({
'html': html,
'discussion_data': map(utils.safe_content, threads),
'user_info': user_info,
})
def render_search_bar(request, course_id, discussion_id=None, text=''):
......@@ -295,10 +294,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,
})
......
......@@ -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
$ ->
if !window.$$contents
window.$$contents = {}
$.fn.extend
loading: ->
@$_loading = $("<span class='discussion-loading'></span>")
......
......@@ -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'])
......
......@@ -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
}
}
<%include file="_underscore_templates.html" />
<div class="discussion-module">
<a class="discussion-show control-button" href="javascript:void(0)" discussion_id="${discussion_id | h}">Show Discussion</a>
</div>
......@@ -6,7 +6,7 @@
<a href="#" class="vote-btn discussion-vote discussion-vote-up"><span class="plus-icon">+</span> <span class='votes-count-number'>${'<%- votes["up_count"] %>'}</span></a>
<h1>${'<%- title %>'}</h1>
<p class="posted-details">
<span class="timeago" title="${'<%- created_at %>'}">sometime</span> by
<span class="timeago" title="${'<%- created_at %>'}">${'<%- created_at %>'}</span> by
<a href="${'<%- user_url %>'}">${'<%- username %>'}</a>
</p>
</header>
......@@ -17,7 +17,7 @@
<ol class="responses">
<li class="loading"><div class="loading-animation"></div></li>
</ol>
<form class="discussion-reply-new">
<form class="discussion-reply-new" data-id="${'<%- id %>'}">
<h4>Post a response:</h4>
<ul class="discussion-errors"></ul>
<div class="reply-body"></div>
......@@ -38,14 +38,14 @@
<ol class="comments">
<li>
<form class="comment-form">
<input type="text" placeholder="Comment" class="comment-form-input">
<input type="text" placeholder="Comment..." class="comment-form-input">
</form>
</li>
</ol>
</script>
<script type="text/template" id="response-comment-template">
<p><span class="response-body">${'<%- body %>'}</span><span class="posted-details">posted <span class="timeago" title="${'<%- created_at %>'}">sometime</span> by <a href="${'<%- user_url %>'}">${'<%- username %>'}</a></span></p>
<p><span class="response-body">${'<%- body %>'}</span><span class="posted-details">--posted <span class="timeago" title="${'<%- created_at %>'}">sometime</span> by <a href="${'<%- user_url %>'}">${'<%- username %>'}</a></span></p>
</script>
<script type="text/template" id="thread-list-item-template">
......
<section class="discussion">
{{#threads}}
<article class="discussion-article" data-id="{{id}}" id="thread_{{id}}">
</article>
{{/threads}}
</section>
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