From 9dcf8e101a6740d15b126c0a17c7a16ca5ae7225 Mon Sep 17 00:00:00 2001 From: Joshua Carp Date: Mon, 8 Oct 2018 12:40:52 -0400 Subject: [PATCH] Upgrade flask-appbuilder to latest. (#6030) * Upgrade flask-appbuilder to latest. * Skip constraint deletes if not exist. * Document breaking change in flask-login. --- UPDATING.md | 5 +++++ requirements.txt | 2 +- setup.py | 2 +- ...3_fix_wrong_constraint_on_table_columns.py | 5 +++-- .../3b626e2a6783_sync_db_with_models.py | 21 ++++++------------- superset/security.py | 2 +- .../templates/appbuilder/navbar_right.html | 2 +- superset/views/base.py | 4 ++-- superset/views/utils.py | 2 +- 9 files changed, 21 insertions(+), 24 deletions(-) diff --git a/UPDATING.md b/UPDATING.md index 48fa027d0..326a57d4f 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -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 diff --git a/requirements.txt b/requirements.txt index f1a3cd75a..9fa2bffb4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.py b/setup.py index 6cbe7a605..5816a0590 100644 --- a/setup.py +++ b/setup.py @@ -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', diff --git a/superset/migrations/versions/1226819ee0e3_fix_wrong_constraint_on_table_columns.py b/superset/migrations/versions/1226819ee0e3_fix_wrong_constraint_on_table_columns.py index f5d940c1b..a7682efe4 100644 --- a/superset/migrations/versions/1226819ee0e3_fix_wrong_constraint_on_table_columns.py +++ b/superset/migrations/versions/1226819ee0e3_fix_wrong_constraint_on_table_columns.py @@ -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', diff --git a/superset/migrations/versions/3b626e2a6783_sync_db_with_models.py b/superset/migrations/versions/3b626e2a6783_sync_db_with_models.py index f1bf94968..8e21114e3 100644 --- a/superset/migrations/versions/3b626e2a6783_sync_db_with_models.py +++ b/superset/migrations/versions/3b626e2a6783_sync_db_with_models.py @@ -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: diff --git a/superset/security.py b/superset/security.py index be8805b63..3f2358e96 100644 --- a/superset/security.py +++ b/superset/security.py @@ -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) diff --git a/superset/templates/appbuilder/navbar_right.html b/superset/templates/appbuilder/navbar_right.html index 9d6c251f3..1d6fb69bd 100644 --- a/superset/templates/appbuilder/navbar_right.html +++ b/superset/templates/appbuilder/navbar_right.html @@ -27,7 +27,7 @@ -{% if not current_user.is_anonymous() %} +{% if not current_user.is_anonymous %}