You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/09/09 15:09:33 UTC

[GitHub] [superset] ofekisr commented on a change in pull request #14015: feat(filter-set): Add filterset resource

ofekisr commented on a change in pull request #14015:
URL: https://github.com/apache/superset/pull/14015#discussion_r705439941



##########
File path: superset/dashboards/filter_sets/commands/base.py
##########
@@ -0,0 +1,95 @@
+# 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.
+import logging
+from typing import cast, Optional
+
+from flask_appbuilder.models.sqla import Model
+from flask_appbuilder.security.sqla.models import User
+
+from superset.commands.base import BaseCommand
+from superset.common.not_authrized_object import NotAuthorizedException
+from superset.common.request_contexed_based import is_user_admin
+from superset.dashboards.commands.exceptions import DashboardNotFoundError
+from superset.dashboards.dao import DashboardDAO
+from superset.dashboards.filter_sets.commands.exceptions import (
+    FilterSetForbiddenError,
+    FilterSetNotFoundError,
+)
+from superset.dashboards.filter_sets.consts import USER_OWNER_TYPE
+from superset.models.dashboard import Dashboard
+from superset.models.filter_set import FilterSet
+
+logger = logging.getLogger(__name__)
+
+
+class BaseFilterSetCommand(BaseCommand):
+    # pylint: disable=C0103
+    _dashboard: Dashboard
+    _filter_set_id: Optional[int]
+    _filter_set: Optional[FilterSet]
+
+    def __init__(self, user: User, dashboard_id: int):
+        self._actor = user
+        self._is_actor_admin = is_user_admin()
+        self._dashboard_id = dashboard_id
+
+    def run(self) -> Model:
+        pass
+
+    def validate(self) -> None:
+        self._validate_filterset_dashboard_exists()
+
+    def _validate_filterset_dashboard_exists(self) -> None:
+        self._dashboard = DashboardDAO.get_by_id_or_slug(str(self._dashboard_id))
+        if not self._dashboard:
+            raise DashboardNotFoundError()

Review comment:
       validate is coming from the base... and could be consists several of validators 
   if you see only "validate" you can understand what is validate that is why, but you can understand what is "validate filterset dashboard exists 




-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org