mirror of https://gitlab.com/tildes/tildes.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
"""Contains the TopicIgnore class."""
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import BigInteger, Column, ForeignKey, TIMESTAMP
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql.expression import text
|
|
|
|
from tildes.models import DatabaseModel
|
|
from tildes.models.topic import Topic
|
|
from tildes.models.user import User
|
|
|
|
|
|
class TopicIgnore(DatabaseModel):
|
|
"""Model for an ignored topic."""
|
|
|
|
__tablename__ = "topic_ignores"
|
|
|
|
user_id: int = Column(
|
|
BigInteger, ForeignKey("users.user_id"), nullable=False, primary_key=True
|
|
)
|
|
topic_id: int = Column(
|
|
BigInteger, ForeignKey("topics.topic_id"), nullable=False, primary_key=True
|
|
)
|
|
created_time: datetime = Column(
|
|
TIMESTAMP(timezone=True),
|
|
nullable=False,
|
|
index=True,
|
|
server_default=text("NOW()"),
|
|
)
|
|
|
|
user: User = relationship("User", innerjoin=True)
|
|
topic: Topic = relationship("Topic", innerjoin=True)
|
|
|
|
def __init__(self, user: User, topic: Topic) -> None:
|
|
"""Ignore a topic."""
|
|
self.user = user
|
|
self.topic = topic
|