adding new models for Use, Recycling, Refurbish and Management actions
This commit is contained in:
parent
e861ae3bf8
commit
c2b0e6341f
|
@ -0,0 +1,38 @@
|
|||
"""adding state actions
|
||||
|
||||
Revision ID: a0978ac6cf4a
|
||||
Revises: 7ecb8ff7abad
|
||||
Create Date: 2021-09-24 12:03:01.661679
|
||||
|
||||
"""
|
||||
from alembic import op, context
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a0978ac6cf4a'
|
||||
down_revision = '7ecb8ff7abad'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def get_inv():
|
||||
INV = context.get_x_argument(as_dictionary=True).get('inventory')
|
||||
if not INV:
|
||||
raise ValueError("Inventory value is not specified")
|
||||
return INV
|
||||
|
||||
def upgrade():
|
||||
op.create_table('action_status',
|
||||
sa.Column('rol_user_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ),
|
||||
sa.ForeignKeyConstraint(['rol_user_id'], ['common.user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
schema=f'{get_inv()}'
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('action_status', schema=f'{get_inv()}')
|
|
@ -199,9 +199,19 @@ class RecyclingDef(ActionDef):
|
|||
SCHEMA = schemas.Recycling
|
||||
|
||||
|
||||
class ReuseDef(ActionDef):
|
||||
class UseDef(ActionDef):
|
||||
VIEW = None
|
||||
SCHEMA = schemas.Reuse
|
||||
SCHEMA = schemas.Use
|
||||
|
||||
|
||||
class RefurbishDef(ActionDef):
|
||||
VIEW = None
|
||||
SCHEMA = schemas.Refurbish
|
||||
|
||||
|
||||
class ManagementDef(ActionDef):
|
||||
VIEW = None
|
||||
SCHEMA = schemas.Management
|
||||
|
||||
|
||||
class ToPrepareDef(ActionDef):
|
||||
|
|
|
@ -1341,12 +1341,31 @@ class DataWipe(JoinedTableMixin, ActionWithMultipleDevices):
|
|||
primaryjoin='DataWipe.document_id == DataWipeDocument.id')
|
||||
|
||||
|
||||
class Recycling(ActionWithMultipleDevices):
|
||||
"""This action mark one devices or container as recycled"""
|
||||
class ActionStatus(JoinedTableMixin, ActionWithMultipleDevices):
|
||||
"""This is a meta-action than mark the status of the devices"""
|
||||
|
||||
rol_user_id = db.Column(UUID(as_uuid=True),
|
||||
db.ForeignKey(User.id),
|
||||
nullable=False,
|
||||
default=lambda: g.user.id)
|
||||
rol_user = db.relationship(User, primaryjoin=rol_user_id == User.id)
|
||||
rol_user_comment = """The user that ."""
|
||||
|
||||
|
||||
class Reuse(ActionWithMultipleDevices):
|
||||
"""This action mark one devices or container as reuse"""
|
||||
class Recycling(ActionStatus):
|
||||
"""This action mark one devices or container as recycling"""
|
||||
|
||||
|
||||
class Use(ActionStatus):
|
||||
"""This action mark one devices or container as use"""
|
||||
|
||||
|
||||
class Refurbish(ActionStatus):
|
||||
"""This action mark one devices or container as refurbish"""
|
||||
|
||||
|
||||
class Management(ActionStatus):
|
||||
"""This action mark one devices or container as management"""
|
||||
|
||||
|
||||
class Prepare(ActionWithMultipleDevices):
|
||||
|
|
|
@ -423,12 +423,24 @@ class Ready(ActionWithMultipleDevices):
|
|||
__doc__ = m.Ready.__doc__
|
||||
|
||||
|
||||
class Recycling(ActionWithMultipleDevices):
|
||||
class ActionStatus(ActionWithMultipleDevices):
|
||||
rol_user = NestedOn(s_user.User, dump_only=True, exclude=('token',))
|
||||
|
||||
|
||||
class Recycling(ActionStatus):
|
||||
__doc__ = m.Recycling.__doc__
|
||||
|
||||
|
||||
class Reuse(ActionWithMultipleDevices):
|
||||
__doc__ = m.Reuse.__doc__
|
||||
class Use(ActionStatus):
|
||||
__doc__ = m.Use.__doc__
|
||||
|
||||
|
||||
class Refurbish(ActionStatus):
|
||||
__doc__ = m.Refurbish.__doc__
|
||||
|
||||
|
||||
class Management(ActionStatus):
|
||||
__doc__ = m.Management.__doc__
|
||||
|
||||
|
||||
class ToPrepare(ActionWithMultipleDevices):
|
||||
|
|
Reference in a new issue