2020-01-20 21:47:45 +00:00
|
|
|
from sqlalchemy import *
|
|
|
|
from sqlalchemy.orm import relationship, backref
|
|
|
|
from sqlalchemy.ext.declarative import declared_attr
|
2020-01-20 23:54:55 +00:00
|
|
|
import steam
|
2020-01-20 21:47:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Steam:
|
|
|
|
__tablename__ = "steam"
|
|
|
|
|
|
|
|
@declared_attr
|
|
|
|
def user_id(self):
|
|
|
|
return Column(Integer, ForeignKey("users.uid"))
|
|
|
|
|
|
|
|
@declared_attr
|
|
|
|
def user(self):
|
|
|
|
return relationship("User", backref=backref("steam"))
|
|
|
|
|
|
|
|
@declared_attr
|
2020-01-20 23:54:55 +00:00
|
|
|
def _steamid(self):
|
2020-01-20 21:47:45 +00:00
|
|
|
return Column(BigInteger, primary_key=True)
|
|
|
|
|
2020-01-20 23:54:55 +00:00
|
|
|
@property
|
|
|
|
def steamid(self):
|
|
|
|
return steam.SteamID(self._steamid)
|
|
|
|
|
2020-01-20 21:47:45 +00:00
|
|
|
@declared_attr
|
|
|
|
def persona_name(self):
|
|
|
|
return Column(String)
|
|
|
|
|
|
|
|
@declared_attr
|
|
|
|
def profile_url(self):
|
|
|
|
return Column(String)
|
|
|
|
|
|
|
|
@declared_attr
|
|
|
|
def avatar(self):
|
|
|
|
return Column(String)
|
|
|
|
|
|
|
|
@declared_attr
|
|
|
|
def primary_clan_id(self):
|
|
|
|
return Column(BigInteger)
|
|
|
|
|
|
|
|
@declared_attr
|
|
|
|
def account_creation_date(self):
|
|
|
|
return Column(DateTime)
|
|
|
|
|
|
|
|
def __repr__(self):
|
2020-01-20 23:54:55 +00:00
|
|
|
return f"<Steam account {self._steamid} of {self.user}>"
|
2020-01-20 21:47:45 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
2020-01-20 23:54:55 +00:00
|
|
|
return f"[c]steam:{self._steamid}[/c]"
|