superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [incubator-superset] branch master updated: Update annotation model to have JSON Metadata field (#5745)
Date Fri, 31 Aug 2018 17:06:29 GMT
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e3f833  Update annotation model to have JSON Metadata field (#5745)
5e3f833 is described below

commit 5e3f8332c4b6bcba15f06725ddb6295d703db94a
Author: Hugh A. Miles II <hughmil3s@gmail.com>
AuthorDate: Fri Aug 31 10:06:27 2018 -0700

    Update annotation model to have JSON Metadata field (#5745)
    
    * add column to annotation model
    
    * update migration file
    
    * change to Text
    
    * remove old migration file
    
    * add migration file
    
    * remove JSON
    
    * add new column to view
    
    * add comma back
    
    * linting
    
    * lint some more
    
    * missing comma
    
    * rename columns
    
    * add degrade and new migration file
    
    * update version
    
    * fixe changed name
    
    * remove json from list columns
---
 ...826_add_metadata_column_to_annotation_model_.py | 22 ++++++++++++++++++++++
 superset/models/annotations.py                     |  1 +
 superset/views/annotations.py                      | 10 +++++++++-
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/superset/migrations/versions/55e910a74826_add_metadata_column_to_annotation_model_.py
b/superset/migrations/versions/55e910a74826_add_metadata_column_to_annotation_model_.py
new file mode 100644
index 0000000..17c2419
--- /dev/null
+++ b/superset/migrations/versions/55e910a74826_add_metadata_column_to_annotation_model_.py
@@ -0,0 +1,22 @@
+"""add_metadata_column_to_annotation_model.py
+
+Revision ID: 55e910a74826
+Revises: 1a1d627ebd8e
+Create Date: 2018-08-29 14:35:20.407743
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '55e910a74826'
+down_revision = '1a1d627ebd8e'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+    op.add_column('annotation', sa.Column('json_metadata', sa.Text(), nullable=True))
+
+
+def downgrade():
+    op.drop_column('annotation', 'json_metadata')
diff --git a/superset/models/annotations.py b/superset/models/annotations.py
index 82619fd..b7640ba 100644
--- a/superset/models/annotations.py
+++ b/superset/models/annotations.py
@@ -42,6 +42,7 @@ class Annotation(Model, AuditMixinNullable):
     layer = relationship(
         AnnotationLayer,
         backref='annotation')
+    json_metadata = Column(Text)
 
     __table_args__ = (
         Index('ti_dag_state', layer_id, start_dttm, end_dttm),
diff --git a/superset/views/annotations.py b/superset/views/annotations.py
index 648be25..c1d4551 100644
--- a/superset/views/annotations.py
+++ b/superset/views/annotations.py
@@ -24,7 +24,9 @@ class AnnotationModelView(SupersetModelView, DeleteMixin):  # noqa
 
     list_columns = ['layer', 'short_descr', 'start_dttm', 'end_dttm']
     edit_columns = [
-        'layer', 'short_descr', 'long_descr', 'start_dttm', 'end_dttm']
+        'layer', 'short_descr', 'long_descr', 'start_dttm', 'end_dttm',
+        'json_metadata']
+
     add_columns = edit_columns
 
     label_columns = {
@@ -33,6 +35,12 @@ class AnnotationModelView(SupersetModelView, DeleteMixin):  # noqa
         'start_dttm': _('Start Dttm'),
         'end_dttm': _('End Dttm'),
         'long_descr': _('Long Descr'),
+        'json_metadata': _('JSON Metadata'),
+    }
+
+    description_columns = {
+        'json_metadata': 'This JSON represents any additional metadata this \
+         annotation needs to add more context.',
     }
 
     def pre_add(self, obj):


Mime
View raw message