1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Begin work on Diario

This commit is contained in:
Steffo 2019-04-02 12:32:13 +02:00
parent 32d334251f
commit a0912a4db2
5 changed files with 45 additions and 4 deletions

View file

@ -0,0 +1,11 @@
from ..utils import Command, CommandArgs, Call
class DiarioCommand(Command):
command_name = "diario"
command_title = "Aggiungi una citazione al Diario."
async def common(self, call: Call, args: CommandArgs):
# TODO
raise NotImplementedError("TODO")

View file

@ -1,4 +1,3 @@
from .alchemy import Alchemy
from .tables import Royal
__all__ = ["Alchemy", "Royal"]
__all__ = ["Alchemy"]

View file

@ -1,4 +1,5 @@
from .royals import Royal
from .telegram import Telegram
from .diario import Diario
__all__ = ["Royal", "Telegram"]
__all__ = ["Royal", "Telegram", "Diario"]

View file

@ -0,0 +1,30 @@
from sqlalchemy import Column, \
Integer, \
Text, \
Boolean, \
DateTime, \
ForeignKey
from sqlalchemy.orm import relationship
from .royals import Royal
class Diario:
__tablename__ = "diario"
diario_id = Column(Integer, primary_key=True)
creator_id = Column(Integer, ForeignKey("royals.id"))
quoted_id = Column(Integer, ForeignKey("royals.id"))
timestamp = Column(DateTime, nullable=False)
quote = Column(Text, nullable=False)
context = Column(Text)
spoiler = Column(Boolean, default=False)
creator = relationship("Royal", foreign_keys=creator_id, backref="diario_created")
quoted = relationship("Royal", foreign_keys=quoted_id, backref="diario_quoted")
def __repr__(self):
return f"<Diario {self.diario_id}>"
def __str__(self):
return f"diario:{self.diario_id}"

View file

@ -18,7 +18,7 @@ class Telegram:
tg_username = Column(String)
tg_avatar = Column(LargeBinary)
royal = relationship("Royal")
royal = relationship("Royal", backref="telegram")
def __repr__(self):
return f"<Telegram {str(self)}>"