Commit b7da6b2f by E. Kolpakov Committed by Zia Fazal

Moved discussion XBlock to edx-platform

(cherry picked from commit a7c0a2a)
parent 0e82b607
......@@ -19,10 +19,6 @@ from contentstore.utils import reverse_course_url, reverse_library_url, reverse_
__all__ = ['edge', 'event', 'landing']
# Add Discussion templates
add_lookup('lms.main', 'templates', package='discussion_app')
# points to the temporary course landing page with log in and sign up
def landing(request, org, course, coursename):
return render_to_response('temp-course-landing.html', {})
......
......@@ -17,6 +17,3 @@ def run():
clear_lookups(namespace)
for directory in directories:
add_lookup(namespace, directory)
# Add Discussion templates
add_lookup('main', 'templates', package='discussion_app')
......@@ -1267,19 +1267,21 @@ class DescriptorSystem(MetricsMixin, ConfigurableFragmentWrapper, Runtime): # p
return result
def handler_url(self, block, handler_name, suffix='', query='', thirdparty=False):
# Currently, Modulestore is responsible for instantiating DescriptorSystems
# This means that LMS/CMS don't have a way to define a subclass of DescriptorSystem
# that implements the correct handler url. So, for now, instead, we will reference a
# global function that the application can override.
return descriptor_global_handler_url(block, handler_name, suffix, query, thirdparty)
if block.xmodule_runtime is not None:
return block.xmodule_runtime.handler_url(block, handler_name, suffix, query, thirdparty)
else:
# Currently, Modulestore is responsible for instantiating DescriptorSystems
# This means that LMS/CMS don't have a way to define a subclass of DescriptorSystem
# that implements the correct handler url. So, for now, instead, we will reference a
# global function that the application can override.
return descriptor_global_handler_url(block, handler_name, suffix, query, thirdparty)
def local_resource_url(self, block, uri):
"""
See :meth:`xblock.runtime.Runtime:local_resource_url` for documentation.
"""
xmodule_runtime = getattr(block, 'xmodule_runtime', None)
if xmodule_runtime is not None:
return xmodule_runtime.local_resource_url(block, uri)
if block.xmodule_runtime is not None:
return block.xmodule_runtime.local_resource_url(block, uri)
else:
# Currently, Modulestore is responsible for instantiating DescriptorSystems
# This means that LMS/CMS don't have a way to define a subclass of DescriptorSystem
......@@ -1303,6 +1305,13 @@ class DescriptorSystem(MetricsMixin, ConfigurableFragmentWrapper, Runtime): # p
"""
raise NotImplementedError("edX Platform doesn't currently implement XBlock resource urls")
def publish(self, block, event_type, event):
"""
See :meth:`xblock.runtime.Runtime:publish` for documentation.
"""
if block.xmodule_runtime is not None:
return block.xmodule_runtime.publish(block, event_type, event)
def add_block_as_child_node(self, block, node):
child = etree.SubElement(node, "unknown")
child.set('url_name', block.url_name)
......
......@@ -98,7 +98,8 @@ if Backbone?
else
@$el.append($discussion)
@newPostForm = this.$el.find('.new-post-article')
@newPostForm = $('.new-post-article')
async = @options.async_thread_views
@threadviews = @discussion.map (thread) =>
view = new DiscussionThreadView(
el: @$("article#thread_#{thread.id}"),
......
......@@ -22,6 +22,8 @@ if Backbone?
if @mode not in ["tab", "inline"]
throw new Error("invalid mode: " + @mode)
@async_thread_views = if options.async_thread_views? then options.async_thread_views else false
# Quick fix to have an actual model when we're receiving new models from
# the server.
@model.collection.on "reset", (collection) =>
......@@ -227,7 +229,7 @@ if Backbone?
renderResponseToList: (response, listSelector, options) =>
response.set('thread', @model)
view = new ThreadResponseView($.extend({model: response}, options))
view = new ThreadResponseView($.extend({model: response, async: @async_thread_views}, options))
view.on "comment:add", @addComment
view.on "comment:endorse", @endorseThread
view.render()
......@@ -261,7 +263,6 @@ if Backbone?
comment = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), votes: { up_count: 0 }, abuse_flaggers:[], endorsed: false, user_id: window.user.get("id"))
comment.set('thread', @model.get('thread'))
@renderResponseToList(comment, ".js-response-list")
@renderAttrs()
@model.addComment()
@renderAddResponseButton()
......
......@@ -9,10 +9,12 @@
<%block name="headextra">
<%static:css group='style-course-vendor'/>
<%static:css group='style-course'/>
<%include file="_js_head_dependencies.html" />
</%block>
<%block name="js_extra">
<%include file="/discussion/_js_body_dependencies.html" />
<%include file="_js_body_dependencies.html" />
<%static:js group='discussion'/>
<script language="javascript">
$(function () {
......@@ -31,7 +33,7 @@
<nav>
<article class="sidebar-module discussion-sidebar">
<%include file="/discussion/_user_profile.html" />
<%include file="_user_profile.html" />
</article>
</nav>
......@@ -41,4 +43,4 @@
</div>
</section>
<%include file="/discussion/_underscore_templates.html" />
<%include file="_underscore_templates.html" />
......@@ -66,7 +66,6 @@
<%static:css group='style-app'/>
<%static:css group='style-app-extend1'/>
<%static:css group='style-app-extend2'/>
<%static:css group='style-discussion-app'/>
% if disable_courseware_js:
<%static:js group='base_vendor'/>
......
......@@ -13,7 +13,6 @@
{% compressed_css 'style-app-extend2' %}
{% compressed_css 'style-course-vendor' %}
{% compressed_css 'style-course' %}
{% compressed_css 'style-discussion-app' %}
{% block main_vendor_js %}
{% compressed_js 'main_vendor' %}
......
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