Merge pull request #384 from sartography/chore/admin-cat-456
Admin flag on category + migration + updated test
This commit is contained in:
commit
615d0e7f89
|
@ -162,13 +162,14 @@ class Category(object):
|
||||||
self.name = model.name
|
self.name = model.name
|
||||||
self.display_name = model.display_name
|
self.display_name = model.display_name
|
||||||
self.display_order = model.display_order
|
self.display_order = model.display_order
|
||||||
|
self.admin = model.admin
|
||||||
|
|
||||||
|
|
||||||
class CategorySchema(ma.Schema):
|
class CategorySchema(ma.Schema):
|
||||||
workflows = fields.List(fields.Nested(WorkflowMetadataSchema), dump_only=True)
|
workflows = fields.List(fields.Nested(WorkflowMetadataSchema), dump_only=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Category
|
model = Category
|
||||||
additional = ["id", "name", "display_name", "display_order"]
|
additional = ["id", "name", "display_name", "display_order", "admin"]
|
||||||
unknown = INCLUDE
|
unknown = INCLUDE
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class WorkflowSpecCategoryModel(db.Model):
|
||||||
name = db.Column(db.String)
|
name = db.Column(db.String)
|
||||||
display_name = db.Column(db.String)
|
display_name = db.Column(db.String)
|
||||||
display_order = db.Column(db.Integer)
|
display_order = db.Column(db.Integer)
|
||||||
|
admin = db.Column(db.Boolean)
|
||||||
|
|
||||||
class WorkflowSpecCategoryModelSchema(SQLAlchemyAutoSchema):
|
class WorkflowSpecCategoryModelSchema(SQLAlchemyAutoSchema):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -249,7 +249,8 @@ class ExampleDataLoader:
|
||||||
id=0,
|
id=0,
|
||||||
name='test_category',
|
name='test_category',
|
||||||
display_name='Test Category',
|
display_name='Test Category',
|
||||||
display_order=0
|
display_order=0,
|
||||||
|
admin=False
|
||||||
)
|
)
|
||||||
db.session.add(category)
|
db.session.add(category)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -394,4 +395,4 @@ for k in investigators.keys():
|
||||||
del investigator
|
del investigator
|
||||||
|
|
||||||
cnt_subs = len(subs.keys())
|
cnt_subs = len(subs.keys())
|
||||||
del investigators
|
del investigators
|
||||||
|
|
|
@ -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 ###
|
|
@ -69,6 +69,7 @@ class TestStudyApi(BaseTest):
|
||||||
category = study.categories[0]
|
category = study.categories[0]
|
||||||
self.assertEqual("test_category", category['name'])
|
self.assertEqual("test_category", category['name'])
|
||||||
self.assertEqual("Test Category", category['display_name'])
|
self.assertEqual("Test Category", category['display_name'])
|
||||||
|
self.assertEqual(False, category['admin'])
|
||||||
self.assertEqual(1, len(category["workflows"]))
|
self.assertEqual(1, len(category["workflows"]))
|
||||||
workflow = category["workflows"][0]
|
workflow = category["workflows"][0]
|
||||||
self.assertEqual("random_fact", workflow["name"])
|
self.assertEqual("random_fact", workflow["name"])
|
||||||
|
|
Loading…
Reference in New Issue