open-law/app/models/interpretation.py

32 lines
951 B
Python
Raw Normal View History

2023-05-05 13:42:20 +00:00
from datetime import datetime
2023-04-21 12:58:47 +00:00
from app import db
from app.models.utils import BaseModel
class Interpretation(BaseModel):
__tablename__ = "interpretations"
2023-04-27 13:17:25 +00:00
label = db.Column(db.String(256), unique=False, nullable=False)
2023-04-21 14:01:07 +00:00
text = db.Column(db.Text, unique=False, nullable=False)
2023-04-21 12:58:47 +00:00
marked = db.Column(db.Boolean, default=False)
2023-05-05 13:42:20 +00:00
created_at = db.Column(db.DateTime, default=datetime.now)
2023-04-21 12:58:47 +00:00
# Foreign keys
user_id = db.Column(db.ForeignKey("users.id"))
section_id = db.Column(db.ForeignKey("sections.id"))
# Relationships
user = db.relationship("User")
section = db.relationship("Section")
comments = db.relationship("Comment", viewonly=True)
votes = db.relationship("InterpretationVote", viewonly=True)
tags = db.relationship(
"Tag",
secondary="interpretation_tags",
back_populates="interpretations",
)
def __repr__(self):
return f"<{self.id}: {self.label}>"