feat: миграция с булевых переменных на status для target_channel
This commit is contained in:
@@ -25,22 +25,12 @@ class TargetChannel(domain.Base):
|
||||
username: Mapped[str | None] = mapped_column(index=True)
|
||||
status: Mapped[TargetChannelStatus] = mapped_column(default=TargetChannelStatus.ACTIVE)
|
||||
|
||||
# Relationship with user
|
||||
user_id: Mapped[uuid.UUID] = mapped_column(ForeignKey('user.id'), index=True)
|
||||
user: Mapped['User'] = relationship(back_populates='target_channels')
|
||||
|
||||
# M2M relationship with external channels
|
||||
external_channels: Mapped[list['ExternalChannel']] = relationship(
|
||||
secondary='target_external_channel',
|
||||
back_populates='target_channels',
|
||||
)
|
||||
|
||||
creatives: Mapped[list['Creative']] = relationship(back_populates='target_channel')
|
||||
|
||||
@property
|
||||
def is_active(self) -> bool:
|
||||
return self.status == TargetChannelStatus.ACTIVE
|
||||
|
||||
@is_active.setter
|
||||
def is_active(self, value: bool) -> None:
|
||||
self.status = TargetChannelStatus.ACTIVE if value else TargetChannelStatus.INACTIVE
|
||||
|
||||
Reference in New Issue
Block a user