Adds is_status flag to workflow specs
This commit is contained in:
parent
f177e33ad6
commit
902dba7191
|
@ -71,6 +71,7 @@ class FileModel(db.Model):
|
|||
name = db.Column(db.String)
|
||||
type = db.Column(db.Enum(FileType))
|
||||
primary = db.Column(db.Boolean)
|
||||
is_status = db.Column(db.Boolean)
|
||||
content_type = db.Column(db.String)
|
||||
workflow_spec_id = db.Column(db.String, db.ForeignKey('workflow_spec.id'), nullable=True)
|
||||
workflow_id = db.Column(db.Integer, db.ForeignKey('workflow.id'), nullable=True)
|
||||
|
|
|
@ -4,6 +4,17 @@ from marshmallow_sqlalchemy import ModelSchema
|
|||
|
||||
from crc import db
|
||||
|
||||
class WorkflowSpecCategoryModel(db.Model):
|
||||
__tablename__ = 'workflow_spec_category'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String)
|
||||
display_name = db.Column(db.String)
|
||||
|
||||
|
||||
class WorkflowSpecCategoryModelSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = WorkflowSpecCategoryModel
|
||||
|
||||
|
||||
class WorkflowSpecModel(db.Model):
|
||||
__tablename__ = 'workflow_spec'
|
||||
|
@ -12,11 +23,15 @@ class WorkflowSpecModel(db.Model):
|
|||
display_name = db.Column(db.String)
|
||||
description = db.Column(db.Text)
|
||||
primary_process_id = db.Column(db.String)
|
||||
workflow_spec_category_id = db.Column(db.Integer, db.ForeignKey('workflow_spec_category.id'))
|
||||
workflow_spec_category = db.relationship("WorkflowSpecCategoryModel")
|
||||
is_status = db.Column(db.Boolean)
|
||||
|
||||
|
||||
class WorkflowSpecModelSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = WorkflowSpecModel
|
||||
include_fk = True # Includes foreign keys
|
||||
|
||||
|
||||
class WorkflowStatus(enum.Enum):
|
||||
|
|
|
@ -16,12 +16,13 @@ class FileService(object):
|
|||
|
||||
@staticmethod
|
||||
def add_workflow_spec_file(workflow_spec: WorkflowSpecModel,
|
||||
name, content_type, binary_data, primary=False):
|
||||
name, content_type, binary_data, primary=False, is_status=False):
|
||||
"""Create a new file and associate it with a workflow spec."""
|
||||
file_model = FileModel(
|
||||
workflow_spec_id=workflow_spec.id,
|
||||
name=name,
|
||||
primary=primary
|
||||
primary=primary,
|
||||
is_status=is_status
|
||||
)
|
||||
if primary:
|
||||
bpmn: ElementTree.Element = ElementTree.fromstring(binary_data)
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 5f06108116ae
|
||||
Revises: 90dd63672e0a
|
||||
Create Date: 2020-03-13 14:55:32.214380
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5f06108116ae'
|
||||
down_revision = '90dd63672e0a'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('workflow_spec_category',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=True),
|
||||
sa.Column('display_name', sa.String(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.add_column('file', sa.Column('is_status', sa.Boolean(), nullable=True))
|
||||
op.add_column('workflow_spec', sa.Column('is_status', sa.Boolean(), nullable=True))
|
||||
op.add_column('workflow_spec', sa.Column('workflow_spec_category_id', sa.Integer(), nullable=True))
|
||||
op.create_foreign_key(None, 'workflow_spec', 'workflow_spec_category', ['workflow_spec_category_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'workflow_spec', type_='foreignkey')
|
||||
op.drop_column('workflow_spec', 'workflow_spec_category_id')
|
||||
op.drop_column('workflow_spec', 'is_status')
|
||||
op.drop_column('file', 'is_status')
|
||||
op.drop_table('workflow_spec_category')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue