From 0c0e2b4e1f79b31948842c8347ed7b8948bf5f4a Mon Sep 17 00:00:00 2001 From: Brian Mesick Date: Thu, 16 May 2024 08:38:35 -0400 Subject: [PATCH] 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: