1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
royalnet/giftpack/tables/xmasgift.py
2019-12-25 13:22:27 +01:00

34 lines
905 B
Python

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]"