Skip to content

Commit

Permalink
Adding a view for featured datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
Michelle Thomas committed Dec 16, 2015
1 parent dcd3678 commit 30df7be
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 1 deletion.
23 changes: 23 additions & 0 deletions panoramix/migrations/versions/12d55656cbca_is_featured.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""is_featured
Revision ID: 12d55656cbca
Revises: 55179c7f25c7
Create Date: 2015-12-14 13:37:17.374852
"""

# revision identifiers, used by Alembic.
revision = '12d55656cbca'
down_revision = '55179c7f25c7'

from alembic import op
import sqlalchemy as sa


def upgrade():
op.add_column('tables', sa.Column('is_featured', sa.Boolean(), nullable=True))


def downgrade():
op.drop_column('tables', 'is_featured')

1 change: 1 addition & 0 deletions panoramix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
description = Column(Text)
default_endpoint = Column(Text)
database_id = Column(Integer, ForeignKey('dbs.id'), nullable=False)
is_featured = Column(Boolean, default=False)
database = relationship(
'Database', backref='tables', foreign_keys=[database_id])
offset = Column(Integer, default=0)
Expand Down
18 changes: 18 additions & 0 deletions panoramix/static/featured_datasets.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.main-text {
text-align: center;
font-size: 36px;
margin-bottom: 20px;
}

.data-title{
font-size: 26px;
font-weight: strong;
}

table {
border-bottom: 1px solid #dddddd;
}

td {
vertical-align: middle;
}
27 changes: 27 additions & 0 deletions panoramix/templates/panoramix/featured_datasets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "panoramix/base.html" %}
{% block content %}
<link rel="stylesheet" type="text/css" href="/static/featured_datasets.css" />
<div class="main-text">
Featured Datasets
</div>
<table class = "table table-hover">
<thead>
<tr>
<th>Table</th>
<th>Database</th>
</tr>
</thead>
<tbody>
{% for dataset in featured_datasets %}
<tr>
<td>
<a href='{{ dataset.default_endpoint }}' class="data-title">{{ dataset.table_name }}</a>
</br> {{ dataset.description }}
</td>
<td>{{ dataset.database }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

15 changes: 14 additions & 1 deletion panoramix/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ 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', 'database', 'description', 'main_dttm_col',
'table_name', 'is_featured', 'database', 'description', 'main_dttm_col',
'default_endpoint', 'offset']
related_views = [TableColumnInlineView, SqlMetricInlineView]
base_order = ('changed_on','desc')
Expand Down Expand Up @@ -538,6 +538,19 @@ def show_traceback(self):
title=ascii_art.stacktrace,
art=ascii_art.error), 500

@has_access
@expose("/datasets", methods=['GET'])
def datasets(self):
session = db.session()
datasets_sqla = (session.query(models.SqlaTable)
.filter_by(is_featured=True).all())
datasets_druid = (session.query(models.Datasource)
.filter_by(is_featured=True).all())
featured_datasets = datasets_sqla + datasets_druid
return self.render_template(
'panoramix/featured_datasets.html',
featured_datasets=featured_datasets)

appbuilder.add_view_no_menu(Panoramix)
appbuilder.add_link(
"Refresh Druid Metadata",
Expand Down

0 comments on commit 30df7be

Please sign in to comment.