diff --git a/tutoraspects/patches/openedx-common-settings b/tutoraspects/patches/openedx-common-settings index 8ddd86bca..4156f85b5 100644 --- a/tutoraspects/patches/openedx-common-settings +++ b/tutoraspects/patches/openedx-common-settings @@ -6,10 +6,3 @@ EVENT_SINK_CLICKHOUSE_BACKEND_CONFIG = { "database": "{{ ASPECTS_EVENT_SINK_DATABASE }}", "timeout_secs": {{ ASPECTS_EVENT_SINK_CLICKHOUSE_TIMEOUT_SECS }} } -SUPERSET_DASHBOARDS = { - {% for dashboard, body in SUPERSET_DASHBOARDS.items() %}"{{ dashboard }}": { - "uuid": "{{ body.uuid }}", - "slug": "{{ body.slug }}", - "title": "{{ body.title }}", - },{% endfor %} -} diff --git a/tutoraspects/plugin.py b/tutoraspects/plugin.py index a4a0a54e4..6acd47011 100644 --- a/tutoraspects/plugin.py +++ b/tutoraspects/plugin.py @@ -256,18 +256,9 @@ }, ), ( - "SUPERSET_DASHBOARDS", + "SUPERSET_EMBEDDABLE_DASHBOARDS", { - "instructor_dashboard": { - "uuid": "1d6bf904-f53f-47fd-b1c9-6cd7e284d286", - "title": "Instructor Dashboard", - "slug": "instructor-dashboard", - }, - "operator_dashboard": { - "uuid": "02c0121c-40e9-4d8a-b86a-6b996a1cc6fe", - "title": "Operator Dashboard", - "slug": "operator-dashboard", - }, + "instructor-dashboard": "1d6bf904-f53f-47fd-b1c9-6cd7e284d286", }, ), ("SUPERSET_ADMIN_EMAIL", "admin@openedx.org"), diff --git a/tutoraspects/templates/aspects/apps/superset/pythonpath/create_assets.py b/tutoraspects/templates/aspects/apps/superset/pythonpath/create_assets.py index f3faea007..08f3642f6 100644 --- a/tutoraspects/templates/aspects/apps/superset/pythonpath/create_assets.py +++ b/tutoraspects/templates/aspects/apps/superset/pythonpath/create_assets.py @@ -84,6 +84,7 @@ def create_assets(): import_assets() update_dashboard_roles(roles) + update_embeddable_uuids() def get_uuid5(base_uuid, name): @@ -238,16 +239,24 @@ def update_dashboard_roles(roles): dashboard.owners = owners db.session.commit() + +def update_embeddable_uuids(): + """Update the uuids of the embeddable dashboards""" + for dashboard_slug, embeddable_uuid in {{SUPERSET_EMBEDDABLE_DASHBOARDS}}.items(): + dashboard = db.session.query(Dashboard).filter_by(slug=dashboard_slug).first() + if dashboard is None: + print(f"WARNING: Dashboard {dashboard_slug} not found") + continue + embedded_dashboard = db.session.query(EmbeddedDashboard).filter_by(dashboard_id=dashboard.id).first() if embedded_dashboard is None: embedded_dashboard = EmbeddedDashboard() embedded_dashboard.dashboard_id = dashboard.id - embedded_dashboard.uuid = dashboard_uuid + embedded_dashboard.uuid = embeddable_uuid db.session.add(embedded_dashboard) db.session.commit() - def get_translation(text, language): """Get a translation for a text in a language""" default_text = f"{text} - {language}" diff --git a/tutoraspects/templates/openedx-assets/assets/dashboards/Instructor_Dashboard.yaml b/tutoraspects/templates/openedx-assets/assets/dashboards/Instructor_Dashboard.yaml index 781fd515a..8c9b25f31 100644 --- a/tutoraspects/templates/openedx-assets/assets/dashboards/Instructor_Dashboard.yaml +++ b/tutoraspects/templates/openedx-assets/assets/dashboards/Instructor_Dashboard.yaml @@ -2,7 +2,7 @@ _file_name: Instructor_Dashboard.yaml _roles: - {{ SUPERSET_ROLES_MAPPING.instructor }} css: '' -dashboard_title: {{ SUPERSET_DASHBOARDS.instructor_dashboard.title }} +dashboard_title: Instructor Dashboard description: null metadata: chart_configuration: @@ -908,6 +908,6 @@ position: parents: - ROOT_ID type: TABS -slug: {{ SUPERSET_DASHBOARDS.instructor_dashboard.slug }} -uuid: {{ SUPERSET_DASHBOARDS.instructor_dashboard.uuid }} +slug: instructor-dashboard +uuid: 1d6bf904-f53f-47fd-b1c9-6cd7e284d286 version: 1.0.0 diff --git a/tutoraspects/templates/openedx-assets/assets/dashboards/Operator_Dashboard.yaml b/tutoraspects/templates/openedx-assets/assets/dashboards/Operator_Dashboard.yaml index f49ab3d09..d068a62b0 100644 --- a/tutoraspects/templates/openedx-assets/assets/dashboards/Operator_Dashboard.yaml +++ b/tutoraspects/templates/openedx-assets/assets/dashboards/Operator_Dashboard.yaml @@ -2,7 +2,7 @@ _file_name: Operator_Dashboard.yaml _roles: - {{ SUPERSET_ROLES_MAPPING.operator }} css: '' -dashboard_title: {{ SUPERSET_DASHBOARDS.operator_dashboard.title }} +dashboard_title: Operator Dashboard description: null metadata: chart_configuration: @@ -728,6 +728,6 @@ position: - ROOT_ID - GRID_ID type: TABS -slug: {{ SUPERSET_DASHBOARDS.operator_dashboard.slug }} -uuid: {{ SUPERSET_DASHBOARDS.operator_dashboard.uuid }} +slug: operator-dashboard +uuid: 02c0121c-40e9-4d8a-b86a-6b996a1cc6fe version: 1.0.0