You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by dp...@apache.org on 2020/07/09 10:43:03 UTC

[incubator-superset] branch master updated: fix: dashboard endpoint sig changed (#10220)

This is an automated email from the ASF dual-hosted git repository.

dpgaspar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 6224edd  fix: dashboard endpoint sig changed (#10220)
6224edd is described below

commit 6224edd42d5a99ccc7922985fa44bd8c6c43c2db
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Thu Jul 9 11:42:38 2020 +0100

    fix: dashboard endpoint sig changed (#10220)
    
    * fix(thumbnails): dashboard endpoint sig changed
    
    * fix, flask get url for Superset.dashboard
    
    * add simple test
---
 superset/cli.py              | 2 +-
 superset/dashboards/api.py   | 4 +++-
 superset/models/dashboard.py | 2 +-
 tests/dashboard_tests.py     | 7 ++++---
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/superset/cli.py b/superset/cli.py
index 774addb..3122b94 100755
--- a/superset/cli.py
+++ b/superset/cli.py
@@ -530,7 +530,7 @@ def compute_thumbnails(
                     "Superset.slice", slice_id=model.id, standalone="true"
                 )
             else:
-                url = get_url_path("Superset.dashboard", dashboard_id=model.id)
+                url = get_url_path("Superset.dashboard", dashboard_id_or_slug=model.id)
             func(url, model.digest, force=force)
 
     if not charts_only:
diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py
index 29572cc..2e94e28 100644
--- a/superset/dashboards/api.py
+++ b/superset/dashboards/api.py
@@ -510,7 +510,9 @@ class DashboardRestApi(BaseSupersetModelRestApi):
         if not dashboard:
             return self.response_404()
 
-        dashboard_url = get_url_path("Superset.dashboard", dashboard_id=dashboard.id)
+        dashboard_url = get_url_path(
+            "Superset.dashboard", dashboard_id_or_slug=dashboard.id
+        )
         # If force, request a screenshot from the workers
         if kwargs["rison"].get("force", False):
             cache_dashboard_thumbnail.delay(dashboard_url, dashboard.digest, force=True)
diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py
index fa8c450..1844543 100644
--- a/superset/models/dashboard.py
+++ b/superset/models/dashboard.py
@@ -481,7 +481,7 @@ class Dashboard(  # pylint: disable=too-many-instance-attributes
 def event_after_dashboard_changed(  # pylint: disable=unused-argument
     mapper: Mapper, connection: Connection, target: Dashboard
 ) -> None:
-    url = get_url_path("Superset.dashboard", dashboard_id=target.id)
+    url = get_url_path("Superset.dashboard", dashboard_id_or_slug=target.id)
     cache_dashboard_thumbnail.delay(url, target.digest, force=True)
 
 
diff --git a/tests/dashboard_tests.py b/tests/dashboard_tests.py
index 50db6d0..f05c980 100644
--- a/tests/dashboard_tests.py
+++ b/tests/dashboard_tests.py
@@ -20,9 +20,8 @@ import json
 import unittest
 from random import random
 
-from flask import escape
+from flask import escape, url_for
 from sqlalchemy import func
-from typing import Dict
 
 import tests.test_app
 from superset import db, security_manager
@@ -30,7 +29,6 @@ from superset.connectors.sqla.models import SqlaTable
 from superset.models import core as models
 from superset.models.dashboard import Dashboard
 from superset.models.slice import Slice
-from superset.views import core as views
 
 from .base_tests import SupersetTestCase
 
@@ -57,6 +55,9 @@ class TestDashboard(SupersetTestCase):
         for title, url in urls.items():
             assert escape(title) in self.client.get(url).data.decode("utf-8")
 
+    def test_superset_dashboard_url(self):
+        url_for("Superset.dashboard", dashboard_id_or_slug=1)
+
     def test_new_dashboard(self):
         self.login(username="admin")
         dash_count_before = db.session.query(func.count(Dashboard.id)).first()[0]