From c36fd9400b027c02ae984d4d90d0e8d476109a7e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 31 Jul 2021 15:55:49 +0200 Subject: [PATCH] fdfd --- drama/classes/comment.py | 17 ++++++++++------- drama/classes/submission.py | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drama/classes/comment.py b/drama/classes/comment.py index 4bdb65d77..3e2f907c6 100644 --- a/drama/classes/comment.py +++ b/drama/classes/comment.py @@ -1,9 +1,10 @@ from flask import * from sqlalchemy import * from sqlalchemy.orm import relationship, deferred -from .mix_ins import * from drama.helpers.lazy import lazy from drama.__main__ import Base +from .mix_ins import * +from .flags import CommentFlag class CommentAux(Base): @@ -50,7 +51,7 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): oauth_app=relationship("OauthApp") post = relationship("Submission") - flags = relationship("CommentFlag", backref="comment") + flags = relationship("CommentFlag", lazy="dynamic") votes = relationship( "CommentVote", lazy="dynamic", @@ -288,14 +289,16 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): @property @lazy - def is_op(self): - return self.author_id==self.post.author_id + def is_op(self): return self.author_id==self.post.author_id @property @lazy - def active_flags(self): - return len(self.flags) - + def active_flags(self): return len(self.flags) + + @property + @lazy + def ordered_flags(self): return self.flags.order_by(CommentFlag.created_utc).all() + class Notification(Base): diff --git a/drama/classes/submission.py b/drama/classes/submission.py index 45b96e787..27a0c61ac 100644 --- a/drama/classes/submission.py +++ b/drama/classes/submission.py @@ -3,9 +3,9 @@ from sqlalchemy import * from sqlalchemy.orm import relationship, deferred import re, random from urllib.parse import urlparse -from .mix_ins import * from drama.helpers.lazy import lazy from drama.__main__ import Base +from .mix_ins import * from .flags import * class SubmissionAux(Base):