diff --git a/platform_plugin_aspects/apps.py b/platform_plugin_aspects/apps.py index 8c65218..e5e6a4f 100644 --- a/platform_plugin_aspects/apps.py +++ b/platform_plugin_aspects/apps.py @@ -75,6 +75,6 @@ def ready(self): from platform_plugin_aspects.extensions import ( # pylint: disable=unused-import, import-outside-toplevel filters, ) - from platform_plugin_aspects.xblock_aside import ( # pylint: disable=unused-import, import-outside-toplevel - AspectsAside + from platform_plugin_aspects.xblock_aside import ( # pylint: disable=unused-import, import-outside-toplevel + AspectsAside, ) diff --git a/platform_plugin_aspects/signals.py b/platform_plugin_aspects/signals.py index 6eda30b..f03ec07 100644 --- a/platform_plugin_aspects/signals.py +++ b/platform_plugin_aspects/signals.py @@ -5,6 +5,7 @@ from django.db import transaction from django.db.models.signals import post_delete, post_save from django.dispatch import Signal, receiver +from opaque_keys import InvalidKeyError from platform_plugin_aspects.sinks import ( CourseEnrollmentSink, @@ -17,8 +18,6 @@ ) from platform_plugin_aspects.utils import get_model -from opaque_keys import InvalidKeyError - try: from openedx.core.djangoapps.user_api.accounts.signals import USER_RETIRE_LMS_MISC except ImportError: diff --git a/platform_plugin_aspects/static/html/example.html b/platform_plugin_aspects/static/html/example.html index dff5f98..bc3ffeb 100644 --- a/platform_plugin_aspects/static/html/example.html +++ b/platform_plugin_aspects/static/html/example.html @@ -1,3 +1,6 @@ -

-Hola desde aside {{xblock_id}} -

\ No newline at end of file +{% load i18n %} + + diff --git a/platform_plugin_aspects/xblock_aside.py b/platform_plugin_aspects/xblock_aside.py index 6b274cf..05b5129 100644 --- a/platform_plugin_aspects/xblock_aside.py +++ b/platform_plugin_aspects/xblock_aside.py @@ -5,10 +5,10 @@ import logging import pkg_resources +from common.djangoapps.edxmako.shortcuts import render_to_string from django.template import Context, Template from django.utils import translation from web_fragments.fragment import Fragment -from common.djangoapps.edxmako.shortcuts import render_to_string from xblock.core import XBlock, XBlockAside from xblock.fields import Scope, String from xblock.utils.resources import ResourceLoader @@ -18,6 +18,7 @@ from platform_plugin_aspects.xblock import ResourceLoader + @XBlock.needs("user") @XBlock.needs("i18n") class AspectsAside(XBlockAside): @@ -29,7 +30,9 @@ def _get_block(self): """ Get the block wrapped by this aside. """ - from xmodule.modulestore.django import modulestore # pylint: disable=import-error, import-outside-toplevel + from xmodule.modulestore.django import ( + modulestore, # pylint: disable=import-error, import-outside-toplevel + ) return modulestore().get_item(self.scope_ids.usage_id.usage_key) @@ -42,11 +45,9 @@ def student_view_aside(self, block, context): # pylint: disable=unused-argument depending on the context. """ logger.info(f"Class name {block.__class__.__name__}") - if block.__class__.__name__.replace("WithMixins", "") in ['ProblemBlock']: + if block.__class__.__name__.replace("WithMixins", "") in ["ProblemBlock"]: frag = Fragment() - context.update({ - "xblock_id": self.scope_ids.usage_id.usage_key - }) + context.update({"xblock_id": self.scope_ids.usage_id.usage_key}) frag.add_content(self.render_template("static/html/example.html", context)) # frag.add_javascript_url(self._get_studio_resource_url('/js/xblock_asides/structured_tags.js')) # frag.initialize_js('StructuredTagsInit') @@ -63,7 +64,6 @@ def should_apply_to_block(cls, block): # logger.info(block.__dict__) return True - def render_template(self, template_path, context=None) -> str: """ Render a template with the given context. @@ -79,4 +79,4 @@ def render_template(self, template_path, context=None) -> str: """ return loader.render_django_template( template_path, context, i18n_service=self.runtime.service(self, "i18n") - ) \ No newline at end of file + )