This repository was archived by the owner on Nov 3, 2023. It is now read-only.
forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from john-bodley/john-bodley-cherry-picks
[cherries] Picking a few cherries
- Loading branch information
Showing
11 changed files
with
213 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
superset/migrations/versions/0c5070e96b57_add_user_attributes_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""add user attributes table | ||
Revision ID: 0c5070e96b57 | ||
Revises: 7fcdcde0761c | ||
Create Date: 2018-08-06 14:38:18.965248 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '0c5070e96b57' | ||
down_revision = '7fcdcde0761c' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(): | ||
op.create_table('user_attribute', | ||
sa.Column('created_on', sa.DateTime(), nullable=True), | ||
sa.Column('changed_on', sa.DateTime(), nullable=True), | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('user_id', sa.Integer(), nullable=True), | ||
sa.Column('welcome_dashboard_id', sa.Integer(), nullable=True), | ||
sa.Column('created_by_fk', sa.Integer(), nullable=True), | ||
sa.Column('changed_by_fk', sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint(['changed_by_fk'], ['ab_user.id'], ), | ||
sa.ForeignKeyConstraint(['created_by_fk'], ['ab_user.id'], ), | ||
sa.ForeignKeyConstraint(['user_id'], ['ab_user.id'], ), | ||
sa.ForeignKeyConstraint(['welcome_dashboard_id'], ['dashboards.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('user_attribute') |
36 changes: 36 additions & 0 deletions
36
superset/migrations/versions/1a1d627ebd8e_position_json.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""position_json | ||
Revision ID: 1a1d627ebd8e | ||
Revises: 0c5070e96b57 | ||
Create Date: 2018-08-13 11:30:07.101702 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '1a1d627ebd8e' | ||
down_revision = '0c5070e96b57' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from superset.utils import MediumText | ||
|
||
|
||
def upgrade(): | ||
with op.batch_alter_table('dashboards') as batch_op: | ||
batch_op.alter_column( | ||
'position_json', | ||
existing_type=sa.Text(), | ||
type_=MediumText(), | ||
existing_nullable=True, | ||
) | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table('dashboards') as batch_op: | ||
batch_op.alter_column( | ||
'position_json', | ||
existing_type=MediumText(), | ||
type_=sa.Text(), | ||
existing_nullable=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import core # noqa | ||
from . import sql_lab # noqa | ||
from . import user_attributes # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
|
||
from flask_appbuilder import Model | ||
from sqlalchemy import Column, ForeignKey, Integer | ||
from sqlalchemy.orm import relationship | ||
|
||
from superset import security_manager | ||
from superset.models.helpers import AuditMixinNullable | ||
|
||
|
||
class UserAttribute(Model, AuditMixinNullable): | ||
|
||
""" | ||
Custom attributes attached to the user. | ||
Extending the user attribute is tricky due to its dependency on the | ||
authentication typew an circular dependencies in Superset. Instead, we use | ||
a custom model for adding attributes. | ||
""" | ||
|
||
__tablename__ = 'user_attribute' | ||
id = Column(Integer, primary_key=True) # pylint: disable=invalid-name | ||
user_id = Column(Integer, ForeignKey('ab_user.id')) | ||
user = relationship( | ||
security_manager.user_model, | ||
backref='extra_attributes', | ||
foreign_keys=[user_id], | ||
) | ||
|
||
welcome_dashboard_id = Column(Integer, ForeignKey('dashboards.id')) | ||
welcome_dashboard = relationship('Dashboard') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters