2023-04-21 15:58:47 +03:00
|
|
|
from app import db
|
|
|
|
from app.models.utils import BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
class Tag(BaseModel):
|
|
|
|
__tablename__ = "tags"
|
|
|
|
|
|
|
|
name = db.Column(db.String(32), unique=True, nullable=False)
|
|
|
|
|
|
|
|
# Relationships
|
2023-05-17 18:39:37 +03:00
|
|
|
sections = db.relationship(
|
|
|
|
"Section", secondary="section_tags", back_populates="tags"
|
|
|
|
)
|
2023-04-21 15:58:47 +03:00
|
|
|
interpretations = db.relationship(
|
|
|
|
"Interpretation", secondary="interpretation_tags", back_populates="tags"
|
|
|
|
)
|
|
|
|
comments = db.relationship(
|
|
|
|
"Comment", secondary="comment_tags", back_populates="tags"
|
|
|
|
)
|
2023-05-16 11:31:17 +03:00
|
|
|
books = db.relationship("Book", secondary="book_tags", back_populates="tags")
|
2023-04-21 15:58:47 +03:00
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f"<{self.id}: {self.name}>"
|