feat: переименование доменной области
This commit is contained in:
63
src/domain/purchase_plan.py
Normal file
63
src/domain/purchase_plan.py
Normal file
@@ -0,0 +1,63 @@
|
||||
import enum
|
||||
import uuid
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from tortoise import fields
|
||||
|
||||
from .base import TimestampedModel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .channel import Channel
|
||||
from .project import Project
|
||||
from .workspace import Workspace
|
||||
|
||||
|
||||
class PurchasePlanStatus(str, enum.Enum):
|
||||
ACTIVE = 'active'
|
||||
ARCHIVED = 'archived'
|
||||
|
||||
|
||||
class PurchasePlanChannelStatus(str, enum.Enum):
|
||||
PLANNED = 'planned'
|
||||
APPROVED = 'approved'
|
||||
REJECTED = 'rejected'
|
||||
IN_PROGRESS = 'in_progress'
|
||||
COMPLETED = 'completed'
|
||||
|
||||
|
||||
class PurchasePlan(TimestampedModel):
|
||||
id = fields.UUIDField(pk=True)
|
||||
status = fields.CharEnumField(PurchasePlanStatus, default=PurchasePlanStatus.ACTIVE)
|
||||
|
||||
workspace: fields.ForeignKeyRelation['Workspace'] = fields.ForeignKeyField(
|
||||
'models.Workspace', related_name='purchase_plans', on_delete=fields.CASCADE, index=True
|
||||
)
|
||||
project: fields.ForeignKeyRelation['Project'] = fields.ForeignKeyField(
|
||||
'models.Project', related_name='purchase_plans', on_delete=fields.CASCADE, index=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
table = 'purchase_plan'
|
||||
indexes = (('project', 'status'),)
|
||||
|
||||
|
||||
class PurchasePlanChannel(TimestampedModel):
|
||||
id = fields.UUIDField(pk=True)
|
||||
status = fields.CharEnumField(PurchasePlanChannelStatus, default=PurchasePlanChannelStatus.PLANNED)
|
||||
planned_cost = fields.FloatField(null=True)
|
||||
comment = fields.TextField(null=True)
|
||||
|
||||
purchase_plan: fields.ForeignKeyRelation['PurchasePlan'] = fields.ForeignKeyField(
|
||||
'models.PurchasePlan', related_name='channels', on_delete=fields.CASCADE, index=True
|
||||
)
|
||||
channel: fields.ForeignKeyRelation['Channel'] = fields.ForeignKeyField(
|
||||
'models.Channel', related_name='purchase_plan_channels', on_delete=fields.CASCADE, index=True
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
purchase_plan_id: uuid.UUID
|
||||
channel_id: uuid.UUID
|
||||
|
||||
class Meta:
|
||||
table = 'purchase_plan_channel'
|
||||
unique_together = (('purchase_plan_id', 'channel_id'),)
|
||||
Reference in New Issue
Block a user