28 lines
801 B
Python
28 lines
801 B
Python
import uuid
|
|
from enum import StrEnum
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import ForeignKey
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from src import domain
|
|
|
|
if TYPE_CHECKING:
|
|
from .target_channel import TargetChannel
|
|
|
|
|
|
class CreativeStatus(StrEnum):
|
|
ACTIVE = 'active'
|
|
ARCHIVED = 'archived'
|
|
|
|
|
|
class Creative(domain.Base):
|
|
name: Mapped[str]
|
|
text: Mapped[str]
|
|
status: Mapped[CreativeStatus]
|
|
purchases_count: Mapped[int] = mapped_column(default=0, server_default='0')
|
|
user_id: Mapped[uuid.UUID] = mapped_column(ForeignKey('users.id'), index=True)
|
|
|
|
target_channel_id: Mapped[uuid.UUID] = mapped_column(ForeignKey('targetchannels.id'), index=True)
|
|
target_channel: Mapped['TargetChannel'] = relationship(back_populates='creatives')
|