diff --git a/Makefile b/Makefile index 6c525a57b6..92a2e37b9a 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,6 @@ pull_translations: clean_translations ## pull translations via atlas make pull_plugin_translations atlas pull $(ATLAS_OPTIONS) \ translations/edx-platform/conf/locale:conf/locale \ - translations/studio-frontend/src/i18n/messages:conf/plugins-locale/studio-frontend python manage.py lms compilemessages python manage.py lms compilejsi18n python manage.py cms compilejsi18n diff --git a/cms/envs/common.py b/cms/envs/common.py index e219e3c48d..a40ef75dd3 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -1423,8 +1423,6 @@ ELASTIC_FIELD_MAPPINGS = { XBLOCK_FS_STORAGE_BUCKET = None XBLOCK_FS_STORAGE_PREFIX = None -STUDIO_FRONTEND_CONTAINER_URL = None - ############################ Global Database Configuration ##################### DATABASE_ROUTERS = [ diff --git a/cms/templates/container.html b/cms/templates/container.html index 36cf84d2b4..61e52f617a 100644 --- a/cms/templates/container.html +++ b/cms/templates/container.html @@ -36,10 +36,6 @@ from openedx.core.djangolib.markup import HTML, Text <%static:include path="common/templates/image-modal.underscore" /> -% if not settings.STUDIO_FRONTEND_CONTAINER_URL: - - -% endif <%block name="page_bundle"> diff --git a/cms/templates/container_chromeless.html b/cms/templates/container_chromeless.html index 647a68f322..3ef229e906 100644 --- a/cms/templates/container_chromeless.html +++ b/cms/templates/container_chromeless.html @@ -98,13 +98,6 @@ from openedx.core.release import RELEASE_LINE <%static:include path="common/templates/image-modal.underscore" /> - ## The following stylesheets are included for studio-frontend debugging. - ## Remove this as part of studio frontend deprecation. - ## https://github.com/openedx/studio-frontend/issues/381 - % if not settings.STUDIO_FRONTEND_CONTAINER_URL: - - - % endif diff --git a/cms/templates/container_editor.html b/cms/templates/container_editor.html index e7585d7b96..90ad0d32ee 100644 --- a/cms/templates/container_editor.html +++ b/cms/templates/container_editor.html @@ -77,10 +77,6 @@ from openedx.core.release import RELEASE_LINE <%static:include path="common/templates/image-modal.underscore" /> - % if not settings.STUDIO_FRONTEND_CONTAINER_URL: - - - % endif % for _, resource in resources: % if resource['kind'] == 'url' and resource['mimetype'] == 'text/css': diff --git a/common/djangoapps/pipeline_mako/helpers/studiofrontend.py b/common/djangoapps/pipeline_mako/helpers/studiofrontend.py deleted file mode 100644 index 41e2c4daf5..0000000000 --- a/common/djangoapps/pipeline_mako/helpers/studiofrontend.py +++ /dev/null @@ -1,41 +0,0 @@ -""" -Helpers for studio-frontend. - -Contains code that gets run inside our mako template -Debugging python-in-mako is terrible, so we've moved the actual code out to its own file -""" - - -import logging - -from django.conf import settings -from django.utils.translation import to_locale - -log = logging.getLogger(__name__) - - -def load_sfe_i18n_messages(language): - """ - Loads i18n data from studio-frontend's published files. - - This loads the i18n files pulled by the `make pull_translations` command. - - Returns: - str: unparsed i18n locale JSON file content as a string. - """ - messages = '{}' - - # because en is the default, studio-frontend will have it loaded by default - if language != 'en': - locale = to_locale(language) # fr-ca --> fr_CA format to match the file name in studio-frontend - messages_path = settings.REPO_ROOT / 'conf/plugins-locale/studio-frontend' / f'{locale}.json' - if messages_path.exists(): - try: - with open(messages_path) as messages_file: - messages = messages_file.read() - except OSError: - log.error(f"Error loading studiofrontend language files for langauge '{language}'", exc_info=True) - else: - log.warning(f"studiofrontend language files for langauge '{language}' was not found.") - - return messages diff --git a/common/djangoapps/pipeline_mako/templates/static_content.html b/common/djangoapps/pipeline_mako/templates/static_content.html index fc80c77e9e..345030c154 100644 --- a/common/djangoapps/pipeline_mako/templates/static_content.html +++ b/common/djangoapps/pipeline_mako/templates/static_content.html @@ -4,7 +4,6 @@ import logging import json from django.contrib.staticfiles.storage import staticfiles_storage from common.djangoapps.pipeline_mako import compressed_css, compressed_js -from common.djangoapps.pipeline_mako.helpers.studiofrontend import load_sfe_i18n_messages from django.utils.translation import get_language_bidi from mako.exceptions import TemplateLookupException from common.djangoapps.edxmako.shortcuts import marketing_link @@ -108,37 +107,6 @@ if not source: %>${source | n, decode.utf8} -<%def name="studiofrontend(entry)"> - <%doc> - Loads a studio-frontend page, with the necessary context. Context is expected - as a dictionary in the body of this tag. - - <% - body = capture(caller.body) - body_dict = json.loads(body) - locale = body_dict['lang'] - - messages = load_sfe_i18n_messages(locale) - %> - - -
- % if settings.STUDIO_FRONTEND_CONTAINER_URL: - - % else: - - - - % endif - - <%def name="webpack(entry, extension=None, config='DEFAULT', attrs='')"> <%doc> Loads Javascript onto your page from a Webpack-generated bundle. diff --git a/common/djangoapps/pipeline_mako/tests/test_studio_frontend.py b/common/djangoapps/pipeline_mako/tests/test_studio_frontend.py deleted file mode 100644 index 61b0b51b6c..0000000000 --- a/common/djangoapps/pipeline_mako/tests/test_studio_frontend.py +++ /dev/null @@ -1,51 +0,0 @@ -""" -Tests for the studiofrontend helper module. -""" - -import logging -import os - -import pytest - -from ..helpers import studiofrontend - - -def test_messages_file_not_found(tmpdir, settings, caplog): - """ - Ensure load_sfe_i18n_messages returns an empty json string when the messages file is not found. - """ - caplog.set_level(logging.INFO) - settings.REPO_ROOT = tmpdir - assert studiofrontend.load_sfe_i18n_messages('ar') == '{}' - assert 'studiofrontend language files for langauge \'ar\' was not found' in caplog.text - - -def test_messages_file_error(tmpdir, settings, caplog): - """ - Ensure load_sfe_i18n_messages returns an empty json string when the messages file is not found. - """ - caplog.set_level(logging.INFO) - settings.REPO_ROOT = tmpdir - # create a directory to cause an OSError when attempting to read it as a file - os.makedirs(tmpdir / 'conf/plugins-locale/studio-frontend/ar.json') - assert studiofrontend.load_sfe_i18n_messages('ar') == '{}' - assert 'Error loading studiofrontend language files for langauge' in caplog.text - - -@pytest.mark.parametrize('language', ['jp-jp', 'jp_JP']) -def test_messages_file_found(tmpdir, settings, caplog, language): - """ - Ensure load_sfe_i18n_messages finds the right language file and returns its content as string. - - django.utils.translation.get_language() returns 'jp-jp' or 'fr-ca' instead of 'jp_JP' or 'fr_CA' respectively. - - This test checks load_sfe_i18n_messages on both formats. - """ - caplog.set_level(logging.INFO) - settings.REPO_ROOT = tmpdir - studio_frontend_messages_dir = tmpdir / 'conf/plugins-locale/studio-frontend' - os.makedirs(studio_frontend_messages_dir) - messages_path = studio_frontend_messages_dir / 'jp_JP.json' - messages_path.write_text('{"homepage": "Homepage"}', encoding='utf-8') - assert studiofrontend.load_sfe_i18n_messages(language) == '{"homepage": "Homepage"}' - assert caplog.text == '' diff --git a/scripts/xsslint/tests/test_linters.py b/scripts/xsslint/tests/test_linters.py index 1c15894161..2aba52ed78 100644 --- a/scripts/xsslint/tests/test_linters.py +++ b/scripts/xsslint/tests/test_linters.py @@ -1244,22 +1244,16 @@ class TestMakoTemplateLinter(TestLinter): ${x | h} ${x | h} - <%static:studiofrontend page="${x}"> - ${x | h} - - ${x | h} """) linter._check_mako_file_is_safe(mako_template, results) - assert len(results.violations) == 7 + assert len(results.violations) == 5 assert results.violations[0].rule == MAKO_LINTER_RULESET.mako_unwanted_html_filter assert results.violations[1].rule == MAKO_LINTER_RULESET.mako_invalid_js_filter assert results.violations[2].rule == MAKO_LINTER_RULESET.mako_unwanted_html_filter assert results.violations[3].rule == MAKO_LINTER_RULESET.mako_invalid_js_filter assert results.violations[4].rule == MAKO_LINTER_RULESET.mako_unwanted_html_filter - assert results.violations[5].rule == MAKO_LINTER_RULESET.mako_invalid_js_filter - assert results.violations[6].rule == MAKO_LINTER_RULESET.mako_unwanted_html_filter def test_check_mako_expressions_javascript_strings(self): """ diff --git a/scripts/xsslint/xsslint/linters.py b/scripts/xsslint/xsslint/linters.py index a73e805dac..911c50a34f 100644 --- a/scripts/xsslint/xsslint/linters.py +++ b/scripts/xsslint/xsslint/linters.py @@ -1359,8 +1359,6 @@ class MakoTemplateLinter(BaseLinter): | # require js script tag end (optionally the _async version) <%static:webpack.*(? | # webpack script tag start | # webpack script tag end - <%static:studiofrontend.*?(? | # studiofrontend script tag start - | # studiofrontend script tag end <%block[ ]*name=['"]requirejs['"]\w*(? | # require js tag start # require js tag end """,