32 lines
898 B
Python
32 lines
898 B
Python
from typing import TYPE_CHECKING
|
|
from uuid import UUID
|
|
|
|
from tortoise import fields
|
|
|
|
from .base import TimestampedModel
|
|
|
|
if TYPE_CHECKING:
|
|
from .target_channel import TargetChannel
|
|
from .user import User
|
|
|
|
|
|
class ExternalChannel(TimestampedModel):
|
|
id = fields.UUIDField(pk=True)
|
|
telegram_id = fields.BigIntField(unique=True, index=True)
|
|
title = fields.CharField(max_length=255)
|
|
username = fields.CharField(max_length=255, null=True, index=True)
|
|
description = fields.TextField(null=True)
|
|
subscribers_count = fields.IntField(null=True)
|
|
|
|
user: fields.ForeignKeyRelation['User'] = fields.ForeignKeyField(
|
|
'models.User', related_name='external_channels', on_delete=fields.CASCADE, index=True
|
|
)
|
|
|
|
target_channels: fields.ManyToManyRelation['TargetChannel']
|
|
|
|
if TYPE_CHECKING:
|
|
user_id: UUID
|
|
|
|
class Meta:
|
|
table = 'external_channel'
|