1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-12-05 01:04:21 +00:00
royalnet/royalpack/tables/fiorygitransactions.py

35 lines
885 B
Python
Raw Normal View History

2020-01-31 00:47:44 +00:00
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declared_attr
class FiorygiTransaction:
__tablename__ = "fiorygitransactions"
@declared_attr
def id(self):
return Column(Integer, primary_key=True)
@declared_attr
def change(self):
return Column(Integer, nullable=False)
@declared_attr
def user_id(self):
return Column(Integer, ForeignKey("fiorygi.user_id"), nullable=False)
@declared_attr
2020-03-18 16:35:08 +00:00
def wallet(self):
2020-01-31 00:47:44 +00:00
return relationship("Fiorygi", backref=backref("transactions"))
2020-03-18 16:35:08 +00:00
@property
def user(self):
return self.wallet.user
2020-01-31 00:47:44 +00:00
@declared_attr
def reason(self):
return Column(String, nullable=False, default="")
def __repr__(self):
return f"<{self.__class__.__name__}: {self.change:+} to {self.user.username} for {self.reason}>"