diff --git a/tutoraspects/patches/openedx-common-settings b/tutoraspects/patches/openedx-common-settings index 1dd1d6d76..4245c981d 100644 --- a/tutoraspects/patches/openedx-common-settings +++ b/tutoraspects/patches/openedx-common-settings @@ -1,8 +1,15 @@ # Configuration needed for openedx-event-sink-clickhouse EVENT_SINK_CLICKHOUSE_BACKEND_CONFIG = { - "url": "{% if CLICKHOUSE_SECURE_CONNECTION %}https{% else %}http{% endif %}://{{ CLICKHOUSE_HOST }}:{{ CLICKHOUSE_INTERNAL_HTTP_PORT }}", - "username": "{{ ASPECTS_CLICKHOUSE_CMS_USER }}", - "password": "{{ ASPECTS_CLICKHOUSE_CMS_PASSWORD }}", - "database": "{{ ASPECTS_EVENT_SINK_DATABASE }}", - "timeout_secs": {{ ASPECTS_EVENT_SINK_CLICKHOUSE_TIMEOUT_SECS }} + "url": "{% if CLICKHOUSE_SECURE_CONNECTION %}https{% else %}http{% endif %}://{{ CLICKHOUSE_HOST }}:{{ CLICKHOUSE_INTERNAL_HTTP_PORT }}", + "username": "{{ ASPECTS_CLICKHOUSE_CMS_USER }}", + "password": "{{ ASPECTS_CLICKHOUSE_CMS_PASSWORD }}", + "database": "{{ ASPECTS_EVENT_SINK_DATABASE }}", + "timeout_secs": {{ ASPECTS_EVENT_SINK_CLICKHOUSE_TIMEOUT_SECS }} +} +SUPERSET_CONFIG = { + "service_url": "http://superset:{{ SUPERSET_PORT }}/", + "host": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ SUPERSET_HOST }}", + "username": "{{ SUPERSET_LMS_USERNAME }}", + "password": "{{ SUPERSET_LMS_PASSWORD }}", + "email": "{{ SUPERSET_LMS_EMAIL }}", } diff --git a/tutoraspects/patches/openedx-development-settings b/tutoraspects/patches/openedx-development-settings new file mode 100644 index 000000000..beefbc5e6 --- /dev/null +++ b/tutoraspects/patches/openedx-development-settings @@ -0,0 +1,7 @@ +SUPERSET_CONFIG = { + "service_url": "http://superset:{{ SUPERSET_PORT }}/", + "host": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ SUPERSET_HOST }}:{{ SUPERSET_PORT }}", + "username": "{{ SUPERSET_LMS_USERNAME }}", + "password": "{{ SUPERSET_LMS_PASSWORD }}", + "email": "{{ SUPERSET_LMS_EMAIL }}", +} diff --git a/tutoraspects/plugin.py b/tutoraspects/plugin.py index cbfa8ec53..efc150129 100644 --- a/tutoraspects/plugin.py +++ b/tutoraspects/plugin.py @@ -255,7 +255,14 @@ "student": "Student", }, ), + ( + "SUPERSET_EMBEDDABLE_DASHBOARDS", + { + "instructor-dashboard": "1d6bf904-f53f-47fd-b1c9-6cd7e284d286", + }, + ), ("SUPERSET_ADMIN_EMAIL", "admin@openedx.org"), + ("SUPERSET_LMS_EMAIL", "superset/lms-admin@aspects.invalid"), ("SUPERSET_OWNERS", []), # Set to 0 to have no row limit. ("SUPERSET_ROW_LIMIT", 100_000), @@ -403,6 +410,8 @@ ("SUPERSET_OAUTH2_CLIENT_SECRET", "{{ 16|random_string }}"), ("SUPERSET_ADMIN_USERNAME", "{{ 12|random_string }}"), ("SUPERSET_ADMIN_PASSWORD", "{{ 24|random_string }}"), + ("SUPERSET_LMS_USERNAME", "{{ 12|random_string }}"), + ("SUPERSET_LMS_PASSWORD", "{{ 24|random_string }}"), ] ) diff --git a/tutoraspects/templates/aspects/apps/superset/pythonpath/create_assets.py b/tutoraspects/templates/aspects/apps/superset/pythonpath/create_assets.py index 25849361f..08f3642f6 100644 --- a/tutoraspects/templates/aspects/apps/superset/pythonpath/create_assets.py +++ b/tutoraspects/templates/aspects/apps/superset/pythonpath/create_assets.py @@ -16,6 +16,7 @@ from superset.extensions import db from superset.models.dashboard import Dashboard from superset.utils.database import get_or_create_db +from superset.models.embedded_dashboard import EmbeddedDashboard BASE_DIR = "/app/assets/superset" @@ -83,6 +84,7 @@ def create_assets(): import_assets() update_dashboard_roles(roles) + update_embeddable_uuids() def get_uuid5(base_uuid, name): @@ -238,6 +240,23 @@ def update_dashboard_roles(roles): 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 = 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/aspects/jobs/init/superset/init-superset.sh b/tutoraspects/templates/aspects/jobs/init/superset/init-superset.sh index 0fa9d53bb..c60221264 100755 --- a/tutoraspects/templates/aspects/jobs/init/superset/init-superset.sh +++ b/tutoraspects/templates/aspects/jobs/init/superset/init-superset.sh @@ -52,6 +52,13 @@ superset fab create-admin \ --lastname Admin \ --email "{{ SUPERSET_ADMIN_EMAIL }}" +superset fab create-admin \ + --username "{{ SUPERSET_LMS_USERNAME }}" \ + --password "{{ SUPERSET_LMS_PASSWORD }}" \ + --firstname LMS \ + --lastname Admin \ + --email "{{ SUPERSET_LMS_EMAIL }}" + # Update the password of the Admin user # (in case it changed since the user was created) superset fab reset-password \