Add Mapped types to relationships
parent
7b0632bdc7
commit
6cb4c88b75
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -8,6 +9,9 @@ from files.classes import Base
|
||||||
from files.helpers.config.awards import AWARDS, HOUSE_AWARDS
|
from files.helpers.config.awards import AWARDS, HOUSE_AWARDS
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import Comment, Post, User
|
||||||
|
|
||||||
|
|
||||||
class AwardRelationship(Base):
|
class AwardRelationship(Base):
|
||||||
__tablename__ = "award_relationships"
|
__tablename__ = "award_relationships"
|
||||||
|
@ -22,9 +26,9 @@ class AwardRelationship(Base):
|
||||||
price_paid: Mapped[int] = mapped_column(default = 0)
|
price_paid: Mapped[int] = mapped_column(default = 0)
|
||||||
note: Mapped[str]
|
note: Mapped[str]
|
||||||
|
|
||||||
user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", back_populates="awards")
|
user: Mapped["User"] = relationship(primaryjoin="AwardRelationship.user_id==User.id", back_populates="awards")
|
||||||
post = relationship("Post", primaryjoin="AwardRelationship.post_id==Post.id", back_populates="awards")
|
post: Mapped["Post"] = relationship(primaryjoin="AwardRelationship.post_id==Post.id", back_populates="awards")
|
||||||
comment = relationship("Comment", primaryjoin="AwardRelationship.comment_id==Comment.id", back_populates="awards")
|
comment: Mapped["Comment"] = relationship(primaryjoin="AwardRelationship.comment_id==Comment.id", back_populates="awards")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -8,6 +9,10 @@ from files.classes import Base
|
||||||
from files.helpers.config.const import *
|
from files.helpers.config.const import *
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class BadgeDef(Base):
|
class BadgeDef(Base):
|
||||||
__tablename__ = "badge_defs"
|
__tablename__ = "badge_defs"
|
||||||
|
|
||||||
|
@ -38,8 +43,8 @@ class Badge(Base):
|
||||||
url: Mapped[str]
|
url: Mapped[str]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User", back_populates="badges")
|
user: Mapped["User"] = relationship(back_populates="badges")
|
||||||
badge = relationship("BadgeDef", primaryjoin="Badge.badge_id == BadgeDef.id", lazy="joined", innerjoin=True)
|
badge: Mapped["BadgeDef"] = relationship(primaryjoin="Badge.badge_id == BadgeDef.id", lazy="joined", innerjoin=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs:
|
if "created_utc" not in kwargs:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -8,6 +9,9 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
CASINO_GAME_KINDS = ['blackjack', 'slots', 'roulette']
|
CASINO_GAME_KINDS = ['blackjack', 'slots', 'roulette']
|
||||||
|
|
||||||
class CasinoGame(Base):
|
class CasinoGame(Base):
|
||||||
|
@ -23,7 +27,7 @@ class CasinoGame(Base):
|
||||||
kind: Mapped[str]
|
kind: Mapped[str]
|
||||||
game_state: Mapped[str] = mapped_column(JSON)
|
game_state: Mapped[str] = mapped_column(JSON)
|
||||||
|
|
||||||
user = relationship("User")
|
user: Mapped["User"] = relationship()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs:
|
if "created_utc" not in kwargs:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from flask import g
|
from flask import g
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
|
@ -12,6 +13,10 @@ from files.helpers.lazy import lazy
|
||||||
from .comment import Comment
|
from .comment import Comment
|
||||||
from .post import Post
|
from .post import Post
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class OauthApp(Base):
|
class OauthApp(Base):
|
||||||
__tablename__ = "oauth_apps"
|
__tablename__ = "oauth_apps"
|
||||||
|
|
||||||
|
@ -23,7 +28,7 @@ class OauthApp(Base):
|
||||||
author_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
author_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
author = relationship("User", back_populates="apps")
|
author: Mapped["User"] = relationship(back_populates="apps")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
@ -56,8 +61,8 @@ class ClientAuth(Base):
|
||||||
access_token: Mapped[str]
|
access_token: Mapped[str]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User")
|
user: Mapped["User"] = relationship()
|
||||||
application = relationship("OauthApp")
|
application: Mapped["OauthApp"] = relationship()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import time
|
import time
|
||||||
from math import floor
|
from math import floor
|
||||||
from random import randint
|
from random import randint
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
from urllib.parse import parse_qs, urlencode, urlparse
|
from urllib.parse import parse_qs, urlencode, urlparse
|
||||||
from flask import g
|
from flask import g
|
||||||
|
|
||||||
|
@ -21,6 +22,9 @@ from files.helpers.bleach_body import *
|
||||||
|
|
||||||
from .saves import CommentSaveRelationship
|
from .saves import CommentSaveRelationship
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import AwardRelationship, CasinoGame, CommentOption, CommentReport, OauthApp, Post, User
|
||||||
|
|
||||||
def get_emoji_awards_emojis(obj, v, kind, NSFW_EMOJIS):
|
def get_emoji_awards_emojis(obj, v, kind, NSFW_EMOJIS):
|
||||||
if g.show_nsfw:
|
if g.show_nsfw:
|
||||||
emojis = [x.note for x in obj.awards if x.kind == kind]
|
emojis = [x.note for x in obj.awards if x.kind == kind]
|
||||||
|
@ -216,16 +220,16 @@ class Comment(Base):
|
||||||
else:
|
else:
|
||||||
nsfw = False
|
nsfw = False
|
||||||
|
|
||||||
oauth_app = relationship("OauthApp")
|
oauth_app: Mapped["OauthApp"] = relationship()
|
||||||
post = relationship("Post", back_populates="comments")
|
post: Mapped["Post"] = relationship(back_populates="comments")
|
||||||
author = relationship("User", primaryjoin="User.id==Comment.author_id")
|
author: Mapped["User"] = relationship(primaryjoin="User.id==Comment.author_id")
|
||||||
senttouser = relationship("User", primaryjoin="User.id==Comment.sentto")
|
senttouser: Mapped["User"] = relationship(primaryjoin="User.id==Comment.sentto")
|
||||||
parent_comment = relationship("Comment", remote_side=[id])
|
parent_comment: Mapped["Comment"] = relationship(remote_side=[id])
|
||||||
awards = relationship("AwardRelationship", order_by="AwardRelationship.awarded_utc.desc()", back_populates="comment")
|
awards: Mapped[list["AwardRelationship"]] = relationship(order_by="AwardRelationship.awarded_utc.desc()", back_populates="comment")
|
||||||
reports = relationship("CommentReport", order_by="CommentReport.created_utc")
|
reports: Mapped[list["CommentReport"]] = relationship(order_by="CommentReport.created_utc")
|
||||||
options = relationship("CommentOption", order_by="CommentOption.id")
|
options: Mapped[list["CommentOption"]] = relationship(order_by="CommentOption.id")
|
||||||
casino_game = relationship("CasinoGame")
|
casino_game: Mapped["CasinoGame"] = relationship()
|
||||||
wall_user = relationship("User", primaryjoin="User.id==Comment.wall_user_id")
|
wall_user: Mapped["User"] = relationship(primaryjoin="User.id==Comment.wall_user_id")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs:
|
if "created_utc" not in kwargs:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -6,14 +7,18 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class Follow(Base):
|
class Follow(Base):
|
||||||
__tablename__ = "follows"
|
__tablename__ = "follows"
|
||||||
target_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
target_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User", uselist=False, primaryjoin="User.id==Follow.user_id", back_populates="following")
|
user: Mapped["User"] = relationship(uselist=False, primaryjoin="User.id==Follow.user_id", back_populates="following")
|
||||||
target = relationship("User", uselist=False, primaryjoin="User.id==Follow.target_id", back_populates="followers")
|
target: Mapped["User"] = relationship(uselist=False, primaryjoin="User.id==Follow.target_id", back_populates="followers")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
from sqlalchemy.types import Integer
|
from sqlalchemy.types import Integer
|
||||||
|
@ -9,6 +10,10 @@ from files.helpers.config.const import *
|
||||||
|
|
||||||
from .group_membership import *
|
from .group_membership import *
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class Group(Base):
|
class Group(Base):
|
||||||
__tablename__ = "groups"
|
__tablename__ = "groups"
|
||||||
name: Mapped[str] = mapped_column(primary_key=True)
|
name: Mapped[str] = mapped_column(primary_key=True)
|
||||||
|
@ -17,8 +22,8 @@ class Group(Base):
|
||||||
description: Mapped[str]
|
description: Mapped[str]
|
||||||
description_html: Mapped[str]
|
description_html: Mapped[str]
|
||||||
|
|
||||||
memberships = relationship("GroupMembership", primaryjoin="GroupMembership.group_name==Group.name", order_by="GroupMembership.approved_utc")
|
memberships: Mapped[list["GroupMembership"]] = relationship(primaryjoin="GroupMembership.group_name==Group.name", order_by="GroupMembership.approved_utc")
|
||||||
owner = relationship("User", primaryjoin="Group.owner_id==User.id")
|
owner: Mapped["User"] = relationship(primaryjoin="Group.owner_id==User.id")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -6,6 +7,10 @@ from sqlalchemy.types import Integer, String, Boolean
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes.user import User
|
||||||
|
|
||||||
|
|
||||||
class GroupMembership(Base):
|
class GroupMembership(Base):
|
||||||
__tablename__ = "group_memberships"
|
__tablename__ = "group_memberships"
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
|
@ -14,7 +19,7 @@ class GroupMembership(Base):
|
||||||
approved_utc: Mapped[int]
|
approved_utc: Mapped[int]
|
||||||
is_mod: Mapped[bool] = mapped_column(default=False)
|
is_mod: Mapped[bool] = mapped_column(default=False)
|
||||||
|
|
||||||
user = relationship("User", uselist=False)
|
user: Mapped["User"] = relationship(uselist=False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -9,6 +10,10 @@ from files.classes import Base
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
from files.helpers.slurs_and_profanities import censor_slurs_profanities
|
from files.helpers.slurs_and_profanities import censor_slurs_profanities
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class HatDef(Base):
|
class HatDef(Base):
|
||||||
__tablename__ = "hat_defs"
|
__tablename__ = "hat_defs"
|
||||||
|
|
||||||
|
@ -20,8 +25,8 @@ class HatDef(Base):
|
||||||
submitter_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
submitter_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
author = relationship("User", primaryjoin="HatDef.author_id == User.id", back_populates="designed_hats")
|
author: Mapped["User"] = relationship(primaryjoin="HatDef.author_id == User.id", back_populates="designed_hats")
|
||||||
submitter = relationship("User", primaryjoin="HatDef.submitter_id == User.id")
|
submitter: Mapped["User"] = relationship(primaryjoin="HatDef.submitter_id == User.id")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
@ -53,8 +58,8 @@ class Hat(Base):
|
||||||
equipped: Mapped[bool] = mapped_column(default=False)
|
equipped: Mapped[bool] = mapped_column(default=False)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
hat_def = relationship("HatDef")
|
hat_def: Mapped["HatDef"] = relationship()
|
||||||
owners = relationship("User", back_populates="owned_hats")
|
owners: Mapped[list["User"]] = relationship(back_populates="owned_hats")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -3,7 +3,7 @@ import time
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
from sqlalchemy.ext.mutable import MutableList
|
from sqlalchemy.ext.mutable import MutableList
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import DynamicMapped, Mapped, mapped_column, relationship
|
||||||
from sqlalchemy.dialects.postgresql import ARRAY
|
from sqlalchemy.dialects.postgresql import ARRAY
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
@ -29,9 +29,9 @@ class Hole(Base):
|
||||||
else:
|
else:
|
||||||
snappy_quotes: Mapped[Annotated[str, HOLE_SNAPPY_QUOTES_LENGTH]] = mapped_column(deferred=True)
|
snappy_quotes: Mapped[Annotated[str, HOLE_SNAPPY_QUOTES_LENGTH]] = mapped_column(deferred=True)
|
||||||
|
|
||||||
blocks = relationship("HoleBlock", primaryjoin="HoleBlock.hole==Hole.name")
|
blocks: Mapped[list["HoleBlock"]] = relationship(primaryjoin="HoleBlock.hole==Hole.name")
|
||||||
followers = relationship("HoleFollow", primaryjoin="HoleFollow.hole==Hole.name")
|
followers: Mapped[list["HoleFollow"]] = relationship(primaryjoin="HoleFollow.hole==Hole.name")
|
||||||
stealth_hole_unblocks = relationship("StealthHoleUnblock", lazy="dynamic", primaryjoin="StealthHoleUnblock.hole==Hole.name")
|
stealth_hole_unblocks: DynamicMapped["StealthHoleUnblock"] = relationship(primaryjoin="StealthHoleUnblock.hole==Hole.name")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -11,6 +12,10 @@ from files.helpers.lazy import lazy
|
||||||
from files.helpers.slurs_and_profanities import censor_slurs_profanities
|
from files.helpers.slurs_and_profanities import censor_slurs_profanities
|
||||||
from files.helpers.sorting_and_time import make_age_string
|
from files.helpers.sorting_and_time import make_age_string
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import Comment, Post, User
|
||||||
|
|
||||||
|
|
||||||
class HoleAction(Base):
|
class HoleAction(Base):
|
||||||
__tablename__ = "hole_actions"
|
__tablename__ = "hole_actions"
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
@ -23,10 +28,10 @@ class HoleAction(Base):
|
||||||
_note: Mapped[str]
|
_note: Mapped[str]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User", primaryjoin="User.id==HoleAction.user_id")
|
user: Mapped["User"] = relationship(primaryjoin="User.id==HoleAction.user_id")
|
||||||
target_user = relationship("User", primaryjoin="User.id==HoleAction.target_user_id")
|
target_user: Mapped["User"] = relationship(primaryjoin="User.id==HoleAction.target_user_id")
|
||||||
target_post = relationship("Post")
|
target_post: Mapped["Post"] = relationship()
|
||||||
target_comment = relationship("Comment")
|
target_comment: Mapped["Comment"] = relationship()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, relationship, mapped_column
|
from sqlalchemy.orm import Mapped, relationship, mapped_column
|
||||||
|
@ -6,6 +7,10 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class HoleRelationship(Base):
|
class HoleRelationship(Base):
|
||||||
__tablename__ = NotImplemented
|
__tablename__ = NotImplemented
|
||||||
__abstract__ = True
|
__abstract__ = True
|
||||||
|
@ -36,4 +41,4 @@ class Mod(HoleRelationship):
|
||||||
class Exile(HoleRelationship):
|
class Exile(HoleRelationship):
|
||||||
__tablename__ = "exiles"
|
__tablename__ = "exiles"
|
||||||
exiler_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
exiler_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
||||||
exiler = relationship("User", primaryjoin="User.id==Exile.exiler_id")
|
exiler: Mapped["User"] = relationship(primaryjoin="User.id==Exile.exiler_id")
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -6,6 +7,10 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class IPLog(Base):
|
class IPLog(Base):
|
||||||
__tablename__ = "ip_logs"
|
__tablename__ = "ip_logs"
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
|
@ -13,7 +18,7 @@ class IPLog(Base):
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
last_used: Mapped[int]
|
last_used: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User")
|
user: Mapped["User"] = relationship()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs:
|
if "created_utc" not in kwargs:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -11,6 +12,10 @@ from files.helpers.lazy import lazy
|
||||||
from files.helpers.slurs_and_profanities import censor_slurs_profanities
|
from files.helpers.slurs_and_profanities import censor_slurs_profanities
|
||||||
from files.helpers.sorting_and_time import make_age_string
|
from files.helpers.sorting_and_time import make_age_string
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import Comment, Post, User
|
||||||
|
|
||||||
|
|
||||||
class ModAction(Base):
|
class ModAction(Base):
|
||||||
__tablename__ = "modactions"
|
__tablename__ = "modactions"
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
@ -22,10 +27,10 @@ class ModAction(Base):
|
||||||
_note: Mapped[str]
|
_note: Mapped[str]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User", primaryjoin="User.id==ModAction.user_id")
|
user: Mapped["User"] = relationship(primaryjoin="User.id==ModAction.user_id")
|
||||||
target_user = relationship("User", primaryjoin="User.id==ModAction.target_user_id")
|
target_user: Mapped["User"] = relationship(primaryjoin="User.id==ModAction.target_user_id")
|
||||||
target_post = relationship("Post")
|
target_post: Mapped["Post"] = relationship()
|
||||||
target_comment = relationship("Comment")
|
target_comment: Mapped["Comment"] = relationship()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -6,6 +7,10 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import Comment, User
|
||||||
|
|
||||||
|
|
||||||
class Notification(Base):
|
class Notification(Base):
|
||||||
__tablename__ = "notifications"
|
__tablename__ = "notifications"
|
||||||
|
|
||||||
|
@ -14,8 +19,8 @@ class Notification(Base):
|
||||||
read: Mapped[bool] = mapped_column(default=False)
|
read: Mapped[bool] = mapped_column(default=False)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
comment = relationship("Comment")
|
comment: Mapped["Comment"] = relationship()
|
||||||
user = relationship("User")
|
user: Mapped["User"] = relationship()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -7,6 +8,10 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import Comment, Post, User
|
||||||
|
|
||||||
|
|
||||||
class PostOption(Base):
|
class PostOption(Base):
|
||||||
__tablename__ = "post_options"
|
__tablename__ = "post_options"
|
||||||
|
|
||||||
|
@ -16,8 +21,8 @@ class PostOption(Base):
|
||||||
exclusive: Mapped[int]
|
exclusive: Mapped[int]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
votes = relationship("PostOptionVote")
|
votes: Mapped[list["PostOptionVote"]] = relationship()
|
||||||
parent = relationship("Post", back_populates="options")
|
parent: Mapped["Post"] = relationship(back_populates="options")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
@ -45,7 +50,7 @@ class PostOptionVote(Base):
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
post_id: Mapped[int] = mapped_column(ForeignKey("posts.id"))
|
post_id: Mapped[int] = mapped_column(ForeignKey("posts.id"))
|
||||||
|
|
||||||
user = relationship("User")
|
user: Mapped["User"] = relationship()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
@ -65,8 +70,8 @@ class CommentOption(Base):
|
||||||
exclusive: Mapped[int]
|
exclusive: Mapped[int]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
votes = relationship("CommentOptionVote")
|
votes: Mapped[list["CommentOptionVote"]] = relationship()
|
||||||
parent = relationship("Comment", back_populates="options")
|
parent: Mapped["Comment"] = relationship(back_populates="options")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
@ -94,7 +99,7 @@ class CommentOptionVote(Base):
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
comment_id: Mapped[int] = mapped_column(ForeignKey("comments.id"))
|
comment_id: Mapped[int] = mapped_column(ForeignKey("comments.id"))
|
||||||
|
|
||||||
user = relationship("User")
|
user: Mapped["User"] = relationship()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from flask import g
|
from flask import g
|
||||||
|
|
||||||
|
@ -22,6 +23,10 @@ from .hole import *
|
||||||
from .subscriptions import *
|
from .subscriptions import *
|
||||||
from .saves import SaveRelationship
|
from .saves import SaveRelationship
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import OauthApp, Report
|
||||||
|
|
||||||
|
|
||||||
class Post(Base):
|
class Post(Base):
|
||||||
__tablename__ = "posts"
|
__tablename__ = "posts"
|
||||||
|
|
||||||
|
@ -77,14 +82,14 @@ class Post(Base):
|
||||||
if SITE_NAME == 'WPD':
|
if SITE_NAME == 'WPD':
|
||||||
cw: Mapped[bool] = mapped_column(default=False)
|
cw: Mapped[bool] = mapped_column(default=False)
|
||||||
|
|
||||||
author = relationship("User", primaryjoin="Post.author_id==User.id")
|
author: Mapped["User"] = relationship(primaryjoin="Post.author_id==User.id")
|
||||||
oauth_app = relationship("OauthApp")
|
oauth_app: Mapped["OauthApp"] = relationship()
|
||||||
approved_by = relationship("User", uselist=False, primaryjoin="Post.is_approved==User.id")
|
approved_by: Mapped["User"] = relationship(uselist=False, primaryjoin="Post.is_approved==User.id")
|
||||||
awards = relationship("AwardRelationship", order_by="AwardRelationship.awarded_utc.desc()", back_populates="post")
|
awards: Mapped[list["AwardRelationship"]] = relationship(order_by="AwardRelationship.awarded_utc.desc()", back_populates="post")
|
||||||
reports = relationship("Report", order_by="Report.created_utc")
|
reports: Mapped[list["Report"]] = relationship(order_by="Report.created_utc")
|
||||||
comments = relationship("Comment", primaryjoin="Comment.parent_post==Post.id", back_populates="post")
|
comments: Mapped[list["Comment"]] = relationship(primaryjoin="Comment.parent_post==Post.id", back_populates="post")
|
||||||
hole_obj = relationship("Hole", primaryjoin="foreign(Post.hole)==remote(Hole.name)")
|
hole_obj: Mapped["Hole"] = relationship(primaryjoin="foreign(Post.hole)==remote(Hole.name)")
|
||||||
options = relationship("PostOption", order_by="PostOption.id")
|
options: Mapped[list["PostOption"]] = relationship(order_by="PostOption.id")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs:
|
if "created_utc" not in kwargs:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -8,6 +9,10 @@ from files.classes import Base
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
from files.helpers.slurs_and_profanities import censor_slurs_profanities
|
from files.helpers.slurs_and_profanities import censor_slurs_profanities
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class Report(Base):
|
class Report(Base):
|
||||||
__tablename__ = "reports"
|
__tablename__ = "reports"
|
||||||
|
|
||||||
|
@ -16,7 +21,7 @@ class Report(Base):
|
||||||
reason: Mapped[str]
|
reason: Mapped[str]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User", primaryjoin = "Report.user_id == User.id", uselist = False)
|
user: Mapped["User"] = relationship(primaryjoin = "Report.user_id == User.id", uselist = False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
@ -44,7 +49,7 @@ class CommentReport(Base):
|
||||||
reason: Mapped[str]
|
reason: Mapped[str]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User", primaryjoin = "CommentReport.user_id == User.id", uselist = False)
|
user: Mapped["User"] = relationship(primaryjoin = "CommentReport.user_id == User.id", uselist = False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -6,6 +7,11 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes.comment import Comment
|
||||||
|
from files.classes.post import Post
|
||||||
|
|
||||||
|
|
||||||
class SaveRelationship(Base):
|
class SaveRelationship(Base):
|
||||||
__tablename__ = "save_relationship"
|
__tablename__ = "save_relationship"
|
||||||
|
|
||||||
|
@ -13,7 +19,7 @@ class SaveRelationship(Base):
|
||||||
post_id: Mapped[int] = mapped_column(ForeignKey("posts.id"), primary_key=True)
|
post_id: Mapped[int] = mapped_column(ForeignKey("posts.id"), primary_key=True)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
post = relationship("Post", uselist=False)
|
post: Mapped["Post"] = relationship(uselist=False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
@ -31,7 +37,7 @@ class CommentSaveRelationship(Base):
|
||||||
comment_id: Mapped[int] = mapped_column(ForeignKey("comments.id"), primary_key=True)
|
comment_id: Mapped[int] = mapped_column(ForeignKey("comments.id"), primary_key=True)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
comment = relationship("Comment", uselist=False)
|
comment: Mapped["Comment"] = relationship(uselist=False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -6,14 +7,18 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import Post, User
|
||||||
|
|
||||||
|
|
||||||
class Subscription(Base):
|
class Subscription(Base):
|
||||||
__tablename__ = "subscriptions"
|
__tablename__ = "subscriptions"
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
post_id: Mapped[int] = mapped_column(ForeignKey("posts.id"), primary_key=True)
|
post_id: Mapped[int] = mapped_column(ForeignKey("posts.id"), primary_key=True)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User", uselist=False)
|
user: Mapped["User"] = relationship(uselist=False)
|
||||||
post = relationship("Post", uselist=False)
|
post: Mapped["Post"] = relationship(uselist=False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -3,7 +3,7 @@ from operator import *
|
||||||
|
|
||||||
import pyotp
|
import pyotp
|
||||||
from sqlalchemy import ForeignKey, FetchedValue
|
from sqlalchemy import ForeignKey, FetchedValue
|
||||||
from sqlalchemy.orm import Mapped, Query, aliased, deferred, mapped_column
|
from sqlalchemy.orm import DynamicMapped, Mapped, Query, aliased, deferred, mapped_column
|
||||||
from sqlalchemy.sql import case, func, literal
|
from sqlalchemy.sql import case, func, literal
|
||||||
from sqlalchemy.sql.expression import not_, and_, or_
|
from sqlalchemy.sql.expression import not_, and_, or_
|
||||||
from sqlalchemy.sql.sqltypes import *
|
from sqlalchemy.sql.sqltypes import *
|
||||||
|
@ -175,20 +175,20 @@ class User(Base):
|
||||||
zombie: Mapped[int] = mapped_column(default=0) # > 0 vaxxed; < 0 zombie
|
zombie: Mapped[int] = mapped_column(default=0) # > 0 vaxxed; < 0 zombie
|
||||||
jumpscare: Mapped[int] = mapped_column(default=0)
|
jumpscare: Mapped[int] = mapped_column(default=0)
|
||||||
|
|
||||||
badges = relationship("Badge", order_by="Badge.created_utc", back_populates="user")
|
badges: Mapped[list["Badge"]] = relationship(order_by="Badge.created_utc", back_populates="user")
|
||||||
subscriptions = relationship("Subscription", back_populates="user")
|
subscriptions: Mapped[list["Subscription"]] = relationship(back_populates="user")
|
||||||
following = relationship("Follow", primaryjoin="Follow.user_id==User.id", back_populates="user")
|
following: Mapped[list["Follow"]] = relationship(primaryjoin="Follow.user_id==User.id", back_populates="user")
|
||||||
followers = relationship("Follow", primaryjoin="Follow.target_id==User.id", back_populates="target")
|
followers: Mapped[list["Follow"]] = relationship(primaryjoin="Follow.target_id==User.id", back_populates="target")
|
||||||
blocking = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.user_id", back_populates="user")
|
blocking: DynamicMapped["UserBlock"] = relationship(primaryjoin="User.id==UserBlock.user_id", back_populates="user")
|
||||||
blocked = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.target_id", back_populates="target")
|
blocked: DynamicMapped["UserBlock"] = relationship(primaryjoin="User.id==UserBlock.target_id", back_populates="target")
|
||||||
authorizations = relationship("ClientAuth", back_populates="user")
|
authorizations: Mapped[list["ClientAuth"]] = relationship(back_populates="user")
|
||||||
apps = relationship("OauthApp", back_populates="author")
|
apps: Mapped[list["OauthApp"]] = relationship(back_populates="author")
|
||||||
awards = relationship("AwardRelationship", primaryjoin="User.id==AwardRelationship.user_id", back_populates="user")
|
awards: Mapped[list["AwardRelationship"]] = relationship(primaryjoin="User.id==AwardRelationship.user_id", back_populates="user")
|
||||||
referrals = relationship("User", primaryjoin="User.id==User.referred_by", order_by="User.created_utc")
|
referrals: Mapped[list["User"]] = relationship(primaryjoin="User.id==User.referred_by", order_by="User.created_utc")
|
||||||
designed_hats = relationship("HatDef", primaryjoin="User.id==HatDef.author_id", back_populates="author")
|
designed_hats: Mapped[list["HatDef"]] = relationship(primaryjoin="User.id==HatDef.author_id", back_populates="author")
|
||||||
owned_hats = relationship("Hat", back_populates="owners")
|
owned_hats: Mapped[list["Hat"]] = relationship(back_populates="owners")
|
||||||
hats_equipped = relationship("Hat", lazy="raise", viewonly=True)
|
hats_equipped: Mapped[list["Hat"]] = relationship(lazy="raise", viewonly=True)
|
||||||
hole_mods = relationship("Mod", primaryjoin="User.id == Mod.user_id", lazy="raise")
|
hole_mods: Mapped[list["Mod"]] = relationship(primaryjoin="User.id == Mod.user_id", lazy="raise")
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -6,14 +7,18 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class UserBlock(Base):
|
class UserBlock(Base):
|
||||||
__tablename__ = "userblocks"
|
__tablename__ = "userblocks"
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
target_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
target_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User", primaryjoin="User.id==UserBlock.user_id", back_populates="blocking")
|
user: Mapped["User"] = relationship(primaryjoin="User.id==UserBlock.user_id", back_populates="blocking")
|
||||||
target = relationship("User", primaryjoin="User.id==UserBlock.target_id", back_populates="blocked")
|
target: Mapped["User"] = relationship(primaryjoin="User.id==UserBlock.target_id", back_populates="blocked")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -6,14 +7,18 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class UserMute(Base):
|
class UserMute(Base):
|
||||||
__tablename__ = "usermutes"
|
__tablename__ = "usermutes"
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
target_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
target_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User", primaryjoin="User.id==UserMute.user_id")
|
user: Mapped["User"] = relationship(primaryjoin="User.id==UserMute.user_id")
|
||||||
target = relationship("User", primaryjoin="User.id==UserMute.target_id")
|
target: Mapped["User"] = relationship(primaryjoin="User.id==UserMute.target_id")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -8,6 +9,10 @@ from files.classes import Base
|
||||||
from files.helpers.lazy import *
|
from files.helpers.lazy import *
|
||||||
from files.helpers.sorting_and_time import make_age_string
|
from files.helpers.sorting_and_time import make_age_string
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class ViewerRelationship(Base):
|
class ViewerRelationship(Base):
|
||||||
__tablename__ = "viewers"
|
__tablename__ = "viewers"
|
||||||
|
|
||||||
|
@ -16,7 +21,7 @@ class ViewerRelationship(Base):
|
||||||
last_view_utc: Mapped[int]
|
last_view_utc: Mapped[int]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
viewer = relationship("User", primaryjoin="ViewerRelationship.viewer_id == User.id")
|
viewer: Mapped["User"] = relationship(primaryjoin="ViewerRelationship.viewer_id == User.id")
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
@ -7,6 +8,10 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from files.classes import User
|
||||||
|
|
||||||
|
|
||||||
class Vote(Base):
|
class Vote(Base):
|
||||||
__tablename__ = "votes"
|
__tablename__ = "votes"
|
||||||
|
|
||||||
|
@ -17,7 +22,7 @@ class Vote(Base):
|
||||||
coins: Mapped[int] = mapped_column(default=1)
|
coins: Mapped[int] = mapped_column(default=1)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User")
|
user: Mapped["User"] = relationship()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
@ -47,7 +52,7 @@ class CommentVote(Base):
|
||||||
coins: Mapped[int] = mapped_column(default=1)
|
coins: Mapped[int] = mapped_column(default=1)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user = relationship("User")
|
user: Mapped["User"] = relationship()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
Loading…
Reference in New Issue