refactor: use MakoService.render_template to remove deprecation warnings

from block code.
This commit is contained in:
Jillian Vogel
2021-10-05 13:34:03 +10:30
parent 457f959356
commit 8d62d337f5
24 changed files with 91 additions and 49 deletions

View File

@@ -3,12 +3,12 @@ Code to wrap web fragments with a license.
"""
def wrap_with_license(block, view, frag, context): # pylint: disable=unused-argument
def wrap_with_license(block, view, frag, context, mako_service): # pylint: disable=unused-argument
"""
In the LMS, display the custom license underneath the XBlock.
"""
license = getattr(block, "license", None) # pylint: disable=redefined-builtin
if license:
context = {"license": license}
frag.content += block.runtime.render_template('license_wrapper.html', context)
frag.content += mako_service.render_template('license_wrapper.html', context)
return frag

View File

@@ -32,6 +32,7 @@ def _(text):
@XBlock.needs('user') # pylint: disable=abstract-method
@XBlock.needs('i18n')
@XBlock.needs('mako')
class DiscussionXBlock(XBlock, StudioEditableXBlockMixin, XmlParserMixin): # lint-amnesty, pylint: disable=abstract-method
"""
Provides a discussion forum that is inline with other content in the courseware.
@@ -202,7 +203,8 @@ class DiscussionXBlock(XBlock, StudioEditableXBlockMixin, XmlParserMixin): # li
'login_msg': login_msg,
}
fragment.add_content(self.runtime.render_template('discussion/_discussion_inline.html', context))
fragment.add_content(self.runtime.service(self, 'mako').render_template('discussion/_discussion_inline.html',
context))
fragment.initialize_js('DiscussionInlineBlock')
return fragment
@@ -212,7 +214,7 @@ class DiscussionXBlock(XBlock, StudioEditableXBlockMixin, XmlParserMixin): # li
Renders author view for Studio.
"""
fragment = Fragment()
fragment.add_content(self.runtime.render_template(
fragment.add_content(self.runtime.service(self, 'mako').render_template(
'discussion/_discussion_inline_studio.html',
{'discussion_id': self.discussion_id}
))