forked from MarseyWorld/MarseyWorld
fsdfs
parent
2691177365
commit
fc4b89bfbc
|
@ -65,10 +65,10 @@ class AwardRelationship(Base):
|
|||
comment_id = Column(Integer, ForeignKey("comments.id"), default=None)
|
||||
kind = Column(String(20))
|
||||
|
||||
user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id")
|
||||
user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", viewonly=True)
|
||||
|
||||
post = relationship("Submission", primaryjoin="AwardRelationship.submission_id==Submission.id")
|
||||
comment = relationship("Comment", primaryjoin="AwardRelationship.comment_id==Comment.id")
|
||||
post = relationship("Submission", primaryjoin="AwardRelationship.submission_id==Submission.id", viewonly=True)
|
||||
comment = relationship("Comment", primaryjoin="AwardRelationship.comment_id==Comment.id", viewonly=True)
|
||||
|
||||
|
||||
@property
|
||||
|
|
|
@ -48,7 +48,7 @@ class Badge(Base):
|
|||
badge_id = Column(Integer, ForeignKey("badge_defs.id"))
|
||||
description = Column(String(64))
|
||||
url = Column(String(256))
|
||||
badge = relationship("BadgeDef")
|
||||
badge = relationship("BadgeDef", viewonly=True)
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class OauthApp(Base):
|
|||
redirect_uri = Column(String(4096))
|
||||
description = Column(String(256))
|
||||
author_id = Column(Integer, ForeignKey("users.id"))
|
||||
author = relationship("User")
|
||||
author = relationship("User", viewonly=True)
|
||||
|
||||
def __repr__(self): return f"<OauthApp(id={self.id})>"
|
||||
|
||||
|
@ -68,8 +68,8 @@ class ClientAuth(Base):
|
|||
oauth_client = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||
access_token = Column(String(128))
|
||||
user_id = Column(Integer, ForeignKey("users.id"))
|
||||
user = relationship("User")
|
||||
application = relationship("OauthApp")
|
||||
user = relationship("User", viewonly=True)
|
||||
application = relationship("OauthApp", viewonly=True)
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -28,7 +28,7 @@ class Comment(Base):
|
|||
__tablename__ = "comments"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
comment_aux = relationship("CommentAux", uselist=False, primaryjoin="Comment.id==CommentAux.id")
|
||||
comment_aux = relationship("CommentAux", uselist=False, primaryjoin="Comment.id==CommentAux.id", viewonly=True)
|
||||
author_id = Column(Integer, ForeignKey("users.id"))
|
||||
parent_submission = Column(Integer, ForeignKey("submissions.id"))
|
||||
# this column is foreignkeyed to comment(id) but we can't do that yet as
|
||||
|
@ -50,19 +50,19 @@ class Comment(Base):
|
|||
sentto=Column(Integer)
|
||||
|
||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||
oauth_app=relationship("OauthApp")
|
||||
oauth_app = relationship("OauthApp", viewonly=True)
|
||||
|
||||
post = relationship("Submission")
|
||||
flags = relationship("CommentFlag", lazy="dynamic")
|
||||
author = relationship("User", primaryjoin="User.id==Comment.author_id")
|
||||
post = relationship("Submission", viewonly=True)
|
||||
flags = relationship("CommentFlag", lazy="dynamic", viewonly=True)
|
||||
author = relationship("User", primaryjoin="User.id==Comment.author_id", viewonly=True)
|
||||
|
||||
upvotes = Column(Integer, default=1)
|
||||
downvotes = Column(Integer, default=0)
|
||||
|
||||
parent_comment = relationship("Comment", remote_side=[id])
|
||||
child_comments = relationship("Comment", remote_side=[parent_comment_id])
|
||||
parent_comment = relationship("Comment", remote_side=[id], viewonly=True)
|
||||
child_comments = relationship("Comment", remote_side=[parent_comment_id], viewonly=True)
|
||||
|
||||
awards = relationship("AwardRelationship")
|
||||
awards = relationship("AwardRelationship", viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
|
@ -408,8 +408,8 @@ class Notification(Base):
|
|||
blocksender = Column(Integer)
|
||||
unblocksender = Column(Integer)
|
||||
|
||||
comment = relationship("Comment")
|
||||
user=relationship("User")
|
||||
comment = relationship("Comment", viewonly=True)
|
||||
user = relationship("User", viewonly=True)
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class Flag(Base):
|
|||
user_id = Column(Integer, ForeignKey("users.id"))
|
||||
reason = Column(String(100))
|
||||
|
||||
user = relationship("User", primaryjoin = "Flag.user_id == User.id", uselist = False)
|
||||
user = relationship("User", primaryjoin = "Flag.user_id == User.id", uselist = False, viewonly=True)
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
|
@ -39,7 +39,7 @@ class CommentFlag(Base):
|
|||
comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||
reason = Column(String(100))
|
||||
|
||||
user = relationship("User", primaryjoin = "CommentFlag.user_id == User.id", uselist = False)
|
||||
user = relationship("User", primaryjoin = "CommentFlag.user_id == User.id", uselist = False, viewonly=True)
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ class ModAction(Base):
|
|||
_note=Column(String(256), default=None)
|
||||
created_utc = Column(Integer, default=0)
|
||||
|
||||
user = relationship("User", primaryjoin="User.id==ModAction.user_id")
|
||||
target_user = relationship("User", primaryjoin="User.id==ModAction.target_user_id")
|
||||
target_post = relationship("Submission")
|
||||
user = relationship("User", primaryjoin="User.id==ModAction.user_id", viewonly=True)
|
||||
target_user = relationship("User", primaryjoin="User.id==ModAction.target_user_id", viewonly=True)
|
||||
target_post = relationship("Submission", viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "created_utc" not in kwargs:
|
||||
|
|
|
@ -33,7 +33,7 @@ class Submission(Base):
|
|||
__tablename__ = "submissions"
|
||||
|
||||
id = Column(BigInteger, primary_key=True)
|
||||
submission_aux = relationship("SubmissionAux", uselist=False, primaryjoin="Submission.id==SubmissionAux.id")
|
||||
submission_aux = relationship("SubmissionAux", uselist=False, primaryjoin="Submission.id==SubmissionAux.id", viewonly=True)
|
||||
author_id = Column(BigInteger, ForeignKey("users.id"))
|
||||
edited_utc = Column(BigInteger, default=0)
|
||||
created_utc = Column(BigInteger, default=0)
|
||||
|
@ -51,11 +51,11 @@ class Submission(Base):
|
|||
private = Column(Boolean, default=False)
|
||||
club = Column(Boolean, default=False)
|
||||
comment_count = Column(Integer, default=0)
|
||||
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id")
|
||||
flags = relationship("Flag", lazy="dynamic")
|
||||
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id", viewonly=True)
|
||||
flags = relationship("Flag", lazy="dynamic", viewonly=True)
|
||||
is_approved = Column(Integer, ForeignKey("users.id"), default=0)
|
||||
over_18 = Column(Boolean, default=False)
|
||||
author = relationship("User", primaryjoin="Submission.author_id==User.id")
|
||||
author = relationship("User", primaryjoin="Submission.author_id==User.id", viewonly=True)
|
||||
is_pinned = Column(Boolean, default=False)
|
||||
is_bot = Column(Boolean, default=False)
|
||||
|
||||
|
@ -63,11 +63,11 @@ class Submission(Base):
|
|||
downvotes = Column(Integer, default=0)
|
||||
|
||||
app_id=Column(Integer, ForeignKey("oauth_apps.id"))
|
||||
oauth_app=relationship("OauthApp")
|
||||
oauth_app = relationship("OauthApp", viewonly=True)
|
||||
|
||||
approved_by = relationship("User", uselist=False, primaryjoin="Submission.is_approved==User.id")
|
||||
approved_by = relationship("User", uselist=False, primaryjoin="Submission.is_approved==User.id", viewonly=True)
|
||||
|
||||
awards = relationship("AwardRelationship")
|
||||
awards = relationship("AwardRelationship", viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ class Subscription(Base):
|
|||
user_id = Column(BigInteger, ForeignKey("users.id"))
|
||||
submission_id = Column(BigInteger, default=0)
|
||||
|
||||
user = relationship("User", uselist=False)
|
||||
user = relationship("User", uselist=False, viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -24,8 +24,8 @@ class Follow(Base):
|
|||
user_id = Column(BigInteger, ForeignKey("users.id"))
|
||||
target_id = Column(BigInteger, ForeignKey("users.id"))
|
||||
|
||||
user = relationship("User", uselist=False, primaryjoin="User.id==Follow.user_id")
|
||||
target = relationship("User", primaryjoin="User.id==Follow.target_id")
|
||||
user = relationship("User", uselist=False, primaryjoin="User.id==Follow.user_id", viewonly=True)
|
||||
target = relationship("User", primaryjoin="User.id==Follow.target_id", viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -123,12 +123,12 @@ class User(Base):
|
|||
oldreddit = Column(Boolean)
|
||||
nitter = Column(Boolean)
|
||||
controversial = Column(Boolean, default=False)
|
||||
submissions = relationship("Submission", lazy="dynamic", primaryjoin="Submission.author_id==User.id")
|
||||
comments = relationship("Comment", lazy="dynamic", primaryjoin="Comment.author_id==User.id")
|
||||
submissions = relationship("Submission", lazy="dynamic", primaryjoin="Submission.author_id==User.id", viewonly=True)
|
||||
comments = relationship("Comment", lazy="dynamic", primaryjoin="Comment.author_id==User.id", viewonly=True)
|
||||
bio = Column(String)
|
||||
bio_html = Column(String)
|
||||
badges = relationship("Badge", lazy="dynamic")
|
||||
notifications = relationship("Notification", lazy="dynamic")
|
||||
badges = relationship("Badge", lazy="dynamic", viewonly=True)
|
||||
notifications = relationship("Notification", lazy="dynamic", viewonly=True)
|
||||
|
||||
is_banned = Column(Integer, default=0)
|
||||
unban_utc = Column(Integer, default=0)
|
||||
|
@ -151,24 +151,24 @@ class User(Base):
|
|||
discord_id = Column(String(64))
|
||||
ban_evade = Column(Integer, default=0)
|
||||
original_username = deferred(Column(String(255)))
|
||||
subscriptions = relationship("Subscription")
|
||||
subscriptions = relationship("Subscription", viewonly=True)
|
||||
|
||||
following = relationship("Follow", primaryjoin="Follow.user_id==User.id")
|
||||
followers = relationship("Follow", primaryjoin="Follow.target_id==User.id")
|
||||
following = relationship("Follow", primaryjoin="Follow.user_id==User.id", viewonly=True)
|
||||
followers = relationship("Follow", primaryjoin="Follow.target_id==User.id", viewonly=True)
|
||||
|
||||
viewers = relationship("ViewerRelationship", primaryjoin="User.id == ViewerRelationship.user_id")
|
||||
viewers = relationship("ViewerRelationship", primaryjoin="User.id == ViewerRelationship.user_id", viewonly=True)
|
||||
|
||||
blocking = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.user_id")
|
||||
blocked = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.target_id")
|
||||
blocking = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.user_id", viewonly=True)
|
||||
blocked = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.target_id", viewonly=True)
|
||||
|
||||
_applications = relationship("OauthApp", lazy="dynamic")
|
||||
authorizations = relationship("ClientAuth", lazy="dynamic")
|
||||
_applications = relationship("OauthApp", lazy="dynamic", viewonly=True)
|
||||
authorizations = relationship("ClientAuth", lazy="dynamic", viewonly=True)
|
||||
|
||||
awards = relationship("AwardRelationship", lazy="dynamic", primaryjoin="User.id==AwardRelationship.user_id")
|
||||
awards = relationship("AwardRelationship", lazy="dynamic", primaryjoin="User.id==AwardRelationship.user_id", viewonly=True)
|
||||
|
||||
referred_by = Column(Integer, ForeignKey("users.id"))
|
||||
|
||||
referrals = relationship("User")
|
||||
referrals = relationship("User", viewonly=True)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
|
@ -623,7 +623,7 @@ class ViewerRelationship(Base):
|
|||
viewer_id = Column(Integer, ForeignKey('users.id'))
|
||||
last_view_utc = Column(Integer)
|
||||
|
||||
viewer = relationship("User", primaryjoin="ViewerRelationship.viewer_id == User.id")
|
||||
viewer = relationship("User", primaryjoin="ViewerRelationship.viewer_id == User.id", viewonly=True)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ class UserBlock(Base):
|
|||
user_id = Column(Integer, ForeignKey("users.id"))
|
||||
target_id = Column(Integer, ForeignKey("users.id"))
|
||||
|
||||
user = relationship("User", primaryjoin="User.id==UserBlock.user_id")
|
||||
target = relationship("User", primaryjoin="User.id==UserBlock.target_id")
|
||||
user = relationship("User", primaryjoin="User.id==UserBlock.user_id", viewonly=True)
|
||||
target = relationship("User", primaryjoin="User.id==UserBlock.target_id", viewonly=True)
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ class Vote(Base):
|
|||
submission_id = Column(Integer, ForeignKey("submissions.id"))
|
||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||
|
||||
user = relationship("User", lazy="subquery")
|
||||
post = relationship("Submission", lazy="subquery")
|
||||
user = relationship("User", lazy="subquery", viewonly=True)
|
||||
post = relationship("Submission", lazy="subquery", viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
|
@ -54,8 +54,8 @@ class CommentVote(Base):
|
|||
comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||
|
||||
user = relationship("User", lazy="subquery")
|
||||
comment = relationship("Comment", lazy="subquery")
|
||||
user = relationship("User", lazy="subquery", viewonly=True)
|
||||
comment = relationship("Comment", lazy="subquery", viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
|
|
Loading…
Reference in New Issue