Skip to content

Commit

Permalink
Merge pull request #51 from openedx/bmtcril/superset_link_updates
Browse files Browse the repository at this point in the history
Change Superset link text, make the link optional
  • Loading branch information
Cristhian Garcia authored May 16, 2024
2 parents 6ef7dee + 0c0e2b4 commit 818d383
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 28 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ Change Log
Unreleased
**********

0.9.3 - 2024-05-15
******************

Fixes
=====

* Change wording of the "go to Superset" link, and make it optional.


0.9.2 - 2024-05-08
******************

Expand Down
2 changes: 1 addition & 1 deletion platform_plugin_aspects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
import os
from pathlib import Path

__version__ = "0.9.2"
__version__ = "0.9.3"

ROOT_DIRECTORY = Path(os.path.dirname(os.path.abspath(__file__)))
15 changes: 12 additions & 3 deletions platform_plugin_aspects/extensions/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ def run_filter(
"""
course = context["course"]
dashboards = settings.ASPECTS_INSTRUCTOR_DASHBOARDS
show_dashboard_link = settings.SUPERSET_SHOW_INSTRUCTOR_DASHBOARD_LINK

user = get_current_user()

user_language = (
get_model("user_preference").get_value(user, "pref-lang") or "en"
)
try:
user_language = (
get_model("user_preference").get_value(user, "pref-lang") or "en"
)
# If there is no user_preferences model defined this will get thrown
except AttributeError:
user_language = "en"

formatted_language = user_language.lower().replace("-", "_")
if formatted_language not in [
loc.lower().replace("-", "_") for loc in settings.SUPERSET_DASHBOARD_LOCALES
Expand All @@ -62,7 +68,10 @@ def run_filter(
"superset_guest_token_url": str(context.get("superset_guest_token_url")),
"superset_url": str(context.get("superset_url")),
"template_path_prefix": TEMPLATE_ABSOLUTE_PATH,
"show_dashboard_link": show_dashboard_link,
}

print(section_data)
context["sections"].append(section_data)
return {
"context": context,
Expand Down
39 changes: 17 additions & 22 deletions platform_plugin_aspects/extensions/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,15 @@ def test_run_filter_with_language(

context = self.filter.run_filter(self.context, self.template_name)

self.assertDictContainsSubset(
{
"course_id": self.course_id,
"section_key": BLOCK_CATEGORY,
"section_display_name": "Reports",
"superset_url": "http://superset-dummy-url/",
"superset_guest_token_url": f"https://lms.url/superset_guest_token/{self.course_id}",
"template_path_prefix": "/instructor_dashboard/",
},
context["context"]["sections"][0],
)
assert {
"course_id": self.course_id,
"section_key": BLOCK_CATEGORY,
"section_display_name": "Reports",
"superset_url": "http://superset-dummy-url/",
"superset_guest_token_url": f"https://lms.url/superset_guest_token/{self.course_id}",
"template_path_prefix": "/instructor_dashboard/",
}.items() <= context["context"]["sections"][0].items()

mock_get_model.assert_called_once()

@patch("platform_plugin_aspects.extensions.filters.get_model")
Expand All @@ -66,16 +64,13 @@ def test_run_filter_without_language(

context = self.filter.run_filter(self.context, self.template_name)

self.assertDictContainsSubset(
{
"course_id": self.course_id,
"section_key": BLOCK_CATEGORY,
"section_display_name": "Reports",
"superset_url": "http://superset-dummy-url/",
"superset_guest_token_url": f"https://lms.url/superset_guest_token/{self.course_id}",
"template_path_prefix": "/instructor_dashboard/",
},
context["context"]["sections"][0],
)
assert {
"course_id": self.course_id,
"section_key": BLOCK_CATEGORY,
"section_display_name": "Reports",
"superset_url": "http://superset-dummy-url/",
"superset_guest_token_url": f"https://lms.url/superset_guest_token/{self.course_id}",
"template_path_prefix": "/instructor_dashboard/",
}.items() <= context["context"]["sections"][0].items()

mock_get_model.assert_called_once()
1 change: 1 addition & 0 deletions platform_plugin_aspects/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def plugin_settings(settings):
"allow_translations": True,
},
]
settings.SUPERSET_SHOW_INSTRUCTOR_DASHBOARD_LINK = True
settings.SUPERSET_EXTRA_FILTERS_FORMAT = []
settings.SUPERSET_DASHBOARD_LOCALES = ["en"]
settings.EVENT_SINK_CLICKHOUSE_BACKEND_CONFIG = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
<%include file="/courseware/xqa_interface.html/"/>
<%
superset_url = section_data.get("superset_url")
show_superset_link = superset_url and section_data.get("show_dashboard_link")
%>

<section class="superset">
% if superset_url:
% if show_superset_link:
<div class="superset-link">
<a href="${superset_url}login/openedxsso">${_("Go to Superset to create new or further customize the reports below.")}</a>
<a href="${superset_url}login/openedxsso">${_("View dashboards in Superset")}</a>
</div>
% endif
${HTML(section_data['fragment'].body_html())}
Expand Down
1 change: 1 addition & 0 deletions test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,5 @@
"timeout_secs": 1,
}

SUPERSET_SHOW_INSTRUCTOR_DASHBOARD_LINK = True
SUPERSET_DASHBOARD_LOCALES = ["en_US", "es_419"]

0 comments on commit 818d383

Please sign in to comment.