core/orm/collab.py

28 lines
970 B
Python
Raw Normal View History

2022-09-02 10:23:33 +00:00
from datetime import datetime
2022-11-24 17:53:39 +00:00
from sqlalchemy import Column, ForeignKey, DateTime, String
2022-11-19 12:02:45 +00:00
from sqlalchemy.orm import relationship
2022-09-02 10:23:33 +00:00
from base.orm import Base
2022-11-19 12:02:45 +00:00
from orm.user import User
2022-09-02 10:23:33 +00:00
2022-09-03 10:50:14 +00:00
2022-09-02 10:23:33 +00:00
class CollabAuthor(Base):
2022-09-03 10:50:14 +00:00
__tablename__ = "collab_author"
2022-09-02 10:23:33 +00:00
2022-09-03 10:50:14 +00:00
id = None # type: ignore
collab = Column(ForeignKey("collab.id"), primary_key=True)
2022-11-30 06:27:12 +00:00
author = Column(ForeignKey("user.id"), primary_key=True)
2022-11-30 20:29:27 +00:00
# accepted = Column(Boolean, default=False)
2022-09-02 10:23:33 +00:00
2022-09-03 10:50:14 +00:00
class Collab(Base):
__tablename__ = "collab"
2022-09-02 10:23:33 +00:00
2022-09-03 10:50:14 +00:00
title = Column(String, nullable=True, comment="Title")
body = Column(String, nullable=True, comment="Body")
pic = Column(String, nullable=True, comment="Picture")
2022-11-19 12:02:45 +00:00
authors = relationship(lambda: User, secondary=CollabAuthor.__tablename__)
2022-11-30 20:29:27 +00:00
# invites = relationship(lambda: User, secondary=CollabInvited.__tablename__)
2022-09-03 10:50:14 +00:00
createdAt = Column(DateTime, default=datetime.now, comment="Created At")
2022-11-24 17:53:39 +00:00
chat = Column(String, unique=True, nullable=False)