mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +00:00
fix(API): Updating assets via the API should preserve ownership configuration (#27364)
This commit is contained in:
@@ -35,7 +35,7 @@ if TYPE_CHECKING:
|
||||
from superset.connectors.sqla.models import BaseDatasource
|
||||
|
||||
|
||||
def populate_owners(
|
||||
def populate_owner_list(
|
||||
owner_ids: list[int] | None,
|
||||
default_to_user: bool,
|
||||
) -> list[User]:
|
||||
@@ -62,6 +62,25 @@ def populate_owners(
|
||||
return owners
|
||||
|
||||
|
||||
def compute_owner_list(
|
||||
current_owners: list[User] | None,
|
||||
new_owners: list[int] | None,
|
||||
) -> list[User]:
|
||||
"""
|
||||
Helper function for update commands, to properly handle the owners list.
|
||||
Preserve the previous configuration unless included in the update payload.
|
||||
|
||||
:param current_owners: list of current owners
|
||||
:param new_owners: list of new owners specified in the update payload
|
||||
:returns: Final list of owners
|
||||
"""
|
||||
current_owners = current_owners or []
|
||||
owners_ids = (
|
||||
[owner.id for owner in current_owners] if new_owners is None else new_owners
|
||||
)
|
||||
return populate_owner_list(owners_ids, default_to_user=False)
|
||||
|
||||
|
||||
def populate_roles(role_ids: list[int] | None = None) -> list[Role]:
|
||||
"""
|
||||
Helper function for commands, will fetch all roles from roles id's
|
||||
|
||||
Reference in New Issue
Block a user