mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Begin work on Diario
This commit is contained in:
parent
32d334251f
commit
a0912a4db2
5 changed files with 45 additions and 4 deletions
11
royalnet/commands/diario.py
Normal file
11
royalnet/commands/diario.py
Normal 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")
|
|
@ -1,4 +1,3 @@
|
|||
from .alchemy import Alchemy
|
||||
from .tables import Royal
|
||||
|
||||
__all__ = ["Alchemy", "Royal"]
|
||||
__all__ = ["Alchemy"]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from .royals import Royal
|
||||
from .telegram import Telegram
|
||||
from .diario import Diario
|
||||
|
||||
__all__ = ["Royal", "Telegram"]
|
||||
__all__ = ["Royal", "Telegram", "Diario"]
|
||||
|
|
30
royalnet/database/tables/diario.py
Normal file
30
royalnet/database/tables/diario.py
Normal 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}"
|
|
@ -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)}>"
|
||||
|
|
Loading…
Reference in a new issue