Add status to task order table
This commit is contained in:
parent
27eb15fc2d
commit
dda6db8562
@ -0,0 +1,31 @@
|
|||||||
|
"""Add status enum to task_order
|
||||||
|
|
||||||
|
Revision ID: 3d346b5c8f19
|
||||||
|
Revises: 71cbe76c3b87
|
||||||
|
Create Date: 2019-01-10 13:55:58.934890
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '3d346b5c8f19'
|
||||||
|
down_revision = '71cbe76c3b87'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('task_orders', sa.Column('status', sa.Enum('PENDING', name='status', native_enum=False), nullable=True))
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
conn = op.get_bind()
|
||||||
|
conn.execute("UPDATE task_orders set status = 'PENDING'")
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('task_orders', 'status')
|
||||||
|
# ### end Alembic commands ###
|
@ -1,10 +1,16 @@
|
|||||||
from sqlalchemy import Column, Numeric, String, ForeignKey, Date
|
from enum import Enum
|
||||||
|
|
||||||
|
from sqlalchemy import Column, Enum as SQLAEnum, Numeric, String, ForeignKey, Date
|
||||||
from sqlalchemy.types import ARRAY
|
from sqlalchemy.types import ARRAY
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from atst.models import Base, types, mixins
|
from atst.models import Base, types, mixins
|
||||||
|
|
||||||
|
|
||||||
|
class Status(Enum):
|
||||||
|
PENDING = "pending"
|
||||||
|
|
||||||
|
|
||||||
class TaskOrder(Base, mixins.TimestampsMixin):
|
class TaskOrder(Base, mixins.TimestampsMixin):
|
||||||
__tablename__ = "task_orders"
|
__tablename__ = "task_orders"
|
||||||
|
|
||||||
@ -27,6 +33,8 @@ class TaskOrder(Base, mixins.TimestampsMixin):
|
|||||||
so_id = Column(ForeignKey("users.id"))
|
so_id = Column(ForeignKey("users.id"))
|
||||||
security_officer = relationship("User", foreign_keys="TaskOrder.so_id")
|
security_officer = relationship("User", foreign_keys="TaskOrder.so_id")
|
||||||
|
|
||||||
|
status = Column(SQLAEnum(Status, native_enum=False, default=Status.PENDING))
|
||||||
|
|
||||||
scope = Column(String) # Cloud Project Scope
|
scope = Column(String) # Cloud Project Scope
|
||||||
defense_component = Column(String) # Department of Defense Component
|
defense_component = Column(String) # Department of Defense Component
|
||||||
app_migration = Column(String) # App Migration
|
app_migration = Column(String) # App Migration
|
||||||
@ -67,6 +75,10 @@ class TaskOrder(Base, mixins.TimestampsMixin):
|
|||||||
def portfolio_name(self):
|
def portfolio_name(self):
|
||||||
return self.workspace.name
|
return self.workspace.name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_pending(self):
|
||||||
|
return self.status == Status.PENDING
|
||||||
|
|
||||||
def to_dictionary(self):
|
def to_dictionary(self):
|
||||||
return {
|
return {
|
||||||
"portfolio_name": self.portfolio_name,
|
"portfolio_name": self.portfolio_name,
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
<div class="panel task-order-heading row">
|
<div class="panel task-order-heading row">
|
||||||
<div class="task-order-heading__name row">
|
<div class="task-order-heading__name row">
|
||||||
<h2>New Task Order</h2>
|
<h2>New Task Order</h2>
|
||||||
<span class="label label--warning">Pending</span>
|
<span class="label label--{{ 'warning' if task_order.is_pending }}">{{ task_order.status.value }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="task_order-heading__details row">
|
<div class="task_order-heading__details row">
|
||||||
<div class="task-order-heading__value col">
|
<div class="task-order-heading__value col">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user