fix(Embedded): Deleting Embedded Dashboards does not commit the transaction (#29894)

This commit is contained in:
Geido
2024-08-09 17:29:57 +03:00
committed by GitHub
parent 38d64e8dd2
commit b323bf0fb6
4 changed files with 61 additions and 3 deletions

View File

@@ -23,12 +23,13 @@ from flask_babel import lazy_gettext as _
from superset import security_manager
from superset.commands.base import BaseCommand
from superset.commands.dashboard.exceptions import (
DashboardDeleteEmbeddedFailedError,
DashboardDeleteFailedError,
DashboardDeleteFailedReportsExistError,
DashboardForbiddenError,
DashboardNotFoundError,
)
from superset.daos.dashboard import DashboardDAO
from superset.daos.dashboard import DashboardDAO, EmbeddedDashboardDAO
from superset.daos.report import ReportScheduleDAO
from superset.exceptions import SupersetSecurityException
from superset.models.dashboard import Dashboard
@@ -37,6 +38,19 @@ from superset.utils.decorators import on_error, transaction
logger = logging.getLogger(__name__)
class DeleteEmbeddedDashboardCommand(BaseCommand):
def __init__(self, dashboard: Dashboard):
self._dashboard = dashboard
@transaction(on_error=partial(on_error, reraise=DashboardDeleteEmbeddedFailedError))
def run(self) -> None:
self.validate()
return EmbeddedDashboardDAO.delete(self._dashboard.embedded)
def validate(self) -> None:
pass
class DeleteDashboardCommand(BaseCommand):
def __init__(self, model_ids: list[int]):
self._model_ids = model_ids