Skip to content

Commit

Permalink
Merge pull request #463 from openedx/cag/embedded_uuids
Browse files Browse the repository at this point in the history
feat: create embeddable UUID
  • Loading branch information
Ian2012 authored Oct 13, 2023
2 parents fe6aba2 + e8c80cf commit c6b95df
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tutoraspects/patches/openedx-common-settings
Original file line number Diff line number Diff line change
@@ -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 }}",
}
7 changes: 7 additions & 0 deletions tutoraspects/patches/openedx-development-settings
Original file line number Diff line number Diff line change
@@ -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 }}",
}
9 changes: 9 additions & 0 deletions tutoraspects/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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 }}"),
]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -83,6 +84,7 @@ def create_assets():

import_assets()
update_dashboard_roles(roles)
update_embeddable_uuids()


def get_uuid5(base_uuid, name):
Expand Down Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit c6b95df

Please sign in to comment.