Skip to content

Commit

Permalink
fix: flash message on database data upload forms (#21761)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgaspar authored Oct 11, 2022
1 parent db075d4 commit ba3275a
Showing 1 changed file with 11 additions and 11 deletions.
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

0 comments on commit ba3275a

Please sign in to comment.