diff --git a/panoramix/migrations/versions/2591d77e9831_user_id.py b/panoramix/migrations/versions/2591d77e9831_user_id.py new file mode 100644 index 0000000000000..5039078e901eb --- /dev/null +++ b/panoramix/migrations/versions/2591d77e9831_user_id.py @@ -0,0 +1,27 @@ +"""user_id + +Revision ID: 2591d77e9831 +Revises: 12d55656cbca +Create Date: 2015-12-15 17:02:45.128709 + +""" + +# revision identifiers, used by Alembic. +revision = '2591d77e9831' +down_revision = '12d55656cbca' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + with op.batch_alter_table('tables') as batch_op: + batch_op.add_column(sa.Column('user_id', sa.Integer())) + batch_op.create_foreign_key('user_id', 'ab_user', ['user_id'], ['id']) + + +def downgrade(): + with op.batch_alter_table('tables'): + op.drop_constraint(None, 'tables', type_='foreignkey') + op.drop_column('tables', 'user_id') + diff --git a/panoramix/models.py b/panoramix/models.py index a4b3007ae5b64..a2357b27a95a6 100644 --- a/panoramix/models.py +++ b/panoramix/models.py @@ -229,6 +229,8 @@ class SqlaTable(Model, Queryable, AuditMixinNullable): default_endpoint = Column(Text) database_id = Column(Integer, ForeignKey('dbs.id'), nullable=False) is_featured = Column(Boolean, default=False) + user_id = Column(Integer, ForeignKey('ab_user.id')) + owner = relationship('User', backref='tables', foreign_keys=[user_id]) database = relationship( 'Database', backref='tables', foreign_keys=[database_id]) offset = Column(Integer, default=0) diff --git a/panoramix/static/featured_datasets.css b/panoramix/static/featured_datasets.css index a9067d4f3e0db..32a41147e8610 100644 --- a/panoramix/static/featured_datasets.css +++ b/panoramix/static/featured_datasets.css @@ -4,15 +4,14 @@ margin-bottom: 20px; } -.data-title{ - font-size: 26px; - font-weight: strong; +.small_table { + width: 170px; } -table { - border-bottom: 1px solid #dddddd; +#data-title{ + font-size: 20px; } -td { - vertical-align: middle; +#dataset-table { + border-bottom: 1px solid #dddddd; } diff --git a/panoramix/templates/panoramix/featured_datasets.html b/panoramix/templates/panoramix/featured_datasets.html index fb9f014690c76..83106307f4550 100644 --- a/panoramix/templates/panoramix/featured_datasets.html +++ b/panoramix/templates/panoramix/featured_datasets.html @@ -4,24 +4,38 @@
Featured Datasets
- +
+ + {% for dataset in featured_datasets %} - + + + {% endfor %}
Table DatabaseOwner
- {{ dataset.table_name }} +
{{ dataset.table_name }}

{{ dataset.description }}
{{ dataset.database }}{{ dataset.database }}{{ dataset.owner }}
{% endblock %} +{% block tail %} + + + + +{% endblock %} diff --git a/panoramix/views.py b/panoramix/views.py index 0d17173db8b37..09ca436068484 100644 --- a/panoramix/views.py +++ b/panoramix/views.py @@ -59,6 +59,14 @@ class TableColumnInlineView(CompactCRUDMixin, PanoramixModelView): } appbuilder.add_view_no_menu(TableColumnInlineView) +appbuilder.add_link( + "Featured Datasets", + href='/panoramix/featured_datasets', + category='Sources', + category_icon='fa-table', + icon="fa-star") + + class ColumnInlineView(CompactCRUDMixin, PanoramixModelView): datamodel = SQLAInterface(models.Column) @@ -140,8 +148,8 @@ class TableView(PanoramixModelView, DeleteMixin): list_columns = ['table_link', 'database', 'changed_by', 'changed_on_'] add_columns = ['table_name', 'database', 'default_endpoint', 'offset'] edit_columns = [ - 'table_name', 'is_featured', 'database', 'description', 'main_dttm_col', - 'default_endpoint', 'offset'] + 'table_name', 'is_featured', 'database', 'description', 'owner', + 'main_dttm_col', 'default_endpoint', 'offset'] related_views = [TableColumnInlineView, SqlMetricInlineView] base_order = ('changed_on','desc') description_columns = { @@ -539,8 +547,8 @@ def show_traceback(self): art=ascii_art.error), 500 @has_access - @expose("/datasets", methods=['GET']) - def datasets(self): + @expose("/featured_datasets", methods=['GET']) + def featured_datasets(self): session = db.session() datasets_sqla = (session.query(models.SqlaTable) .filter_by(is_featured=True).all())