Upgrade flask-appbuilder to latest. (#6030)

* Upgrade flask-appbuilder to latest.

* Skip constraint deletes if not exist.

* Document breaking change in flask-login.
This commit is contained in:
Joshua Carp 2018-10-08 12:40:52 -04:00 committed by Maxime Beauchemin
parent 6282edd033
commit 9dcf8e101a
9 changed files with 21 additions and 24 deletions

View File

@ -16,6 +16,11 @@ assists people when migrating to a new version.
* Superset 0.28 deprecates the `median` cluster label aggregator for mapbox visualizations. This particular aggregation is not supported on mapbox visualizations going forward.
* Superset 0.28 upgrades `flask-login` to `>=0.3`, which includes a
backwards-incompatible change: `g.user.is_authenticated`,
`g.user.is_anonymous`, and `g.user.is_active` are now properties
instead of properties.
## Superset 0.27.0
* Superset 0.27 start to use nested layout for dashboard builder, which is not
backward-compatible with earlier dashboard grid data. We provide migration script

View File

@ -6,7 +6,7 @@ click==6.7
colorama==0.3.9
cryptography==1.9
flask==0.12.2
flask-appbuilder==1.10.0
flask-appbuilder==1.12.0
flask-caching==1.4.0
flask-compress==1.4.0
flask-migrate==2.1.1

View File

@ -67,7 +67,7 @@ setup(
'contextlib2',
'cryptography',
'flask<1.0.0',
'flask-appbuilder==1.10.0', # known db migration with 1.11+
'flask-appbuilder>=1.12.0',
'flask-caching',
'flask-compress',
'flask-migrate',

View File

@ -33,10 +33,11 @@ def find_constraint_name(upgrade=True):
def upgrade():
try:
constraint = find_constraint_name() or 'fk_columns_column_name_datasources'
constraint = find_constraint_name()
with op.batch_alter_table("columns",
naming_convention=naming_convention) as batch_op:
batch_op.drop_constraint(constraint, type_="foreignkey")
if constraint:
batch_op.drop_constraint(constraint, type_="foreignkey")
batch_op.create_foreign_key(
'fk_columns_datasource_name_datasources',
'datasources',

View File

@ -27,14 +27,16 @@ def upgrade():
try:
slices_ibfk_1 = generic_find_constraint_name(
table='slices', columns={'druid_datasource_id'},
referenced='datasources', db=db) or 'slices_ibfk_1'
referenced='datasources', db=db)
slices_ibfk_2 = generic_find_constraint_name(
table='slices', columns={'table_id'},
referenced='tables', db=db) or 'slices_ibfk_2'
referenced='tables', db=db)
with op.batch_alter_table("slices") as batch_op:
batch_op.drop_constraint(slices_ibfk_1, type_="foreignkey")
batch_op.drop_constraint(slices_ibfk_2, type_="foreignkey")
if slices_ibfk_1:
batch_op.drop_constraint(slices_ibfk_1, type_="foreignkey")
if slices_ibfk_2:
batch_op.drop_constraint(slices_ibfk_2, type_="foreignkey")
batch_op.drop_column('druid_datasource_id')
batch_op.drop_column('table_id')
except Exception as e:
@ -59,17 +61,6 @@ def upgrade():
except Exception as e:
logging.warning(str(e))
try:
# wasn't created for some databases in the migration b4456560d4f3
if not table_has_constraint('tables', '_customer_location_uc', db):
with op.batch_alter_table('tables') as batch_op:
batch_op.create_unique_constraint(
'_customer_location_uc',
['database_id', 'schema', 'table_name'])
batch_op.drop_index('table_name')
except Exception as e:
logging.warning(str(e))
def downgrade():
try:

View File

@ -89,7 +89,7 @@ class SupersetSecurityManager(SecurityManager):
"""Protecting from has_access failing from missing perms/view"""
if not user:
user = g.user
if user.is_anonymous():
if user.is_anonymous:
return self.is_item_public(permission_name, view_name)
return self._has_view_access(user, permission_name, view_name)

View File

@ -27,7 +27,7 @@
{% if not current_user.is_anonymous() %}
{% if not current_user.is_anonymous %}
<li class="dropdown">
<a
class="dropdown-toggle"

View File

@ -85,7 +85,7 @@ def get_datasource_exist_error_msg(full_name):
def get_user_roles():
if g.user.is_anonymous():
if g.user.is_anonymous:
public_role = conf.get('AUTH_ROLE_PUBLIC')
return [security_manager.find_role(public_role)] if public_role else []
return g.user.roles
@ -289,7 +289,7 @@ def check_ownership(obj, raise_if_false=True):
security_exception = SupersetSecurityException(
"You don't have the rights to alter [{}]".format(obj))
if g.user.is_anonymous():
if g.user.is_anonymous:
if raise_if_false:
raise security_exception
return False

View File

@ -30,7 +30,7 @@ def bootstrap_user_data(username=None, include_perms=False):
'firstName': user.first_name,
'lastName': user.last_name,
'userId': user.id,
'isActive': user.is_active(),
'isActive': user.is_active,
'createdOn': user.created_on.isoformat(),
'email': user.email,
}