2019-11-29 20:18:01 +00:00
|
|
|
from sqlalchemy import *
|
|
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from sqlalchemy.ext.declarative import declared_attr
|
|
|
|
|
|
|
|
|
|
|
|
class KeiPerson:
|
|
|
|
__tablename__ = "keipeople"
|
|
|
|
|
2019-11-29 23:45:41 +00:00
|
|
|
@declared_attr
|
|
|
|
def kpid(self):
|
|
|
|
return Column(String, primary_key=True)
|
|
|
|
|
2019-11-29 20:18:01 +00:00
|
|
|
@declared_attr
|
|
|
|
def user_id(self):
|
2019-11-29 23:45:41 +00:00
|
|
|
return Column(Integer, ForeignKey("users.uid"))
|
2019-11-29 20:18:01 +00:00
|
|
|
|
|
|
|
@declared_attr
|
|
|
|
def user(self):
|
|
|
|
return relationship("User", foreign_keys=self.user_id, backref="kei_people")
|
|
|
|
|
2019-11-29 23:45:41 +00:00
|
|
|
def __repr__(self):
|
|
|
|
return f"<{self.__class__.__qualname__} {self.kpid}{' ' + self.user.username if self.user is not None else ''}>"
|