mikebridge commented on code in PR #40129:
URL: https://github.com/apache/superset/pull/40129#discussion_r3510305990


##########
superset/charts/filters.py:
##########
@@ -196,3 +197,40 @@ def apply(self, query: Query, value: Any) -> Query:
                 FavStar.user_id == get_user_id(),
             )
         )
+
+
+class ChartDeletedStateFilter(  # pylint: disable=too-few-public-methods
+    BaseDeletedStateFilter
+):
+    """Rison filter for the GET list that exposes soft-deleted charts.
+
+    Soft-deleted rows are additionally scoped to the **restore audience**: only
+    the chart's owners (or admins) may enumerate them. This mirrors
+    ``RestoreChartCommand``'s ``raise_for_ownership`` check, so a read-access
+    non-owner (who can see the chart via datasource access) cannot list
+    soft-deleted charts they could never restore. Live rows are unaffected —
+    they keep their normal ``ChartFilter`` visibility. The ownership scoping is
+    part of the cross-entity deleted-state contract: only the restore audience
+    may enumerate soft-deleted rows (kept consistent with the deleted-state
+    filters in the dashboard and dataset soft-delete rollouts).
+    """
+
+    arg_name = "chart_deleted_state"
+    model = Slice
+
+    def apply(self, query: Query, value: Any) -> Query:

Review Comment:
   Considered — the class-level docstring documents the filtering and 
ownership-scoping behavior in detail; a method-level restatement would 
duplicate it. Declining as style.



##########
superset/translations/ru/LC_MESSAGES/messages.po:
##########
@@ -3060,6 +3060,9 @@ msgstr "Изменения диаграммы"
 msgid "Chart could not be created."
 msgstr "Не удалось создать диаграмму"
 
+msgid "Chart could not be restored."
+msgstr ""

Review Comment:
   An empty `msgstr` is expected for newly-extracted strings — catalogs carry 
new ids untranslated until translators fill them in; untranslated strings fall 
back to source text. Declining.



##########
superset/translations/it/LC_MESSAGES/messages.po:
##########
@@ -2999,6 +2999,9 @@ msgstr "Ultima Modifica"
 msgid "Chart could not be created."
 msgstr "La tua query non può essere salvata"
 
+msgid "Chart could not be restored."
+msgstr ""

Review Comment:
   An empty `msgstr` is expected for newly-extracted strings — catalogs carry 
new ids untranslated until translators fill them in; untranslated strings fall 
back to source text. Declining.



##########
superset/translations/fa/LC_MESSAGES/messages.po:
##########
@@ -3065,6 +3065,9 @@ msgstr "تغییرات نمودار"
 msgid "Chart could not be created."
 msgstr "نمودار نتوانسته ایجاد شود."
 
+msgid "Chart could not be restored."
+msgstr ""

Review Comment:
   An empty `msgstr` is expected for newly-extracted strings — catalogs carry 
new ids untranslated until translators fill them in; untranslated strings fall 
back to source text. Declining.



##########
superset/translations/nl/LC_MESSAGES/messages.po:
##########
@@ -3118,6 +3118,9 @@ msgstr "Veranderingen in de grafiek"
 msgid "Chart could not be created."
 msgstr "Grafiek kon niet worden aangemaakt."
 
+msgid "Chart could not be restored."
+msgstr ""

Review Comment:
   An empty `msgstr` is expected for newly-extracted strings — catalogs carry 
new ids untranslated until translators fill them in; untranslated strings fall 
back to source text. Declining.



##########
superset/translations/pt/LC_MESSAGES/messages.po:
##########
@@ -3045,6 +3045,9 @@ msgstr "Modificado pela última vez"
 msgid "Chart could not be created."
 msgstr "Não foi possível gravar a sua query"
 
+msgid "Chart could not be restored."
+msgstr ""

Review Comment:
   An empty `msgstr` is expected for newly-extracted strings — catalogs carry 
new ids untranslated until translators fill them in; untranslated strings fall 
back to source text. Declining.



##########
superset/commands/chart/restore.py:
##########
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Command to restore a soft-deleted chart."""
+
+from superset.commands.chart.exceptions import (
+    ChartForbiddenError,
+    ChartNotFoundError,
+    ChartRestoreFailedError,
+)
+from superset.commands.restore import BaseRestoreCommand
+from superset.daos.chart import ChartDAO
+from superset.models.slice import Slice
+
+
+class RestoreChartCommand(BaseRestoreCommand[Slice]):
+    """Restore a soft-deleted chart by clearing its ``deleted_at`` field.
+
+    All transactional wrapping and validation lives in
+    ``BaseRestoreCommand``; this subclass is purely declarative.
+    """
+
+    dao = ChartDAO
+    not_found_exc = ChartNotFoundError
+    forbidden_exc = ChartForbiddenError
+    restore_failed_exc = ChartRestoreFailedError

Review Comment:
   Following the surrounding file's conventions — local/test-scaffolding 
variables whose types are unambiguous from context. Declining as style.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to