Skip to content

Commit

Permalink
Merge pull request #697 from openedx/cag/dashboard-translate
Browse files Browse the repository at this point in the history
fix: allow to embed translated dashboards
  • Loading branch information
Cristhian Garcia authored Apr 9, 2024
2 parents 15cb2e2 + 2dfa72d commit 5f276cb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
1 change: 1 addition & 0 deletions tutoraspects/patches/openedx-common-settings
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ EVENT_SINK_CLICKHOUSE_PII_MODELS = {{ EVENT_SINK_PII_MODELS }}

ASPECTS_INSTRUCTOR_DASHBOARDS = {{ ASPECTS_INSTRUCTOR_DASHBOARDS }}
SUPERSET_EXTRA_FILTERS_FORMAT = {{ ASPECTS_SUPERSET_EXTRA_FILTERS_FORMAT }}
SUPERSET_DASHBOARD_LOCALES = {{ SUPERSET_DASHBOARD_LOCALES }}
{% if ASPECTS_ENABLE_INSTRUCTOR_DASHBOARD_PLUGIN %}
try:
not OPEN_EDX_FILTERS_CONFIG
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "platform-plugin-aspects==v0.5.0"
pip install "platform-plugin-aspects==v0.6.0"
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "edx-event-routing-backends==v9.0.0"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "platform-plugin-aspects==v0.5.0"
pip install "platform-plugin-aspects==v0.6.0"
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "edx-event-routing-backends==v9.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
}

DASHBOARD_LOCALES = {{SUPERSET_DASHBOARD_LOCALES}}
EMBEDDABLE_DASHBOARDS = {{SUPERSET_EMBEDDABLE_DASHBOARDS}}

for folder in ASSET_FOLDER_MAPPING.values():
os.makedirs(f"{BASE_DIR}/{folder}", exist_ok=True)
Expand Down Expand Up @@ -267,21 +268,32 @@ def update_dashboard_roles(roles):

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()

for dashboard_slug, embeddable_uuid in EMBEDDABLE_DASHBOARDS.items():
create_embeddable_dashboard_by_slug(dashboard_slug, embeddable_uuid)

for locale in DASHBOARD_LOCALES:
for dashboard_slug, embeddable_uuid in EMBEDDABLE_DASHBOARDS.items():
slug = f"{dashboard_slug}-{locale}"
current_uuid = get_uuid5(embeddable_uuid, locale)
create_embeddable_dashboard_by_slug(slug, current_uuid)


def create_embeddable_dashboard_by_slug(dashboard_slug, embeddable_uuid):
"""Create an embeddable dashboard by slug"""
print(f"Creating embeddable dashboard {dashboard_slug}, {embeddable_uuid}")
dashboard = db.session.query(Dashboard).filter_by(slug=dashboard_slug).first()
if dashboard is None:
print(f"WARNING: Dashboard {dashboard_slug} not found")
return

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 update_datasets():
"""Update the datasets"""
Expand Down

0 comments on commit 5f276cb

Please sign in to comment.