Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync opencraft-release/palm.1 with Upstream 20230814-1691971365 #573

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lms/djangoapps/courseware/tests/test_discussion_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from unittest import mock
import ddt
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
from opaque_keys.edx.keys import CourseKey
from web_fragments.fragment import Fragment
Expand Down Expand Up @@ -167,6 +169,7 @@ def test_studio_view(self):
}
)

@override_settings(FEATURES=dict(settings.FEATURES, ENABLE_DISCUSSION_SERVICE='True'))
@ddt.data(
(False, False, False),
(True, False, False),
Expand Down Expand Up @@ -231,6 +234,7 @@ def test_studio_view(self):
fragment = self.block.author_view({})
assert f'data-discussion-id="{self.discussion_id}"' in fragment.content

@override_settings(FEATURES=dict(settings.FEATURES, ENABLE_DISCUSSION_SERVICE='True'))
@ddt.data(
(True, False, False),
(False, True, False),
Expand Down Expand Up @@ -290,6 +294,7 @@ def get_root(self, block):
block = block.get_parent()
return block

@override_settings(FEATURES=dict(settings.FEATURES, ENABLE_DISCUSSION_SERVICE='True'))
def test_html_with_user(self):
"""
Test rendered DiscussionXBlock permissions.
Expand All @@ -308,6 +313,7 @@ def test_html_with_user(self):
assert 'data-user-create-comment="false"' in html
assert 'data-user-create-subcomment="false"' in html

@override_settings(FEATURES=dict(settings.FEATURES, ENABLE_DISCUSSION_SERVICE='True'))
def test_discussion_render_successfully_with_orphan_parent(self):
"""
Test that discussion xblock render successfully
Expand Down Expand Up @@ -407,6 +413,7 @@ class TestXBlockQueryLoad(SharedModuleStoreTestCase):
Test the number of queries executed when rendering the XBlock.
"""

@override_settings(FEATURES=dict(settings.FEATURES, ENABLE_DISCUSSION_SERVICE='True'))
def test_permissions_query_load(self):
"""
Tests that the permissions queries are cached when rendering numerous discussion XBlocks.
Expand Down
35 changes: 20 additions & 15 deletions xmodule/discussion_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ def student_view(self, context=None):
"""
Renders student view for LMS.
"""
# to prevent a circular import issue
import lms.djangoapps.discussion.django_comment_client.utils as utils

fragment = Fragment()

if not self.is_visible:
Expand All @@ -189,21 +192,23 @@ def student_view(self, context=None):
),
)

context = {
'discussion_id': self.discussion_id,
'display_name': self.display_name if self.display_name else _("Discussion"),
'user': self.django_user,
'course_id': self.course_key,
'discussion_category': self.discussion_category,
'discussion_target': self.discussion_target,
'can_create_thread': self.has_permission("create_thread"),
'can_create_comment': self.has_permission("create_comment"),
'can_create_subcomment': self.has_permission("create_sub_comment"),
'login_msg': login_msg,
}

fragment.add_content(self.runtime.service(self, 'mako').render_template('discussion/_discussion_inline.html',
context))
if utils.is_discussion_enabled(self.course_key):
context = {
'discussion_id': self.discussion_id,
'display_name': self.display_name if self.display_name else _("Discussion"),
'user': self.django_user,
'course_id': self.course_key,
'discussion_category': self.discussion_category,
'discussion_target': self.discussion_target,
'can_create_thread': self.has_permission("create_thread"),
'can_create_comment': self.has_permission("create_comment"),
'can_create_subcomment': self.has_permission("create_sub_comment"),
'login_msg': login_msg,
}
fragment.add_content(
self.runtime.service(self, 'mako').render_template('discussion/_discussion_inline.html', context)
)

fragment.initialize_js('DiscussionInlineBlock')

return fragment
Expand Down
Loading