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 09a381d  fix(reports): notification without standalone link back to 
superset (#12174)
09a381d is described below

commit 09a381da1d48fb260d815858098b32901d53dd2e
Author: Daniel Vaz Gaspar <[email protected]>
AuthorDate: Wed Dec 23 11:31:08 2020 +0000

    fix(reports): notification without standalone link back to superset (#12174)
    
    * fix(reports): notification without standalone link back to superset
    
    * fix comment
---
 superset/reports/commands/execute.py | 10 ++++++----
 tests/reports/commands_tests.py      |  6 ++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/superset/reports/commands/execute.py 
b/superset/reports/commands/execute.py
index ab3ee58..ddf4f19 100644
--- a/superset/reports/commands/execute.py
+++ b/superset/reports/commands/execute.py
@@ -16,7 +16,7 @@
 # under the License.
 import logging
 from datetime import datetime, timedelta
-from typing import List, Optional
+from typing import Any, List, Optional
 
 from flask_appbuilder.security.sqla.models import User
 from sqlalchemy.orm import Session
@@ -116,7 +116,7 @@ class BaseReportState:
         self._session.add(log)
         self._session.commit()
 
-    def _get_url(self, user_friendly: bool = False) -> str:
+    def _get_url(self, user_friendly: bool = False, **kwargs: Any) -> str:
         """
         Get the url for this report schedule: chart or dashboard
         """
@@ -125,12 +125,13 @@ class BaseReportState:
                 "Superset.slice",
                 user_friendly=user_friendly,
                 slice_id=self._report_schedule.chart_id,
-                standalone="true",
+                **kwargs,
             )
         return get_url_path(
             "Superset.dashboard",
             user_friendly=user_friendly,
             dashboard_id_or_slug=self._report_schedule.dashboard_id,
+            **kwargs,
         )
 
     def _get_screenshot_user(self) -> User:
@@ -148,11 +149,12 @@ class BaseReportState:
         Get a chart or dashboard screenshot
         :raises: ReportScheduleScreenshotFailedError
         """
-        url = self._get_url()
         screenshot: Optional[BaseScreenshot] = None
         if self._report_schedule.chart:
+            url = self._get_url(standalone="true")
             screenshot = ChartScreenshot(url, 
self._report_schedule.chart.digest)
         else:
+            url = self._get_url()
             screenshot = DashboardScreenshot(
                 url, self._report_schedule.dashboard.digest
             )
diff --git a/tests/reports/commands_tests.py b/tests/reports/commands_tests.py
index 3de782d..dac3437 100644
--- a/tests/reports/commands_tests.py
+++ b/tests/reports/commands_tests.py
@@ -455,6 +455,12 @@ def test_email_chart_report_schedule(
         notification_targets = get_target_from_report_schedule(
             create_report_email_chart
         )
+        # assert that the link sent is correct
+        assert (
+            f'<a href="http://0.0.0.0:8080/superset/slice/'
+            f'{create_report_email_chart.chart.id}/">Explore in Superset</a>'
+            in email_mock.call_args[0][2]
+        )
         # Assert the email smtp address
         assert email_mock.call_args[0][0] == notification_targets[0]
         # Assert the email inline screenshot

Reply via email to