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