sub relationship class (#456)

* sub relationships

* abstract = True

* fix

* fix spelling mistake
master
justcool393 2022-11-15 08:05:42 -08:00 committed by GitHub
parent 532ebd3ac8
commit adf22b494a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 65 deletions

View File

@ -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 *

View File

@ -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()

View File

@ -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})>"

View File

@ -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})>"

View File

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

View File

@ -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})>"

View File

@ -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 *