Skip to content

Commit

Permalink
feat: adds "Go to Superset" link to Instructor Dashboard plugin
Browse files Browse the repository at this point in the history
Because the plugin's template is a mako template, also had to configure
i18n_tools to extract translations from mako templates.
  • Loading branch information
pomegranited committed Mar 13, 2024
1 parent c1c4e11 commit 4e40f21
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 1 deletion.
10 changes: 10 additions & 0 deletions platform_plugin_aspects/conf/locale/babel_mako.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Extraction from Mako templates.
# Mako files can appear in a number of different places. Some we want to
# extract strings from, some we don't.
#
# Extract from these directory trees:
#
# templates/instructor_dashboard/
#
[mako: templates/**/*.html]
input_encoding = utf-8
Binary file not shown.
23 changes: 23 additions & 0 deletions platform_plugin_aspects/conf/locale/en/LC_MESSAGES/mako.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Translations template for PROJECT.
# Copyright (C) 2024 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-03-13 11:48+1030\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.14.0\n"

#: templates/instructor_dashboard/aspects.html:17
msgid "Go to Superset"
msgstr ""

Binary file not shown.
23 changes: 23 additions & 0 deletions platform_plugin_aspects/conf/locale/eo/LC_MESSAGES/mako.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Translations template for PROJECT.
# Copyright (C) 2024 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-03-13 11:48+1030\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: eo\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Generated-By: Babel 2.14.0\n"

#: templates/instructor_dashboard/aspects.html
msgid "Go to Superset"
msgstr "Gö tö Süpérsét Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт#"
1 change: 1 addition & 0 deletions platform_plugin_aspects/extensions/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def run_filter(
"section_key": BLOCK_CATEGORY,
"section_display_name": BLOCK_CATEGORY.title(),
"course_id": str(course.id),
"superset_url": str(context.get("superset_url")),
"template_path_prefix": TEMPLATE_ABSOLUTE_PATH,
}
context["sections"].append(section_data)
Expand Down
2 changes: 2 additions & 0 deletions platform_plugin_aspects/extensions/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_run_filter(self, mock_generate_superset_context):
"""
mock_generate_superset_context.return_value = {
"sections": [],
"superset_url": "http://superset.testing",
}

context = self.filter.run_filter(self.context, self.template_name)
Expand All @@ -40,6 +41,7 @@ def test_run_filter(self, mock_generate_superset_context):
"course_id": str(self.context["course"].id),
"section_key": BLOCK_CATEGORY,
"section_display_name": BLOCK_CATEGORY.title(),
"superset_url": "http://superset.testing",
"template_path_prefix": "/instructor_dashboard/",
},
context["context"]["sections"][0],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
## mako

<%page args="section_data" expression_filter="h"/>
<%! from openedx.core.djangolib.markup import HTML %>
<%!
from django.utils.translation import gettext as _
from openedx.core.djangolib.markup import HTML
%>

<%include file="/courseware/xqa_interface.html/"/>
<%
superset_url = section_data.get("superset_url")
%>

<section class="superset">
% if superset_url:
<div class="superset-link">
<a href="${superset_url}">${_("Go to Superset")}</a>
</div>
% endif
${HTML(section_data['fragment'].body_html())}
</section>

0 comments on commit 4e40f21

Please sign in to comment.