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

fix: flash message on database data upload forms #21761

Merged
merged 2 commits into from
Oct 11, 2022
Merged
Changes from all commits
Commits
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: 11 additions & 11 deletions superset/views/database/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from flask_appbuilder import expose, SimpleFormView
from flask_appbuilder.models.sqla.interface import SQLAInterface
from flask_appbuilder.security.decorators import has_access
from flask_babel import lazy_gettext as _
from flask_babel import gettext as __, lazy_gettext as _
from werkzeug.wrappers import Response
from wtforms.fields import StringField
from wtforms.validators import ValidationError
Expand Down Expand Up @@ -130,7 +130,7 @@ def form_post(self, form: CsvToDatabaseForm) -> Response:
csv_table = Table(table=form.name.data, schema=form.schema.data)

if not schema_allows_file_upload(database, csv_table.schema):
message = _(
message = __(
'Database "%(database_name)s" schema "%(schema_name)s" '
"is not allowed for csv uploads. Please contact your Superset Admin.",
database_name=database.database_name,
Expand Down Expand Up @@ -216,7 +216,7 @@ def form_post(self, form: CsvToDatabaseForm) -> Response:
db.session.commit()
except Exception as ex: # pylint: disable=broad-except
db.session.rollback()
message = _(
message = __(
'Unable to upload CSV file "%(filename)s" to table '
'"%(table_name)s" in database "%(db_name)s". '
"Error message: %(error_msg)s",
Expand All @@ -231,7 +231,7 @@ def form_post(self, form: CsvToDatabaseForm) -> Response:
return redirect("/csvtodatabaseview/form")

# Go back to welcome page / splash screen
message = _(
message = __(
'CSV file "%(csv_filename)s" uploaded to table "%(table_name)s" in '
'database "%(db_name)s"',
csv_filename=form.csv_file.data.filename,
Expand Down Expand Up @@ -266,7 +266,7 @@ def form_post(self, form: ExcelToDatabaseForm) -> Response:
excel_table = Table(table=form.name.data, schema=form.schema.data)

if not schema_allows_file_upload(database, excel_table.schema):
message = _(
message = __(
'Database "%(database_name)s" schema "%(schema_name)s" '
"is not allowed for excel uploads. Please contact your Superset Admin.",
database_name=database.database_name,
Expand Down Expand Up @@ -353,7 +353,7 @@ def form_post(self, form: ExcelToDatabaseForm) -> Response:
db.session.commit()
except Exception as ex: # pylint: disable=broad-except
db.session.rollback()
message = _(
message = __(
'Unable to upload Excel file "%(filename)s" to table '
'"%(table_name)s" in database "%(db_name)s". '
"Error message: %(error_msg)s",
Expand All @@ -368,7 +368,7 @@ def form_post(self, form: ExcelToDatabaseForm) -> Response:
return redirect("/exceltodatabaseview/form")

# Go back to welcome page / splash screen
message = _(
message = __(
'Excel file "%(excel_filename)s" uploaded to table "%(table_name)s" in '
'database "%(db_name)s"',
excel_filename=form.excel_file.data.filename,
Expand Down Expand Up @@ -413,7 +413,7 @@ def form_post( # pylint: disable=too-many-locals
]

if len(file_type) > 1:
message = _(
message = __(
"Multiple file extensions are not allowed for columnar uploads."
" Please make sure all files are of the same extension.",
)
Expand All @@ -426,7 +426,7 @@ def form_post( # pylint: disable=too-many-locals
}

if not schema_allows_file_upload(database, columnar_table.schema):
message = _(
message = __(
'Database "%(database_name)s" schema "%(schema_name)s" '
"is not allowed for columnar uploads. "
"Please contact your Superset Admin.",
Expand Down Expand Up @@ -494,7 +494,7 @@ def form_post( # pylint: disable=too-many-locals
db.session.commit()
except Exception as ex: # pylint: disable=broad-except
db.session.rollback()
message = _(
message = __(
'Unable to upload Columnar file "%(filename)s" to table '
'"%(table_name)s" in database "%(db_name)s". '
"Error message: %(error_msg)s",
Expand All @@ -509,7 +509,7 @@ def form_post( # pylint: disable=too-many-locals
return redirect("/columnartodatabaseview/form")

# Go back to welcome page / splash screen
message = _(
message = __(
'Columnar file "%(columnar_filename)s" uploaded to table "%(table_name)s" '
'in database "%(db_name)s"',
columnar_filename=[file.filename for file in form.columnar_file.data],
Expand Down