Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(filter-set): Add filterset resource #14015

Merged
merged 73 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
b7865ad
Add filterset resource
Apr 8, 2021
085a9f7
Merge remote-tracking branch 'upstream/master' into feat/fileter_set
Apr 8, 2021
60ab14f
fix: fix pre-commit
Apr 8, 2021
8fddfd0
add tests
Apr 11, 2021
68aa395
add tests and fixes based of failures
Apr 13, 2021
9ca86fb
Fix pre-commit errors
Apr 14, 2021
f292dea
chore init filterset resource under ff constraint
Apr 14, 2021
d7e4b7b
Merge remote-tracking branch 'upstream/master' into feat/fileter_set
Apr 18, 2021
2a782f9
Fix migration conflicts
Apr 18, 2021
8cd164e
Fix pylint and migrations issues
Apr 18, 2021
3ab9609
Fix pylint and migrations issues
Apr 18, 2021
6c2ed5c
Fix pylint and migrations issues
Apr 18, 2021
4c87d47
Fix pylint and migrations issues
Apr 18, 2021
94abd23
Fix pylint and migrations issues
Apr 18, 2021
4037097
Fix pylint and migrations issues
Apr 18, 2021
4b3fd59
Fix pylint and migrations issues
Apr 18, 2021
733a537
Fix pylint and migrations issues
Apr 18, 2021
eac8526
Fix pylint and migrations issues
Apr 18, 2021
89e8bee
Fix pylint and migrations issues
Apr 18, 2021
3a7f080
Fix pylint and migrations issues
Apr 18, 2021
8c367cc
add tests and fixes based of failures
Apr 27, 2021
28d28c8
Merge remote-tracking branch 'upstream/master' into feat/fileter_set
Apr 27, 2021
4aa4314
Fix missing license
Apr 28, 2021
ad27fca
Merge branch 'master' into feat/fileter_set
May 3, 2021
6d2d23e
fix down revision
May 3, 2021
ad54807
Merge branch 'master' into feat/fileter_set
May 25, 2021
ff6ca29
update down_revision
May 25, 2021
2452389
fix: update down_revision
May 25, 2021
2c7d2c4
chore: add description to migration
May 25, 2021
4aff6b1
fix: type
amitmiran137 Jun 6, 2021
145b07d
refactor: is_user_admin
amitmiran137 Jun 6, 2021
73ab92f
fix: use get_public_role
amitmiran137 Jun 6, 2021
af8e35f
fix: move import to the relevant location
Jun 6, 2021
48b84e8
chore: add openSpec api schema
Jun 6, 2021
f7526b8
chore: cover all openspec API
Jun 6, 2021
7ed5321
fix: pre-commit and lint
Jun 6, 2021
dbb0ae0
fix: put and post schemas
Jun 6, 2021
033734d
fix: undo superset_test_config.py
Jun 6, 2021
39f4d70
Merge remote-tracking branch 'upstream/master' into feat/fileter_set
Jun 6, 2021
ebb1405
fix: limit filterSetsApi to include_route_methods = {"get_list", "put…
Jun 7, 2021
16c8a18
renaming some params
Jun 8, 2021
a87172a
Merge remote-tracking branch 'upstream/master' into feat/fileter_set
Jun 8, 2021
94d8478
chore: add debug in test config
Jun 8, 2021
6b4b3d7
fix: rename database to different name
Jun 8, 2021
9078677
fix: try to make conftest.py harmless
Jun 8, 2021
e84dd26
fix: pre-commit
Jun 8, 2021
0465379
Merge branch 'master' into feat/fileter_set
Aug 24, 2021
1c28bf8
fix: new down_revision ref
Aug 24, 2021
a6b6c11
fix: bad ref
Aug 24, 2021
645e371
fix: bad ref 2
Aug 24, 2021
e2cb552
fix: bad ref 3
Aug 24, 2021
adfe513
fix: add api in initiatior
Aug 24, 2021
abef564
fix: open spec
Aug 25, 2021
930863b
Merge remote-tracking branch 'upstream/master' into feat/fileter_set
Aug 26, 2021
ee7c4e5
Merge remote-tracking branch 'upstream/master' into feat/fileter_set
Aug 29, 2021
d500272
fix: convert name to str to include int usecases
Aug 29, 2021
6762eb5
Merge remote-tracking branch 'upstream/master' into feat/fileter_set
Aug 30, 2021
1dfb029
fix: pylint
Aug 30, 2021
07792fa
fix: pylint
Aug 30, 2021
55dbfa4
Update superset/common/request_contexed_based.py
amitmiran137 Sep 7, 2021
a9ea304
Merge branch 'upstream_master' into feat/fileter_set
ofekisr Sep 13, 2021
568b3a5
chore: resolve PR comments
ofekisr Sep 13, 2021
6359817
chore: resolve PR comments
ofekisr Sep 13, 2021
4af6a6a
chore: resolve PR comments
ofekisr Sep 13, 2021
fd6deca
fix failed tests
ofekisr Sep 14, 2021
4b0a9ed
fix pylint
ofekisr Sep 14, 2021
d1a5968
Update conftest.py
ofekisr Sep 19, 2021
e2bf8d7
chore remove BaseCommand to remove abstraction
ofekisr Sep 19, 2021
2d63fe6
chore remove BaseCommand to remove abstraction
ofekisr Sep 19, 2021
2674d9a
chore remove BaseCommand to remove abstraction
ofekisr Sep 19, 2021
414b0c0
chore remove BaseCommand to remove abstraction
ofekisr Sep 19, 2021
9e7f948
Merge branch 'upstream_master' into feat/fileter_set
ofekisr Sep 23, 2021
51e2084
chore fix migration
ofekisr Sep 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion superset/commands/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional

from flask_babel import lazy_gettext as _
from marshmallow import ValidationError
Expand All @@ -31,6 +31,26 @@ def __repr__(self) -> str:
return repr(self)


class ObjectNotFoundError(CommandException):
status = 404
message_format = "{} {}not found."

def __init__(
self,
object_type: str,
object_id: Optional[str] = None,
exception: Optional[Exception] = None,
) -> None:
super().__init__(
_(
self.message_format.format(
object_type, '"%s" ' % object_id if object_id else ""
)
),
ofekisr marked this conversation as resolved.
Show resolved Hide resolved
exception,
)


class CommandInvalidError(CommandException):
""" Common base class for Command Invalid errors. """

Expand Down
6 changes: 3 additions & 3 deletions superset/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from datetime import datetime
from datetime import timezone
from typing import Iterator, List, Tuple
from typing import Iterator, List, Tuple, Type

import yaml
from flask_appbuilder import Model
Expand All @@ -33,8 +33,8 @@

class ExportModelsCommand(BaseCommand):

dao = BaseDAO
not_found = CommandException
dao: Type[BaseDAO] = BaseDAO
not_found: Type[CommandException] = CommandException

def __init__(self, model_ids: List[int]):
self.model_ids = model_ids
Expand Down
39 changes: 39 additions & 0 deletions superset/common/not_authrized_object.py
Original file line number Diff line number Diff line change
@@ -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.
from typing import Any, Optional

from superset.exceptions import SupersetException


class NotAuthorizedObject:
def __init__(self, what_not_authorized: str):
self._what_not_authorized = what_not_authorized

def __getattr__(self, item: Any) -> None:
raise NotAuthorizedException(self._what_not_authorized)

def __getitem__(self, item: Any) -> None:
raise NotAuthorizedException(self._what_not_authorized)


class NotAuthorizedException(SupersetException):
def __init__(
self, what_not_authorized: str = "", exception: Optional[Exception] = None
) -> None:
super().__init__(
"The user is not authorized to " + what_not_authorized, exception
)
39 changes: 39 additions & 0 deletions superset/common/request_contexed_based.py
Original file line number Diff line number Diff line change
@@ -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.
from __future__ import annotations

from typing import List, TYPE_CHECKING

from flask import g

from superset import conf, security_manager

if TYPE_CHECKING:
from flask_appbuilder.security.sqla.models import Role


def get_user_roles() -> List[Role]:
if g.user.is_anonymous:
public_role = conf.get("AUTH_ROLE_PUBLIC")
return [security_manager.get_public_role()] if public_role else []
return g.user.roles


def is_user_admin() -> bool:
user_roles = [role.name.lower() for role in get_user_roles()]
admin_role = conf.get("AUTH_ROLE_ADMIN").lower()
return admin_role in user_roles
11 changes: 8 additions & 3 deletions superset/dashboards/commands/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from typing import Optional

from flask_babel import lazy_gettext as _
from marshmallow.validate import ValidationError

from superset.commands.exceptions import (
CommandException,
CommandInvalidError,
CreateFailedError,
DeleteFailedError,
ForbiddenError,
ImportFailedError,
ObjectNotFoundError,
UpdateFailedError,
)

Expand All @@ -41,8 +43,11 @@ class DashboardInvalidError(CommandInvalidError):
message = _("Dashboard parameters are invalid.")


class DashboardNotFoundError(CommandException):
message = _("Dashboard not found.")
class DashboardNotFoundError(ObjectNotFoundError):
def __init__(
self, dashboard_id: Optional[str] = None, exception: Optional[Exception] = None
) -> None:
super().__init__("Dashboard", dashboard_id, exception)


class DashboardCreateFailedError(CreateFailedError):
Expand Down
16 changes: 16 additions & 0 deletions superset/dashboards/filter_sets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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.
Loading