Apply Optional to nullable columns
parent
6cb4c88b75
commit
778c2272f5
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
@ -12,7 +13,7 @@ class Alt(Base):
|
||||||
user1: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user1: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
user2: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user2: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
is_manual: Mapped[bool] = mapped_column(default=False)
|
is_manual: Mapped[bool] = mapped_column(default=False)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
|
|
||||||
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,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -18,13 +18,13 @@ class AwardRelationship(Base):
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
||||||
post_id: Mapped[int] = mapped_column(ForeignKey("posts.id"))
|
post_id: Mapped[Optional[int]] = mapped_column(ForeignKey("posts.id"))
|
||||||
comment_id: Mapped[int] = mapped_column(ForeignKey("comments.id"))
|
comment_id: Mapped[Optional[int]] = mapped_column(ForeignKey("comments.id"))
|
||||||
kind: Mapped[str]
|
kind: Mapped[str]
|
||||||
awarded_utc: Mapped[int]
|
awarded_utc: Mapped[Optional[int]]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
price_paid: Mapped[int] = mapped_column(default = 0)
|
price_paid: Mapped[int] = mapped_column(default = 0)
|
||||||
note: Mapped[str]
|
note: Mapped[Optional[str]]
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(primaryjoin="AwardRelationship.user_id==User.id", back_populates="awards")
|
user: Mapped["User"] = relationship(primaryjoin="AwardRelationship.user_id==User.id", back_populates="awards")
|
||||||
post: Mapped["Post"] = relationship(primaryjoin="AwardRelationship.post_id==Post.id", back_populates="awards")
|
post: Mapped["Post"] = relationship(primaryjoin="AwardRelationship.post_id==Post.id", back_populates="awards")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -18,7 +18,7 @@ class BadgeDef(Base):
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||||
name: Mapped[str]
|
name: Mapped[str]
|
||||||
description: Mapped[str]
|
description: Mapped[Optional[str]]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -39,8 +39,8 @@ class Badge(Base):
|
||||||
|
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'), primary_key=True)
|
||||||
badge_id: Mapped[int] = mapped_column(ForeignKey('badge_defs.id'), primary_key=True)
|
badge_id: Mapped[int] = mapped_column(ForeignKey('badge_defs.id'), primary_key=True)
|
||||||
description: Mapped[str]
|
description: Mapped[Optional[str]]
|
||||||
url: Mapped[str]
|
url: Mapped[Optional[str]]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(back_populates="badges")
|
user: Mapped["User"] = relationship(back_populates="badges")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Annotated, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from flask import g
|
from flask import g
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
|
@ -21,12 +21,12 @@ class OauthApp(Base):
|
||||||
__tablename__ = "oauth_apps"
|
__tablename__ = "oauth_apps"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
client_id: Mapped[str]
|
client_id: Mapped[Optional[Annotated[str, 64]]]
|
||||||
app_name: Mapped[str]
|
app_name: Mapped[str]
|
||||||
redirect_uri: Mapped[str]
|
redirect_uri: Mapped[str]
|
||||||
description: Mapped[str]
|
description: Mapped[str]
|
||||||
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[Optional[int]]
|
||||||
|
|
||||||
author: Mapped["User"] = relationship(back_populates="apps")
|
author: Mapped["User"] = relationship(back_populates="apps")
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class ClientAuth(Base):
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
oauth_client: Mapped[int] = mapped_column(ForeignKey("oauth_apps.id"), primary_key=True)
|
oauth_client: Mapped[int] = mapped_column(ForeignKey("oauth_apps.id"), primary_key=True)
|
||||||
access_token: Mapped[str]
|
access_token: Mapped[str]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
|
|
||||||
user: Mapped["User"] = relationship()
|
user: Mapped["User"] = relationship()
|
||||||
application: Mapped["OauthApp"] = relationship()
|
application: Mapped["OauthApp"] = relationship()
|
||||||
|
|
|
@ -1,7 +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 typing import Optional, 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
|
||||||
|
|
||||||
|
@ -178,38 +178,38 @@ class Comment(Base):
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
author_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
author_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
||||||
parent_post: Mapped[int] = mapped_column(ForeignKey("posts.id"))
|
parent_post: Mapped[Optional[int]] = mapped_column(ForeignKey("posts.id"))
|
||||||
wall_user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
wall_user_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
edited_utc: Mapped[int] = mapped_column(default=0)
|
edited_utc: Mapped[int] = mapped_column(default=0)
|
||||||
is_banned: Mapped[bool] = mapped_column(default=False)
|
is_banned: Mapped[bool] = mapped_column(default=False)
|
||||||
ghost: Mapped[bool] = mapped_column(default=False)
|
ghost: Mapped[bool] = mapped_column(default=False)
|
||||||
bannedfor: Mapped[str]
|
bannedfor: Mapped[Optional[str]]
|
||||||
chuddedfor: Mapped[str]
|
chuddedfor: Mapped[Optional[str]]
|
||||||
distinguished: Mapped[bool] = mapped_column(default=False)
|
distinguished: Mapped[bool] = mapped_column(default=False)
|
||||||
deleted_utc: Mapped[int] = mapped_column(default=0)
|
deleted_utc: Mapped[int] = mapped_column(default=0)
|
||||||
is_approved: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
is_approved: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
level: Mapped[int] = mapped_column(default=1)
|
level: Mapped[int] = mapped_column(default=1)
|
||||||
parent_comment_id: Mapped[int] = mapped_column(ForeignKey("comments.id"))
|
parent_comment_id: Mapped[Optional[int]] = mapped_column(ForeignKey("comments.id"))
|
||||||
top_comment_id: Mapped[int]
|
top_comment_id: Mapped[Optional[int]]
|
||||||
is_bot: Mapped[bool] = mapped_column(default=False)
|
is_bot: Mapped[bool] = mapped_column(default=False)
|
||||||
stickied: Mapped[str]
|
stickied: Mapped[Optional[str]]
|
||||||
stickied_utc: Mapped[int]
|
stickied_utc: Mapped[Optional[int]]
|
||||||
num_of_pinned_children: Mapped[int] = mapped_column(default=0)
|
num_of_pinned_children: Mapped[int] = mapped_column(default=0)
|
||||||
sentto: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
sentto: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
app_id: Mapped[int] = mapped_column(ForeignKey("oauth_apps.id"))
|
app_id: Mapped[Optional[int]] = mapped_column(ForeignKey("oauth_apps.id"))
|
||||||
upvotes: Mapped[int] = mapped_column(default=1)
|
upvotes: Mapped[int] = mapped_column(default=1)
|
||||||
downvotes: Mapped[int] = mapped_column(default=0)
|
downvotes: Mapped[int] = mapped_column(default=0)
|
||||||
realupvotes: Mapped[int] = mapped_column(default=1)
|
realupvotes: Mapped[int] = mapped_column(default=1)
|
||||||
body: Mapped[str]
|
body: Mapped[Optional[str]]
|
||||||
body_html: Mapped[str]
|
body_html: Mapped[Optional[str]]
|
||||||
body_ts: Mapped[str] = mapped_column(TSVECTOR(), server_default=FetchedValue())
|
body_ts: Mapped[str] = mapped_column(TSVECTOR(), server_default=FetchedValue())
|
||||||
ban_reason: Mapped[str]
|
ban_reason: Mapped[Optional[str]]
|
||||||
treasure_amount: Mapped[str]
|
treasure_amount: Mapped[Optional[str]]
|
||||||
slots_result: Mapped[str]
|
slots_result: Mapped[Optional[str]]
|
||||||
ping_cost: Mapped[int] = mapped_column(default=0)
|
ping_cost: Mapped[int] = mapped_column(default=0)
|
||||||
blackjack_result: Mapped[str]
|
blackjack_result: Mapped[Optional[str]]
|
||||||
casino_game_id: Mapped[int] = mapped_column(ForeignKey("casino_games.id"))
|
casino_game_id: Mapped[Optional[int]] = mapped_column(ForeignKey("casino_games.id"))
|
||||||
chudded: Mapped[bool] = mapped_column(default=False)
|
chudded: Mapped[bool] = mapped_column(default=False)
|
||||||
rainbowed: Mapped[bool] = mapped_column(default=False)
|
rainbowed: Mapped[bool] = mapped_column(default=False)
|
||||||
queened: Mapped[bool] = mapped_column(default=False)
|
queened: Mapped[bool] = mapped_column(default=False)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
from sqlalchemy.sql.sqltypes import *
|
from sqlalchemy.sql.sqltypes import *
|
||||||
|
@ -9,7 +10,7 @@ class BannedDomain(Base):
|
||||||
__tablename__ = "banneddomains"
|
__tablename__ = "banneddomains"
|
||||||
domain: Mapped[str] = mapped_column(primary_key=True)
|
domain: Mapped[str] = mapped_column(primary_key=True)
|
||||||
reason: Mapped[str]
|
reason: Mapped[str]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
|
|
||||||
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 Optional
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
@ -14,7 +15,7 @@ class Emoji(Base):
|
||||||
author_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
author_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
||||||
tags: Mapped[str]
|
tags: Mapped[str]
|
||||||
count: Mapped[int] = mapped_column(default=0)
|
count: Mapped[int] = mapped_column(default=0)
|
||||||
submitter_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
submitter_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
nsfw: Mapped[bool] = mapped_column(default=False)
|
nsfw: Mapped[bool] = mapped_column(default=False)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -18,9 +18,9 @@ class Group(Base):
|
||||||
__tablename__ = "groups"
|
__tablename__ = "groups"
|
||||||
name: Mapped[str] = mapped_column(primary_key=True)
|
name: Mapped[str] = mapped_column(primary_key=True)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
owner_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
owner_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
description: Mapped[str]
|
description: Mapped[Optional[str]]
|
||||||
description_html: Mapped[str]
|
description_html: Mapped[Optional[str]]
|
||||||
|
|
||||||
memberships: Mapped[list["GroupMembership"]] = relationship(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: Mapped["User"] = relationship(primaryjoin="Group.owner_id==User.id")
|
owner: Mapped["User"] = relationship(primaryjoin="Group.owner_id==User.id")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -16,7 +16,7 @@ class GroupMembership(Base):
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
group_name: Mapped[str] = mapped_column(ForeignKey("groups.name"), primary_key=True)
|
group_name: Mapped[str] = mapped_column(ForeignKey("groups.name"), primary_key=True)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
approved_utc: Mapped[int]
|
approved_utc: Mapped[Optional[int]]
|
||||||
is_mod: Mapped[bool] = mapped_column(default=False)
|
is_mod: Mapped[bool] = mapped_column(default=False)
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(uselist=False)
|
user: Mapped["User"] = relationship(uselist=False)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -22,7 +22,7 @@ class HatDef(Base):
|
||||||
description: Mapped[str]
|
description: Mapped[str]
|
||||||
author_id: Mapped[int] = mapped_column(ForeignKey('users.id'))
|
author_id: Mapped[int] = mapped_column(ForeignKey('users.id'))
|
||||||
price: Mapped[int]
|
price: Mapped[int]
|
||||||
submitter_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
submitter_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
author: Mapped["User"] = relationship(primaryjoin="HatDef.author_id == User.id", back_populates="designed_hats")
|
author: Mapped["User"] = relationship(primaryjoin="HatDef.author_id == User.id", back_populates="designed_hats")
|
||||||
|
@ -55,8 +55,8 @@ class Hat(Base):
|
||||||
|
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'), primary_key=True)
|
||||||
hat_id: Mapped[int] = mapped_column(ForeignKey('hat_defs.id'), primary_key=True)
|
hat_id: Mapped[int] = mapped_column(ForeignKey('hat_defs.id'), primary_key=True)
|
||||||
equipped: Mapped[bool] = mapped_column(default=False)
|
equipped: Mapped[Optional[bool]] = mapped_column(default=False)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
|
|
||||||
hat_def: Mapped["HatDef"] = relationship()
|
hat_def: Mapped["HatDef"] = relationship()
|
||||||
owners: Mapped[list["User"]] = relationship(back_populates="owned_hats")
|
owners: Mapped[list["User"]] = relationship(back_populates="owned_hats")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from typing import Annotated
|
from typing import Annotated, Optional
|
||||||
|
|
||||||
from sqlalchemy.ext.mutable import MutableList
|
from sqlalchemy.ext.mutable import MutableList
|
||||||
from sqlalchemy.orm import DynamicMapped, Mapped, mapped_column, relationship
|
from sqlalchemy.orm import DynamicMapped, Mapped, mapped_column, relationship
|
||||||
|
@ -15,19 +15,19 @@ from .hole_relationship import *
|
||||||
class Hole(Base):
|
class Hole(Base):
|
||||||
__tablename__ = "holes"
|
__tablename__ = "holes"
|
||||||
name: Mapped[str] = mapped_column(primary_key=True)
|
name: Mapped[str] = mapped_column(primary_key=True)
|
||||||
sidebar: Mapped[str]
|
sidebar: Mapped[Optional[str]]
|
||||||
sidebar_html: Mapped[str]
|
sidebar_html: Mapped[Optional[str]]
|
||||||
sidebarurls: Mapped[list[str]] = mapped_column(MutableList.as_mutable(ARRAY(String)), default=MutableList([]))
|
sidebarurls: Mapped[list[str]] = mapped_column(MutableList.as_mutable(ARRAY(String)), default=MutableList([]))
|
||||||
bannerurls: Mapped[list[str]] = mapped_column(MutableList.as_mutable(ARRAY(String)), default=MutableList([]))
|
bannerurls: Mapped[list[str]] = mapped_column(MutableList.as_mutable(ARRAY(String)), default=MutableList([]))
|
||||||
marseyurl: Mapped[str]
|
marseyurl: Mapped[Optional[str]]
|
||||||
css: Mapped[str] = mapped_column(deferred=True)
|
css: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
stealth: Mapped[bool] = mapped_column(default=False)
|
stealth: Mapped[Optional[bool]] = mapped_column(default=False)
|
||||||
public_use: Mapped[bool] = mapped_column(default=False)
|
public_use: Mapped[bool] = mapped_column(default=False)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
if SITE_NAME == 'WPD':
|
if SITE_NAME == 'WPD':
|
||||||
snappy_quotes = None
|
snappy_quotes = None
|
||||||
else:
|
else:
|
||||||
snappy_quotes: Mapped[Annotated[str, HOLE_SNAPPY_QUOTES_LENGTH]] = mapped_column(deferred=True)
|
snappy_quotes: Mapped[Optional[Annotated[str, HOLE_SNAPPY_QUOTES_LENGTH]]] = mapped_column(deferred=True)
|
||||||
|
|
||||||
blocks: Mapped[list["HoleBlock"]] = relationship(primaryjoin="HoleBlock.hole==Hole.name")
|
blocks: Mapped[list["HoleBlock"]] = relationship(primaryjoin="HoleBlock.hole==Hole.name")
|
||||||
followers: Mapped[list["HoleFollow"]] = relationship(primaryjoin="HoleFollow.hole==Hole.name")
|
followers: Mapped[list["HoleFollow"]] = relationship(primaryjoin="HoleFollow.hole==Hole.name")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -20,12 +20,12 @@ 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)
|
||||||
hole: Mapped[str] = mapped_column(ForeignKey("holes.name"))
|
hole: Mapped[str] = mapped_column(ForeignKey("holes.name"))
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
user_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
kind: Mapped[str]
|
kind: Mapped[Optional[str]]
|
||||||
target_user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
target_user_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
target_post_id: Mapped[int] = mapped_column(ForeignKey("posts.id"))
|
target_post_id: Mapped[Optional[int]] = mapped_column(ForeignKey("posts.id"))
|
||||||
target_comment_id: Mapped[int] = mapped_column(ForeignKey("comments.id"))
|
target_comment_id: Mapped[Optional[int]] = mapped_column(ForeignKey("comments.id"))
|
||||||
_note: Mapped[str]
|
_note: Mapped[Optional[str]]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(primaryjoin="User.id==HoleAction.user_id")
|
user: Mapped["User"] = relationship(primaryjoin="User.id==HoleAction.user_id")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -17,7 +17,7 @@ class HoleRelationship(Base):
|
||||||
|
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
hole: Mapped[str] = mapped_column(ForeignKey("holes.name"), primary_key=True)
|
hole: Mapped[str] = mapped_column(ForeignKey("holes.name"), primary_key=True)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
|
|
||||||
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 Optional
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
@ -16,8 +17,8 @@ class Lottery(Base):
|
||||||
ends_at: Mapped[int]
|
ends_at: Mapped[int]
|
||||||
prize: Mapped[int] = mapped_column(default=0)
|
prize: Mapped[int] = mapped_column(default=0)
|
||||||
tickets_sold: Mapped[int] = mapped_column(default=0)
|
tickets_sold: Mapped[int] = mapped_column(default=0)
|
||||||
winner_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
winner_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
|
|
||||||
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,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -19,12 +19,12 @@ if TYPE_CHECKING:
|
||||||
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)
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
user_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
kind: Mapped[str]
|
kind: Mapped[Optional[str]]
|
||||||
target_user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
target_user_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
target_post_id: Mapped[int] = mapped_column(ForeignKey("posts.id"))
|
target_post_id: Mapped[Optional[int]] = mapped_column(ForeignKey("posts.id"))
|
||||||
target_comment_id: Mapped[int] = mapped_column(ForeignKey("comments.id"))
|
target_comment_id: Mapped[Optional[int]] = mapped_column(ForeignKey("comments.id"))
|
||||||
_note: Mapped[str]
|
_note: Mapped[Optional[str]]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(primaryjoin="User.id==ModAction.user_id")
|
user: Mapped["User"] = relationship(primaryjoin="User.id==ModAction.user_id")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import time
|
import time
|
||||||
from flask import g, abort
|
from flask import g, abort
|
||||||
import requests
|
import requests
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
@ -19,7 +20,7 @@ class Orgy(Base):
|
||||||
data: Mapped[str]
|
data: Mapped[str]
|
||||||
title: Mapped[str]
|
title: Mapped[str]
|
||||||
start_utc: Mapped[int]
|
start_utc: Mapped[int]
|
||||||
end_utc: Mapped[int]
|
end_utc: Mapped[Optional[int]]
|
||||||
started: Mapped[bool] = mapped_column(default=False)
|
started: Mapped[bool] = mapped_column(default=False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -19,7 +19,7 @@ class PostOption(Base):
|
||||||
parent_id: Mapped[int] = mapped_column(ForeignKey("posts.id"))
|
parent_id: Mapped[int] = mapped_column(ForeignKey("posts.id"))
|
||||||
body_html: Mapped[str] = mapped_column(Text)
|
body_html: Mapped[str] = mapped_column(Text)
|
||||||
exclusive: Mapped[int]
|
exclusive: Mapped[int]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
|
|
||||||
votes: Mapped[list["PostOptionVote"]] = relationship()
|
votes: Mapped[list["PostOptionVote"]] = relationship()
|
||||||
parent: Mapped["Post"] = relationship(back_populates="options")
|
parent: Mapped["Post"] = relationship(back_populates="options")
|
||||||
|
@ -48,7 +48,7 @@ class PostOptionVote(Base):
|
||||||
option_id: Mapped[int] = mapped_column(ForeignKey("post_options.id"), primary_key=True)
|
option_id: Mapped[int] = mapped_column(ForeignKey("post_options.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]
|
||||||
post_id: Mapped[int] = mapped_column(ForeignKey("posts.id"))
|
post_id: Mapped[Optional[int]] = mapped_column(ForeignKey("posts.id"))
|
||||||
|
|
||||||
user: Mapped["User"] = relationship()
|
user: Mapped["User"] = relationship()
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class CommentOption(Base):
|
||||||
parent_id: Mapped[int] = mapped_column(ForeignKey("comments.id"))
|
parent_id: Mapped[int] = mapped_column(ForeignKey("comments.id"))
|
||||||
body_html: Mapped[str] = mapped_column(Text)
|
body_html: Mapped[str] = mapped_column(Text)
|
||||||
exclusive: Mapped[int]
|
exclusive: Mapped[int]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
|
|
||||||
votes: Mapped[list["CommentOptionVote"]] = relationship()
|
votes: Mapped[list["CommentOptionVote"]] = relationship()
|
||||||
parent: Mapped["Comment"] = relationship(back_populates="options")
|
parent: Mapped["Comment"] = relationship(back_populates="options")
|
||||||
|
@ -97,7 +97,7 @@ class CommentOptionVote(Base):
|
||||||
option_id: Mapped[int] = mapped_column(ForeignKey("comment_options.id"), primary_key=True)
|
option_id: Mapped[int] = mapped_column(ForeignKey("comment_options.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]
|
||||||
comment_id: Mapped[int] = mapped_column(ForeignKey("comments.id"))
|
comment_id: Mapped[Optional[int]] = mapped_column(ForeignKey("comments.id"))
|
||||||
|
|
||||||
user: Mapped["User"] = relationship()
|
user: Mapped["User"] = relationship()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from flask import g
|
from flask import g
|
||||||
|
|
||||||
|
@ -34,38 +34,38 @@ class Post(Base):
|
||||||
author_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
author_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
||||||
edited_utc: Mapped[int] = mapped_column(default=0)
|
edited_utc: Mapped[int] = mapped_column(default=0)
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
thumburl: Mapped[str]
|
thumburl: Mapped[Optional[str]]
|
||||||
posterurl: Mapped[str]
|
posterurl: Mapped[Optional[str]]
|
||||||
is_banned: Mapped[bool] = mapped_column(default=False)
|
is_banned: Mapped[bool] = mapped_column(default=False)
|
||||||
bannedfor: Mapped[str]
|
bannedfor: Mapped[Optional[str]]
|
||||||
chuddedfor: Mapped[str]
|
chuddedfor: Mapped[Optional[str]]
|
||||||
ghost: Mapped[bool] = mapped_column(default=False)
|
ghost: Mapped[bool] = mapped_column(default=False)
|
||||||
effortpost: Mapped[bool] = mapped_column(default=False)
|
effortpost: Mapped[bool] = mapped_column(default=False)
|
||||||
views: Mapped[int] = mapped_column(default=0)
|
views: Mapped[int] = mapped_column(default=0)
|
||||||
deleted_utc: Mapped[int] = mapped_column(default=0)
|
deleted_utc: Mapped[int] = mapped_column(default=0)
|
||||||
distinguished: Mapped[bool] = mapped_column(default=False)
|
distinguished: Mapped[bool] = mapped_column(default=False)
|
||||||
stickied: Mapped[str]
|
stickied: Mapped[Optional[str]]
|
||||||
stickied_utc: Mapped[int]
|
stickied_utc: Mapped[Optional[int]]
|
||||||
hole_pinned: Mapped[str]
|
hole_pinned: Mapped[Optional[str]]
|
||||||
hole: Mapped[str] = mapped_column(ForeignKey("holes.name"))
|
hole: Mapped[Optional[str]] = mapped_column(ForeignKey("holes.name"))
|
||||||
is_pinned: Mapped[bool] = mapped_column(default=False)
|
is_pinned: Mapped[bool] = mapped_column(default=False)
|
||||||
private: Mapped[bool] = mapped_column(default=False)
|
private: Mapped[bool] = mapped_column(default=False)
|
||||||
comment_count: Mapped[int] = mapped_column(default=0)
|
comment_count: Mapped[int] = mapped_column(default=0)
|
||||||
is_approved: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
is_approved: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
is_bot: Mapped[bool] = mapped_column(default=False)
|
is_bot: Mapped[bool] = mapped_column(default=False)
|
||||||
upvotes: Mapped[int] = mapped_column(default=1)
|
upvotes: Mapped[int] = mapped_column(default=1)
|
||||||
downvotes: Mapped[int] = mapped_column(default=0)
|
downvotes: Mapped[int] = mapped_column(default=0)
|
||||||
realupvotes: Mapped[int] = mapped_column(default=1)
|
realupvotes: Mapped[Optional[int]] = mapped_column(default=1)
|
||||||
app_id: Mapped[int] = mapped_column(ForeignKey("oauth_apps.id"))
|
app_id: Mapped[Optional[int]] = mapped_column(ForeignKey("oauth_apps.id"))
|
||||||
title: Mapped[str]
|
title: Mapped[str]
|
||||||
title_html: Mapped[str]
|
title_html: Mapped[str]
|
||||||
url: Mapped[str]
|
url: Mapped[Optional[str]]
|
||||||
body: Mapped[str]
|
body: Mapped[Optional[str]]
|
||||||
body_html: Mapped[str]
|
body_html: Mapped[Optional[str]]
|
||||||
flair: Mapped[str]
|
flair: Mapped[Optional[str]]
|
||||||
ban_reason: Mapped[str]
|
ban_reason: Mapped[Optional[str]]
|
||||||
embed: Mapped[str]
|
embed: Mapped[Optional[str]]
|
||||||
new: Mapped[bool]
|
new: Mapped[Optional[bool]]
|
||||||
notify: Mapped[bool]
|
notify: Mapped[bool]
|
||||||
chudded: Mapped[bool] = mapped_column(default=False)
|
chudded: Mapped[bool] = mapped_column(default=False)
|
||||||
rainbowed: Mapped[bool] = mapped_column(default=False)
|
rainbowed: Mapped[bool] = mapped_column(default=False)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -18,7 +18,7 @@ class Report(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)
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
reason: Mapped[str]
|
reason: Mapped[Optional[str]]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(primaryjoin = "Report.user_id == User.id", uselist = False)
|
user: Mapped["User"] = relationship(primaryjoin = "Report.user_id == User.id", uselist = False)
|
||||||
|
@ -46,7 +46,7 @@ class CommentReport(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)
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
reason: Mapped[str]
|
reason: Mapped[Optional[str]]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[int]
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(primaryjoin = "CommentReport.user_id == User.id", uselist = False)
|
user: Mapped["User"] = relationship(primaryjoin = "CommentReport.user_id == User.id", uselist = False)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -17,7 +17,7 @@ class SaveRelationship(Base):
|
||||||
|
|
||||||
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[Optional[int]]
|
||||||
|
|
||||||
post: Mapped["Post"] = relationship(uselist=False)
|
post: Mapped["Post"] = relationship(uselist=False)
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class CommentSaveRelationship(Base):
|
||||||
|
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
||||||
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[Optional[int]]
|
||||||
|
|
||||||
comment: Mapped["Comment"] = relationship(uselist=False)
|
comment: Mapped["Comment"] = relationship(uselist=False)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -15,7 +15,7 @@ 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[Optional[int]]
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(uselist=False)
|
user: Mapped["User"] = relationship(uselist=False)
|
||||||
post: Mapped["Post"] = relationship(uselist=False)
|
post: Mapped["Post"] = relationship(uselist=False)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
from sqlalchemy.sql.sqltypes import *
|
from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
|
@ -10,7 +12,7 @@ class Transaction(Base):
|
||||||
type: Mapped[str]
|
type: Mapped[str]
|
||||||
amount: Mapped[int]
|
amount: Mapped[int]
|
||||||
email: Mapped[str]
|
email: Mapped[str]
|
||||||
claimed: Mapped[bool]
|
claimed: Mapped[Optional[bool]]
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<{self.__class__.__name__}(id={self.id})>"
|
return f"<{self.__class__.__name__}(id={self.id})>"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import random
|
import random
|
||||||
from operator import *
|
from operator import *
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import pyotp
|
import pyotp
|
||||||
from sqlalchemy import ForeignKey, FetchedValue
|
from sqlalchemy import ForeignKey, FetchedValue
|
||||||
|
@ -52,30 +53,30 @@ class User(Base):
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
username: Mapped[str]
|
username: Mapped[str]
|
||||||
namecolor: Mapped[str] = mapped_column(default=DEFAULT_COLOR)
|
namecolor: Mapped[str] = mapped_column(default=DEFAULT_COLOR)
|
||||||
background: Mapped[str]
|
background: Mapped[Optional[str]]
|
||||||
profile_background: Mapped[str]
|
profile_background: Mapped[Optional[str]]
|
||||||
flair: Mapped[str] = mapped_column(deferred=True)
|
flair: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
flair_html: Mapped[str]
|
flair_html: Mapped[Optional[str]]
|
||||||
flaircolor: Mapped[str] = mapped_column(default=DEFAULT_COLOR)
|
flaircolor: Mapped[str] = mapped_column(default=DEFAULT_COLOR)
|
||||||
theme: Mapped[str] = mapped_column(default=DEFAULT_THEME)
|
theme: Mapped[str] = mapped_column(default=DEFAULT_THEME)
|
||||||
themecolor: Mapped[str] = mapped_column(default=DEFAULT_COLOR)
|
themecolor: Mapped[str] = mapped_column(default=DEFAULT_COLOR)
|
||||||
song: Mapped[str]
|
song: Mapped[Optional[str]]
|
||||||
highres: Mapped[str]
|
highres: Mapped[Optional[str]]
|
||||||
profileurl: Mapped[str]
|
profileurl: Mapped[Optional[str]]
|
||||||
bannerurl: Mapped[str]
|
bannerurl: Mapped[Optional[str]]
|
||||||
house: Mapped[str] = mapped_column(default='')
|
house: Mapped[Optional[str]] = mapped_column(default='')
|
||||||
old_house: Mapped[str] = mapped_column(default='')
|
old_house: Mapped[Optional[str]] = mapped_column(default='')
|
||||||
patron: Mapped[int] = mapped_column(default=0)
|
patron: Mapped[int] = mapped_column(default=0)
|
||||||
patron_utc: Mapped[int] = mapped_column(default=0)
|
patron_utc: Mapped[int] = mapped_column(default=0)
|
||||||
verified: Mapped[str]
|
verified: Mapped[Optional[str]]
|
||||||
verifiedcolor: Mapped[str]
|
verifiedcolor: Mapped[Optional[str]]
|
||||||
hieroglyphs: Mapped[int] = mapped_column(default=0)
|
hieroglyphs: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
rehab: Mapped[int] = mapped_column(default=0)
|
rehab: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
longpost: Mapped[int] = mapped_column(default=0)
|
longpost: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
bird: Mapped[int] = mapped_column(default=0)
|
bird: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
email: Mapped[str] = mapped_column(deferred=True)
|
email: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
css: Mapped[str]
|
css: Mapped[Optional[str]]
|
||||||
profilecss: Mapped[str] = mapped_column(deferred=True)
|
profilecss: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
passhash: Mapped[str] = mapped_column(deferred=True)
|
passhash: Mapped[str] = mapped_column(deferred=True)
|
||||||
post_count: Mapped[int] = mapped_column(default=0)
|
post_count: Mapped[int] = mapped_column(default=0)
|
||||||
comment_count: Mapped[int] = mapped_column(default=0)
|
comment_count: Mapped[int] = mapped_column(default=0)
|
||||||
|
@ -87,49 +88,49 @@ class User(Base):
|
||||||
coins_spent_on_hats: Mapped[int] = mapped_column(default=0)
|
coins_spent_on_hats: Mapped[int] = mapped_column(default=0)
|
||||||
lootboxes_bought: Mapped[int] = mapped_column(default=0)
|
lootboxes_bought: Mapped[int] = mapped_column(default=0)
|
||||||
chud: Mapped[int] = mapped_column(default=0)
|
chud: Mapped[int] = mapped_column(default=0)
|
||||||
queen: Mapped[int] = mapped_column(default=0)
|
queen: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
chud_phrase: Mapped[str]
|
chud_phrase: Mapped[Optional[str]]
|
||||||
email_verified: Mapped[bool] = mapped_column(default=False)
|
email_verified: Mapped[bool] = mapped_column(default=False)
|
||||||
shadowbanned: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
shadowbanned: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
chudded_by: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
chudded_by: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
slurreplacer: Mapped[int] = mapped_column(default=1)
|
slurreplacer: Mapped[int] = mapped_column(default=1)
|
||||||
profanityreplacer: Mapped[int] = mapped_column(default=1)
|
profanityreplacer: Mapped[int] = mapped_column(default=1)
|
||||||
flairchanged: Mapped[int] = mapped_column(default=0)
|
flairchanged: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
namechanged: Mapped[int] = mapped_column(default=0)
|
namechanged: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
newtab: Mapped[bool] = mapped_column(default=False)
|
newtab: Mapped[bool] = mapped_column(default=False)
|
||||||
newtabexternal: Mapped[bool] = mapped_column(default=True)
|
newtabexternal: Mapped[bool] = mapped_column(default=True)
|
||||||
frontsize: Mapped[int] = mapped_column(default=25)
|
frontsize: Mapped[int] = mapped_column(default=25)
|
||||||
bio: Mapped[str] = mapped_column(deferred=True)
|
bio: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
bio_html: Mapped[str]
|
bio_html: Mapped[Optional[str]]
|
||||||
sig: Mapped[str] = mapped_column(deferred=True)
|
sig: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
sig_html: Mapped[str]
|
sig_html: Mapped[Optional[str]]
|
||||||
show_sigs: Mapped[bool] = mapped_column(default=True)
|
show_sigs: Mapped[bool] = mapped_column(default=True)
|
||||||
progressivestack: Mapped[int] = mapped_column(default=0)
|
progressivestack: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
deflector: Mapped[int] = mapped_column(default=0)
|
deflector: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
friends: Mapped[str] = mapped_column(deferred=True)
|
friends: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
friends_html: Mapped[str] = mapped_column(deferred=True)
|
friends_html: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
enemies: Mapped[str] = mapped_column(deferred=True)
|
enemies: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
enemies_html: Mapped[str] = mapped_column(deferred=True)
|
enemies_html: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
is_banned: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
is_banned: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
unban_utc: Mapped[int]
|
unban_utc: Mapped[Optional[int]]
|
||||||
ban_reason: Mapped[str] = mapped_column(deferred=True)
|
ban_reason: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
shadowban_reason: Mapped[str] = mapped_column(deferred=True)
|
shadowban_reason: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
is_muted: Mapped[bool] = mapped_column(default=False)
|
is_muted: Mapped[bool] = mapped_column(default=False)
|
||||||
login_nonce: Mapped[int] = mapped_column(default=0)
|
login_nonce: Mapped[int] = mapped_column(default=0)
|
||||||
coins: Mapped[int] = mapped_column(default=DEFAULT_COINS)
|
coins: Mapped[int] = mapped_column(default=DEFAULT_COINS)
|
||||||
truescore: Mapped[int] = mapped_column(default=0)
|
truescore: Mapped[int] = mapped_column(default=0)
|
||||||
marseybux: Mapped[int] = mapped_column(default=DEFAULT_MARSEYBUX)
|
marseybux: Mapped[int] = mapped_column(default=DEFAULT_MARSEYBUX)
|
||||||
mfa_secret: Mapped[str] = mapped_column(deferred=True)
|
mfa_secret: Mapped[Optional[str]] = mapped_column(deferred=True)
|
||||||
is_private: Mapped[bool] = mapped_column(default=False)
|
is_private: Mapped[bool] = mapped_column(default=False)
|
||||||
stored_subscriber_count: Mapped[int] = mapped_column(default=0)
|
stored_subscriber_count: Mapped[int] = mapped_column(default=0)
|
||||||
defaultsortingcomments: Mapped[str] = mapped_column(default="hot")
|
defaultsortingcomments: Mapped[str] = mapped_column(default="hot")
|
||||||
defaultsorting: Mapped[str] = mapped_column(default="hot")
|
defaultsorting: Mapped[str] = mapped_column(default="hot")
|
||||||
defaulttime: Mapped[str] = mapped_column(default=DEFAULT_TIME_FILTER)
|
defaulttime: Mapped[str] = mapped_column(default=DEFAULT_TIME_FILTER)
|
||||||
custom_filter_list: Mapped[str]
|
custom_filter_list: Mapped[Optional[str]]
|
||||||
original_username: Mapped[str]
|
original_username: Mapped[Optional[str]]
|
||||||
extra_username: Mapped[str]
|
extra_username: Mapped[Optional[str]]
|
||||||
prelock_username: Mapped[str]
|
prelock_username: Mapped[Optional[str]]
|
||||||
referred_by: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
referred_by: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
currently_held_lottery_tickets: Mapped[int] = mapped_column(default=0)
|
currently_held_lottery_tickets: Mapped[int] = mapped_column(default=0)
|
||||||
total_held_lottery_tickets: Mapped[int] = mapped_column(default=0)
|
total_held_lottery_tickets: Mapped[int] = mapped_column(default=0)
|
||||||
total_lottery_winnings: Mapped[int] = mapped_column(default=0)
|
total_lottery_winnings: Mapped[int] = mapped_column(default=0)
|
||||||
|
@ -137,15 +138,15 @@ class User(Base):
|
||||||
last_viewed_post_notifs: Mapped[int] = mapped_column(default=0)
|
last_viewed_post_notifs: Mapped[int] = mapped_column(default=0)
|
||||||
last_viewed_log_notifs: Mapped[int] = mapped_column(default=0)
|
last_viewed_log_notifs: Mapped[int] = mapped_column(default=0)
|
||||||
last_viewed_offsite_notifs: Mapped[int] = mapped_column(default=0)
|
last_viewed_offsite_notifs: Mapped[int] = mapped_column(default=0)
|
||||||
bite: Mapped[int] = mapped_column(default=0)
|
bite: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
owoify: Mapped[int] = mapped_column(default=0)
|
owoify: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
sharpen: Mapped[int] = mapped_column(default=0)
|
sharpen: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
marsify: Mapped[int] = mapped_column(default=0)
|
marsify: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
rainbow: Mapped[int] = mapped_column(default=0)
|
rainbow: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
spider: Mapped[int] = mapped_column(default=0)
|
spider: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
lifetimedonated: Mapped[int] = mapped_column(default=0)
|
lifetimedonated: Mapped[int] = mapped_column(default=0)
|
||||||
lifetimedonated_visible: Mapped[bool] = mapped_column(default=False)
|
lifetimedonated_visible: Mapped[bool] = mapped_column(default=False)
|
||||||
blacklisted_by: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
blacklisted_by: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
||||||
grinch: Mapped[bool] = mapped_column(default=SITE_NAME != 'rDrama') #don't put in an if condition, it will cause an error bc it has a not-null constraint
|
grinch: Mapped[bool] = mapped_column(default=SITE_NAME != 'rDrama') #don't put in an if condition, it will cause an error bc it has a not-null constraint
|
||||||
group_creation_notifs: Mapped[bool] = mapped_column(default=False)
|
group_creation_notifs: Mapped[bool] = mapped_column(default=False)
|
||||||
effortpost_notifs: Mapped[bool] = mapped_column(default=False)
|
effortpost_notifs: Mapped[bool] = mapped_column(default=False)
|
||||||
|
@ -166,7 +167,7 @@ class User(Base):
|
||||||
controversial: Mapped[bool] = mapped_column(default=False)
|
controversial: Mapped[bool] = mapped_column(default=False)
|
||||||
reddit: Mapped[str] = mapped_column(default='old.reddit.com')
|
reddit: Mapped[str] = mapped_column(default='old.reddit.com')
|
||||||
pronouns: Mapped[str] = mapped_column(default='they/them')
|
pronouns: Mapped[str] = mapped_column(default='they/them')
|
||||||
earlylife: Mapped[int] = mapped_column(default=0)
|
earlylife: Mapped[Optional[int]] = mapped_column(default=0)
|
||||||
hole_creation_notifs: Mapped[bool] = mapped_column(default=True)
|
hole_creation_notifs: Mapped[bool] = mapped_column(default=True)
|
||||||
hidevotedon = False
|
hidevotedon = False
|
||||||
hide_cw = False
|
hide_cw = False
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -15,7 +15,7 @@ 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[Optional[int]]
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(primaryjoin="User.id==UserBlock.user_id", back_populates="blocking")
|
user: Mapped["User"] = relationship(primaryjoin="User.id==UserBlock.user_id", back_populates="blocking")
|
||||||
target: Mapped["User"] = relationship(primaryjoin="User.id==UserBlock.target_id", back_populates="blocked")
|
target: Mapped["User"] = relationship(primaryjoin="User.id==UserBlock.target_id", back_populates="blocked")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -15,7 +15,7 @@ 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[Optional[int]]
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(primaryjoin="User.id==UserMute.user_id")
|
user: Mapped["User"] = relationship(primaryjoin="User.id==UserMute.user_id")
|
||||||
target: Mapped["User"] = relationship(primaryjoin="User.id==UserMute.target_id")
|
target: Mapped["User"] = relationship(primaryjoin="User.id==UserMute.target_id")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import Optional, 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
|
||||||
|
@ -19,7 +19,7 @@ class ViewerRelationship(Base):
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'), primary_key=True)
|
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'), primary_key=True)
|
||||||
viewer_id: Mapped[int] = mapped_column(ForeignKey('users.id'), primary_key=True)
|
viewer_id: Mapped[int] = mapped_column(ForeignKey('users.id'), primary_key=True)
|
||||||
last_view_utc: Mapped[int]
|
last_view_utc: Mapped[int]
|
||||||
created_utc: Mapped[int]
|
created_utc: Mapped[Optional[int]]
|
||||||
|
|
||||||
viewer: Mapped["User"] = relationship(primaryjoin="ViewerRelationship.viewer_id == User.id")
|
viewer: Mapped["User"] = relationship(primaryjoin="ViewerRelationship.viewer_id == User.id")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue