Skip to content

Commit

Permalink
fix: use settings object directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Feb 20, 2024
1 parent ba4be6b commit fd61aeb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 7 additions & 13 deletions aspects/extensions/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion aspects/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit fd61aeb

Please sign in to comment.