open-law/app/models/tag.py

24 lines
682 B
Python
Raw Normal View History

2023-04-21 12:58:47 +00: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 15:39:37 +00:00
sections = db.relationship(
"Section", secondary="section_tags", back_populates="tags"
)
2023-04-21 12:58:47 +00:00
interpretations = db.relationship(
"Interpretation", secondary="interpretation_tags", back_populates="tags"
)
comments = db.relationship(
"Comment", secondary="comment_tags", back_populates="tags"
)
2023-05-16 08:31:17 +00:00
books = db.relationship("Book", secondary="book_tags", back_populates="tags")
2023-04-21 12:58:47 +00:00
def __repr__(self):
return f"<{self.id}: {self.name}>"