From 1c997ec1bc7bd8ba41a8fe5be40917d19700dbe1 Mon Sep 17 00:00:00 2001 From: Brian Mesick Date: Wed, 15 May 2024 14:12:09 -0400 Subject: [PATCH 1/3] refactor: Bump version, update changelog --- CHANGELOG.rst | 9 +++++++ platform_plugin_aspects/__init__.py | 2 +- platform_plugin_aspects/extensions/filters.py | 2 ++ .../extensions/tests/test_filters.py | 27 ++++++++----------- platform_plugin_aspects/settings/common.py | 1 + .../instructor_dashboard/aspects.html | 5 ++-- test_settings.py | 1 + 7 files changed, 28 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8401d95..568737f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 ****************** diff --git a/platform_plugin_aspects/__init__.py b/platform_plugin_aspects/__init__.py index 274e5bb..6ae703c 100644 --- a/platform_plugin_aspects/__init__.py +++ b/platform_plugin_aspects/__init__.py @@ -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__))) diff --git a/platform_plugin_aspects/extensions/filters.py b/platform_plugin_aspects/extensions/filters.py index d099d11..b4ab706 100644 --- a/platform_plugin_aspects/extensions/filters.py +++ b/platform_plugin_aspects/extensions/filters.py @@ -30,6 +30,7 @@ def run_filter( """ course = context["course"] dashboards = settings.ASPECTS_INSTRUCTOR_DASHBOARDS + show_dashboard_link = settings.SUPERSET_SHOW_INSTRUCTOR_DASHBOARD_LINK user = get_current_user() @@ -62,6 +63,7 @@ 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, } context["sections"].append(section_data) return { diff --git a/platform_plugin_aspects/extensions/tests/test_filters.py b/platform_plugin_aspects/extensions/tests/test_filters.py index 0954322..21d0c6b 100644 --- a/platform_plugin_aspects/extensions/tests/test_filters.py +++ b/platform_plugin_aspects/extensions/tests/test_filters.py @@ -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") @@ -66,16 +64,13 @@ def test_run_filter_without_language( context = self.filter.run_filter(self.context, self.template_name) - self.assertDictContainsSubset( - { + 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/", - }, - context["context"]["sections"][0], - ) + }.items() <= context["context"]["sections"][0].items() mock_get_model.assert_called_once() diff --git a/platform_plugin_aspects/settings/common.py b/platform_plugin_aspects/settings/common.py index 57ca9a1..7dcdc0a 100644 --- a/platform_plugin_aspects/settings/common.py +++ b/platform_plugin_aspects/settings/common.py @@ -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 = { diff --git a/platform_plugin_aspects/templates/instructor_dashboard/aspects.html b/platform_plugin_aspects/templates/instructor_dashboard/aspects.html index cddeb41..1f94ed8 100644 --- a/platform_plugin_aspects/templates/instructor_dashboard/aspects.html +++ b/platform_plugin_aspects/templates/instructor_dashboard/aspects.html @@ -9,12 +9,13 @@ <%include file="/courseware/xqa_interface.html/"/> <% superset_url = section_data.get("superset_url") +show_superset_link = section_data.get("show_dashboard_link") %>
- % if superset_url: + % if superset_url and show_dashboard_link: % endif ${HTML(section_data['fragment'].body_html())} diff --git a/test_settings.py b/test_settings.py index d13b797..064fcd7 100644 --- a/test_settings.py +++ b/test_settings.py @@ -107,4 +107,5 @@ "timeout_secs": 1, } +SUPERSET_SHOW_INSTRUCTOR_DASHBOARD_LINK = True SUPERSET_DASHBOARD_LOCALES = ["en_US", "es_419"] From be0b0bdedcf7ed6192ed59eeaf9ab41e39879a7e Mon Sep 17 00:00:00 2001 From: Brian Mesick Date: Wed, 15 May 2024 15:06:36 -0400 Subject: [PATCH 2/3] style: Format files --- .../extensions/tests/test_filters.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/platform_plugin_aspects/extensions/tests/test_filters.py b/platform_plugin_aspects/extensions/tests/test_filters.py index 21d0c6b..559f247 100644 --- a/platform_plugin_aspects/extensions/tests/test_filters.py +++ b/platform_plugin_aspects/extensions/tests/test_filters.py @@ -65,12 +65,12 @@ def test_run_filter_without_language( context = self.filter.run_filter(self.context, self.template_name) 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() + "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() From 0c0e2b4e1f79b31948842c8347ed7b8948bf5f4a Mon Sep 17 00:00:00 2001 From: Brian Mesick Date: Thu, 16 May 2024 08:38:35 -0400 Subject: [PATCH 3/3] fix: Errors around displaying Superset link --- platform_plugin_aspects/extensions/filters.py | 13 ++++++++++--- .../templates/instructor_dashboard/aspects.html | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/platform_plugin_aspects/extensions/filters.py b/platform_plugin_aspects/extensions/filters.py index b4ab706..a3215c2 100644 --- a/platform_plugin_aspects/extensions/filters.py +++ b/platform_plugin_aspects/extensions/filters.py @@ -34,9 +34,14 @@ def run_filter( 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 @@ -65,6 +70,8 @@ def run_filter( "template_path_prefix": TEMPLATE_ABSOLUTE_PATH, "show_dashboard_link": show_dashboard_link, } + + print(section_data) context["sections"].append(section_data) return { "context": context, diff --git a/platform_plugin_aspects/templates/instructor_dashboard/aspects.html b/platform_plugin_aspects/templates/instructor_dashboard/aspects.html index 1f94ed8..108b15e 100644 --- a/platform_plugin_aspects/templates/instructor_dashboard/aspects.html +++ b/platform_plugin_aspects/templates/instructor_dashboard/aspects.html @@ -9,11 +9,11 @@ <%include file="/courseware/xqa_interface.html/"/> <% superset_url = section_data.get("superset_url") -show_superset_link = section_data.get("show_dashboard_link") +show_superset_link = superset_url and section_data.get("show_dashboard_link") %>
- % if superset_url and show_dashboard_link: + % if show_superset_link: