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
This commit is contained in:
Hugh A. Miles II 2018-08-31 10:06:27 -07:00 committed by GitHub
parent e12f4fb66d
commit 5e3f8332c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

View File

@ -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')

View File

@ -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),

View File

@ -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):