2019-12-12 23:02:49 +00:00
|
|
|
from typing import *
|
2019-11-29 23:45:41 +00:00
|
|
|
from sqlalchemy import *
|
|
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from sqlalchemy.ext.declarative import declared_attr
|
|
|
|
|
|
|
|
|
2019-12-12 23:02:49 +00:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
from .keipeople import KeiPerson
|
|
|
|
|
|
|
|
|
2019-11-29 23:45:41 +00:00
|
|
|
class KeiMessage:
|
|
|
|
__tablename__ = "keimessages"
|
|
|
|
|
|
|
|
@declared_attr
|
2019-12-12 23:02:49 +00:00
|
|
|
def kmid(self) -> int:
|
2019-11-29 23:45:41 +00:00
|
|
|
return Column(Integer, primary_key=True)
|
|
|
|
|
|
|
|
@declared_attr
|
2019-12-12 23:02:49 +00:00
|
|
|
def kei_person_id(self) -> str:
|
2019-11-29 23:45:41 +00:00
|
|
|
return Column(String, ForeignKey("keipeople.kpid"), nullable=False)
|
|
|
|
|
|
|
|
@declared_attr
|
2019-12-12 23:02:49 +00:00
|
|
|
def kei_person(self) -> "KeiPerson":
|
2019-11-29 23:45:41 +00:00
|
|
|
return relationship("KeiPerson", foreign_keys=self.kei_person_id, backref="kei_messages")
|
|
|
|
|
2019-12-10 01:24:58 +00:00
|
|
|
@declared_attr
|
2019-12-12 23:02:49 +00:00
|
|
|
def previous(self) -> Optional[str]:
|
2019-12-10 01:24:58 +00:00
|
|
|
return Column(String)
|
|
|
|
|
2019-11-29 23:45:41 +00:00
|
|
|
@declared_attr
|
2019-12-12 23:02:49 +00:00
|
|
|
def message(self) -> str:
|
2019-11-29 23:45:41 +00:00
|
|
|
return Column(String, nullable=False)
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f"<{self.__class__.__qualname__} '{self.message}'>"
|