Skip to content

Commit

Permalink
update csv named methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cemremengu committed Mar 26, 2021
1 parent e61f5a9 commit d64d701
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def get_foreign_keys(
) -> List[Dict[str, Any]]:
return self.inspector.get_foreign_keys(table_name, schema)

def get_schema_access_for_csv_upload( # pylint: disable=invalid-name
def get_schema_access_for_file_upload( # pylint: disable=invalid-name
self,
) -> List[str]:
allowed_databases = self.get_extra().get("schemas_allowed_for_csv_upload", [])
Expand Down
2 changes: 1 addition & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2936,7 +2936,7 @@ def schemas_access_for_csv_upload(self) -> FlaskResponse:
db_id = int(request.args["db_id"])
database = db.session.query(Database).filter_by(id=db_id).one()
try:
schemas_allowed = database.get_schema_access_for_csv_upload()
schemas_allowed = database.get_schema_access_for_file_upload()
if security_manager.can_access_database(database):
return self.json_response(schemas_allowed)
# the list schemas_allowed should not be empty here
Expand Down
4 changes: 2 additions & 2 deletions superset/views/database/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def at_least_one_schema_is_allowed(database: Database) -> bool:
"""
if security_manager.can_access_database(database):
return True
schemas = database.get_schema_access_for_csv_upload()
schemas = database.get_schema_access_for_file_upload()
if schemas and security_manager.get_schemas_accessible_by_user(
database, schemas, False
):
Expand Down Expand Up @@ -265,7 +265,7 @@ def at_least_one_schema_is_allowed(database: Database) -> bool:
"""
if security_manager.can_access_database(database):
return True
schemas = database.get_schema_access_for_csv_upload()
schemas = database.get_schema_access_for_file_upload()
if schemas and security_manager.schemas_accessible_by_user(
database, schemas, False
):
Expand Down
4 changes: 2 additions & 2 deletions superset/views/database/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def sqlalchemy_uri_validator(
)


def schema_allows_csv_upload(database: Database, schema: Optional[str]) -> bool:
def schema_allows_file_upload(database: Database, schema: Optional[str]) -> bool:
if not database.allow_csv_upload:
return False
schemas = database.get_schema_access_for_csv_upload()
schemas = database.get_schema_access_for_file_upload()
if schemas:
return schema in schemas
return security_manager.can_access_database(database)
6 changes: 3 additions & 3 deletions superset/views/database/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

from .forms import CsvToDatabaseForm, ExcelToDatabaseForm
from .mixins import DatabaseMixin
from .validators import schema_allows_csv_upload, sqlalchemy_uri_validator
from .validators import schema_allows_file_upload, sqlalchemy_uri_validator

if TYPE_CHECKING:
from werkzeug.datastructures import FileStorage # pylint: disable=unused-import
Expand Down Expand Up @@ -128,7 +128,7 @@ def form_post(self, form: CsvToDatabaseForm) -> Response:
database = form.con.data
csv_table = Table(table=form.name.data, schema=form.schema.data)

if not schema_allows_csv_upload(database, csv_table.schema):
if not schema_allows_file_upload(database, csv_table.schema):
message = _(
'Database "%(database_name)s" schema "%(schema_name)s" '
"is not allowed for csv uploads. Please contact your Superset Admin.",
Expand Down Expand Up @@ -285,7 +285,7 @@ def form_post(self, form: ExcelToDatabaseForm) -> Response:
database = form.con.data
excel_table = Table(table=form.name.data, schema=form.schema.data)

if not schema_allows_csv_upload(database, excel_table.schema):
if not schema_allows_file_upload(database, excel_table.schema):
message = _(
'Database "%(database_name)s" schema "%(schema_name)s" '
"is not allowed for excel uploads. Please contact your Superset Admin.",
Expand Down

0 comments on commit d64d701

Please sign in to comment.