From fd61aebfb4c74475ea804c2eb05bb407b19b006a Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Tue, 20 Feb 2024 17:31:45 -0500 Subject: [PATCH] fix: use settings object directly --- aspects/extensions/filters.py | 20 +++++++------------- aspects/utils.py | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/aspects/extensions/filters.py b/aspects/extensions/filters.py index fe7b129..506023e 100644 --- a/aspects/extensions/filters.py +++ b/aspects/extensions/filters.py @@ -13,6 +13,11 @@ TEMPLATE_ABSOLUTE_PATH = "/instructor_dashboard/" BLOCK_CATEGORY = "aspects" +ASPECTS_SECURITY_FILTERS_FORMAT = [ + "org = '{course.org}'", + "course_name = '{course.display_name}'", + "course_run = '{course.id.run}'", +] class AddSupersetTab(PipelineStep): """Add superset tab to instructor dashboard.""" @@ -26,21 +31,10 @@ def run_filter( _ (str): instructor dashboard template name. """ course = context["course"] - - if not hasattr(settings, "ASPECTS_INSTRUCTOR_DASHBOARD_UUID"): - return { - "context": context, - } - dashboard_uuid = settings.ASPECTS_INSTRUCTOR_DASHBOARD_UUID + extra_filters_format = settings.SUPERSET_EXTRA_FILTERS_FORMAT - extra_filters_format = getattr(settings, "SUPERSET_EXTRA_FILTERS_FORMAT", []) - default_filters = [ - "org = '{course.org}'", - "course_name = '{course.display_name}'", - "course_run = '{course.id.run}'", - ] - filters = default_filters + extra_filters_format + filters = ASPECTS_SECURITY_FILTERS_FORMAT + extra_filters_format context = generate_superset_context( context, dashboard_uuid, filters diff --git a/aspects/utils.py b/aspects/utils.py index f502283..d3608ca 100644 --- a/aspects/utils.py +++ b/aspects/utils.py @@ -70,7 +70,7 @@ def generate_guest_token(user, course, dashboard_uuid, filters): tuple: Superset guest token and dashboard id. or None, exception if Superset is missconfigured or cannot generate guest token. """ - superset_config = getattr(settings, "SUPERSET_CONFIG", {}) + superset_config = settings.SUPERSET_CONFIG superset_internal_host = superset_config.get("service_url") superset_username = superset_config.get("username")