1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00
royalnet/giftpack/tables/xmasgift.py

35 lines
903 B
Python
Raw Normal View History

2019-12-25 01:41:52 +00:00
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declared_attr
class XmasGift:
__tablename__ = "xmasgifts"
@declared_attr
def gift_id(self):
return Column(Integer, primary_key=True)
@declared_attr
def source(self):
return Column(String, nullable=False)
@declared_attr
def destination(self):
return Column(String, nullable=False)
@declared_attr
def extra_text(self):
return Column(String, nullable=False, default="")
@declared_attr
def drawn(self):
return Column(Boolean, nullable=False, default=False)
def __str__(self):
msg = f"Regalo #{self.gift_id} da {self.source} a {self.destination}" + f": {self.extra_text}" if self.extra_text else ""
if self.drawn:
return f"⚫️ {msg}"
else:
return f"🔵 [b]{msg}[/b]"