forked from MarseyWorld/MarseyWorld
sub relationship class (#456)
* sub relationships * abstract = True * fix * fix spelling mistakemaster
parent
532ebd3ac8
commit
adf22b494a
|
@ -20,9 +20,7 @@ from .domains import *
|
|||
from .subscriptions import *
|
||||
from .mod_logs import *
|
||||
from .award import *
|
||||
from .sub_block import *
|
||||
from .sub_subscription import *
|
||||
from .sub_join import *
|
||||
from .sub_relationship import *
|
||||
from .saves import *
|
||||
from .views import *
|
||||
from .notifications import *
|
||||
|
|
|
@ -8,8 +8,7 @@ from sqlalchemy.sql.sqltypes import *
|
|||
from files.classes import Base
|
||||
from files.helpers.lazy import lazy
|
||||
|
||||
from .sub_block import *
|
||||
from .sub_subscription import *
|
||||
from .sub_relationship import *
|
||||
|
||||
SITE_NAME = environ.get("SITE_NAME", '').strip()
|
||||
SITE = environ.get("SITE", '').strip()
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
import time
|
||||
|
||||
from sqlalchemy import Column, ForeignKey
|
||||
from sqlalchemy.sql.sqltypes import *
|
||||
|
||||
from files.classes import Base
|
||||
|
||||
class SubBlock(Base):
|
||||
__tablename__ = "sub_blocks"
|
||||
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
||||
sub = Column(String(20), ForeignKey("subs.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"<SubBlock(user_id={self.user_id}, sub={self.sub})>"
|
|
@ -1,19 +0,0 @@
|
|||
import time
|
||||
|
||||
from sqlalchemy import Column, ForeignKey
|
||||
from sqlalchemy.sql.sqltypes import *
|
||||
|
||||
from files.classes import Base
|
||||
|
||||
class SubJoin(Base):
|
||||
__tablename__ = "sub_joins"
|
||||
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
||||
sub = Column(String(20), ForeignKey("subs.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"<SubJoin(user_id={self.user_id}, sub={self.sub})>"
|
|
@ -0,0 +1,39 @@
|
|||
import time
|
||||
|
||||
from sqlalchemy import Column, ForeignKey
|
||||
from sqlalchemy.orm import declared_attr
|
||||
from sqlalchemy.sql.sqltypes import *
|
||||
|
||||
from files.classes import Base
|
||||
|
||||
class SubRelationship(Base):
|
||||
__tablename__ = NotImplemented
|
||||
__abstract__ = True
|
||||
|
||||
@declared_attr
|
||||
def user_id(self):
|
||||
return Column(Integer, ForeignKey("users.id"), primary_key=True)
|
||||
|
||||
@declared_attr
|
||||
def sub(self):
|
||||
return Column(String(20), ForeignKey("subs.name"), primary_key=True)
|
||||
|
||||
@declared_attr
|
||||
def created_utc(self):
|
||||
return 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}, sub={self.sub})>"
|
||||
|
||||
class SubJoin(SubRelationship):
|
||||
__tablename__ = "sub_joins"
|
||||
|
||||
class SubBlock(SubRelationship):
|
||||
__tablename__ = "sub_blocks"
|
||||
|
||||
class SubSubscription(SubRelationship):
|
||||
__tablename__ = "sub_subscriptions"
|
|
@ -1,19 +0,0 @@
|
|||
import time
|
||||
|
||||
from sqlalchemy import Column, ForeignKey
|
||||
from sqlalchemy.sql.sqltypes import *
|
||||
|
||||
from files.classes import Base
|
||||
|
||||
class SubSubscription(Base):
|
||||
__tablename__ = "sub_subscriptions"
|
||||
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
||||
sub = Column(String(20), ForeignKey("subs.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"<SubSubscription(user_id={self.user_id}, sub={self.sub})>"
|
|
@ -27,10 +27,8 @@ from .mod import *
|
|||
from .mod_logs import *
|
||||
from .notifications import Notification
|
||||
from .saves import *
|
||||
from .sub_block import *
|
||||
from .sub_join import *
|
||||
from .sub_relationship import *
|
||||
from .sub_logs import *
|
||||
from .sub_subscription import *
|
||||
from .subscriptions import *
|
||||
from .userblock import *
|
||||
|
||||
|
|
Loading…
Reference in New Issue