Files
core/orm/collab.py

28 lines
970 B
Python
Raw Normal View History

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