Admin flag on category + migration + updated test

This commit is contained in:
alicia pritchett 2021-09-29 16:53:59 -04:00
parent d0c819dd5f
commit d5d4496cd0
5 changed files with 50 additions and 4 deletions

View File

@ -162,13 +162,14 @@ class Category(object):
self.name = model.name
self.display_name = model.display_name
self.display_order = model.display_order
self.admin = model.admin
class CategorySchema(ma.Schema):
workflows = fields.List(fields.Nested(WorkflowMetadataSchema), dump_only=True)
class Meta:
model = Category
additional = ["id", "name", "display_name", "display_order"]
additional = ["id", "name", "display_name", "display_order", "admin"]
unknown = INCLUDE

View File

@ -16,7 +16,7 @@ class WorkflowSpecCategoryModel(db.Model):
name = db.Column(db.String)
display_name = db.Column(db.String)
display_order = db.Column(db.Integer)
admin = db.Column(db.Boolean)
class WorkflowSpecCategoryModelSchema(SQLAlchemyAutoSchema):
class Meta:

View File

@ -249,7 +249,8 @@ class ExampleDataLoader:
id=0,
name='test_category',
display_name='Test Category',
display_order=0
display_order=0,
admin=False
)
db.session.add(category)
db.session.commit()

View File

@ -0,0 +1,43 @@
"""empty message
Revision ID: 5c63a89ee7b7
Revises: 9afbd55082a0
Create Date: 2021-09-29 10:24:20.413807
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5c63a89ee7b7'
down_revision = '9afbd55082a0'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_foreign_key(None, 'user', 'ldap_model', ['uid'], ['uid'])
op.drop_column('user', 'affiliation')
op.drop_column('user', 'email_address')
op.drop_column('user', 'eppn')
op.drop_column('user', 'title')
op.drop_column('user', 'first_name')
op.drop_column('user', 'last_name')
op.drop_column('user', 'display_name')
op.add_column('workflow_spec_category', sa.Column('admin', sa.Boolean(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('workflow_spec_category', 'admin')
op.add_column('user', sa.Column('display_name', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('user', sa.Column('last_name', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('user', sa.Column('first_name', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('user', sa.Column('title', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('user', sa.Column('eppn', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('user', sa.Column('email_address', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('user', sa.Column('affiliation', sa.VARCHAR(), autoincrement=False, nullable=True))
# ### end Alembic commands ###

View File

@ -69,6 +69,7 @@ class TestStudyApi(BaseTest):
category = study.categories[0]
self.assertEqual("test_category", category['name'])
self.assertEqual("Test Category", category['display_name'])
self.assertEqual(False, category['admin'])
self.assertEqual(1, len(category["workflows"]))
workflow = category["workflows"][0]
self.assertEqual("random_fact", workflow["name"])