Skip to content

Commit

Permalink
chore: Refactor ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley committed Oct 26, 2022
1 parent 9a063ab commit 4d546c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions superset/datasets/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from zipfile import is_zipfile, ZipFile

import yaml
from flask import g, request, Response, send_file
from flask import request, Response, send_file
from flask_appbuilder.api import expose, protect, rison, safe
from flask_appbuilder.models.sqla.interface import SQLAInterface
from flask_babel import ngettext
Expand Down Expand Up @@ -585,7 +585,7 @@ def duplicate(self) -> Response:
return self.response_400(message=error.messages)

try:
new_model = DuplicateDatasetCommand([g.user.id], item).run()
new_model = DuplicateDatasetCommand(item).run()
return self.response(201, id=new_model.id, result=item)
except DatasetInvalidError as ex:
return self.response_422(
Expand Down
6 changes: 2 additions & 4 deletions superset/datasets/commands/duplicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from typing import Any, Dict, List

from flask_appbuilder.models.sqla import Model
from flask_appbuilder.security.sqla.models import User
from flask_babel import gettext as __
from marshmallow import ValidationError
from sqlalchemy.exc import SQLAlchemyError
Expand All @@ -44,8 +43,7 @@


class DuplicateDatasetCommand(CreateMixin, BaseCommand):
def __init__(self, user: User, data: Dict[str, Any]):
self._actor = user
def __init__(self, data: Dict[str, Any]) -> None:
self._base_model: SqlaTable = SqlaTable()
self._properties = data.copy()

Expand Down Expand Up @@ -122,7 +120,7 @@ def validate(self) -> None:
exceptions.append(DatasetExistsValidationError(table_name=duplicate_name))

try:
owners = self.populate_owners(self._actor)
owners = self.populate_owners()
self._properties["owners"] = owners
except ValidationError as ex:
exceptions.append(ex)
Expand Down

0 comments on commit 4d546c7

Please sign in to comment.