forked from rDrama/rDrama
move mods and exiles to hole_relationships.py
parent
c2918d67f0
commit
821c606b8d
|
@ -1,23 +0,0 @@
|
|||
import time
|
||||
|
||||
from sqlalchemy import Column, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql.sqltypes import *
|
||||
|
||||
from files.classes import Base
|
||||
|
||||
class Exile(Base):
|
||||
__tablename__ = "exiles"
|
||||
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
||||
hole = Column(String, ForeignKey("holes.name"), primary_key=True)
|
||||
exiler_id = Column(Integer, ForeignKey("users.id"))
|
||||
created_utc = Column(Integer)
|
||||
|
||||
exiler = relationship("User", primaryjoin="User.id==Exile.exiler_id")
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<{self.__class__.__name__}(user_id={self.user_id}, hole={self.hole})>"
|
|
@ -1,7 +1,7 @@
|
|||
import time
|
||||
|
||||
from sqlalchemy import Column, ForeignKey
|
||||
from sqlalchemy.orm import declared_attr
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql.sqltypes import *
|
||||
|
||||
from files.classes import Base
|
||||
|
@ -10,17 +10,9 @@ class HoleRelationship(Base):
|
|||
__tablename__ = NotImplemented
|
||||
__abstract__ = True
|
||||
|
||||
@declared_attr
|
||||
def user_id(self):
|
||||
return Column(Integer, ForeignKey("users.id"), primary_key=True)
|
||||
|
||||
@declared_attr
|
||||
def hole(self):
|
||||
return Column(String(20), ForeignKey("holes.name"), primary_key=True)
|
||||
|
||||
@declared_attr
|
||||
def created_utc(self):
|
||||
return Column(Integer)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
||||
hole = Column(String, ForeignKey("holes.name"), primary_key=True)
|
||||
created_utc = Column(Integer)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||
|
@ -37,3 +29,11 @@ class HoleBlock(HoleRelationship):
|
|||
|
||||
class HoleFollow(HoleRelationship):
|
||||
__tablename__ = "hole_follows"
|
||||
|
||||
class Mod(HoleRelationship):
|
||||
__tablename__ = "mods"
|
||||
|
||||
class Exile(HoleRelationship):
|
||||
__tablename__ = "exiles"
|
||||
exiler_id = Column(Integer, ForeignKey("users.id"))
|
||||
exiler = relationship("User", primaryjoin="User.id==Exile.exiler_id")
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
import time
|
||||
|
||||
from sqlalchemy import Column, ForeignKey
|
||||
from sqlalchemy.sql.sqltypes import *
|
||||
|
||||
from files.classes import Base
|
||||
from files.helpers.lazy import *
|
||||
|
||||
class Mod(Base):
|
||||
__tablename__ = "mods"
|
||||
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
||||
hole = Column(String, ForeignKey("holes.name"), primary_key=True)
|
||||
created_utc = Column(Integer)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<{self.__class__.__name__}(user_id={self.user_id}, hole={self.hole})>"
|
|
@ -26,10 +26,8 @@ from .alts import Alt
|
|||
from .award import AwardRelationship
|
||||
from .badges import *
|
||||
from .clients import *
|
||||
from .exiles import *
|
||||
from .follows import *
|
||||
from .hats import *
|
||||
from .mod import *
|
||||
from .mod_logs import *
|
||||
from .notifications import Notification
|
||||
from .saves import *
|
||||
|
|
|
@ -12,7 +12,7 @@ from files.classes.mod_logs import ModAction
|
|||
from files.classes.notifications import Notification
|
||||
from files.classes.polls import CommentOption, PostOption
|
||||
from files.classes.award import AwardRelationship
|
||||
from files.classes.exiles import Exile
|
||||
from files.classes.hole_relationship import Exile
|
||||
|
||||
from files.helpers.alerts import send_repeatable_notification, push_notif
|
||||
from files.helpers.config.const import *
|
||||
|
|
Loading…
Reference in New Issue