1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00
royalnet/rpgpack/tables/dndactivecharacters.py

39 lines
1 KiB
Python
Raw Normal View History

2019-11-11 09:34:05 +00:00
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import *
class DndActiveCharacter:
__tablename__ = "dndactivecharacters"
@declared_attr
def active_character_id(self):
return Column(Integer, primary_key=True)
2019-11-11 09:34:05 +00:00
@declared_attr
def character_id(self):
return Column(Integer, ForeignKey("dndcharacters.character_id"))
2019-11-11 09:34:05 +00:00
@declared_attr
def user_id(self):
return Column(Integer, ForeignKey("users.uid"))
2019-11-11 09:34:05 +00:00
@declared_attr
def character(self):
return relationship("DndCharacter", foreign_keys=self.character_id, backref="activated_by")
@declared_attr
def user(self):
2020-02-18 13:48:21 +00:00
return relationship("User", foreign_keys=self.user_id, backref=backref("dnd_active_characters"))
@declared_attr
def interface_name(self):
return Column(String)
@declared_attr
def interface_data(self):
return Column(LargeBinary)
2019-11-11 09:34:05 +00:00
def __repr__(self):
return f"<{self.__class__.__qualname__} for {self.user_id}: {self.character_id}>"