From 668725266ae17f593441c61af06b8bcf219270ee Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 5 Aug 2023 17:12:25 +0300 Subject: [PATCH] fix prev commit --- files/classes/mod_logs.py | 19 ++++++++++++------- files/classes/sub_logs.py | 9 ++++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py index d56fd8f68..0696d28e2 100644 --- a/files/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -40,10 +40,13 @@ class ModAction(Base): @property def note(self): - if self.kind=="ban_user": - if self.target_post: return f'for post' - if self.target_comment: return f'for comment' - else: return self._note + if self.kind == "ban_user": + if self.target_post_id: + return f'for post' + elif self.target_comment_id: + return f'for comment' + else: + return self._note else: return self._note or "" @@ -57,10 +60,12 @@ class ModAction(Base): @property @lazy def target_link(self): - if self.target_user: return f'@{self.target_user.username}' - elif self.target_post: + if self.target_user_id: + return f'@{self.target_user.username}' + elif self.target_post_id: return censor_slurs(f'{self.target_post.title_html}', None) - elif self.target_comment_id: return f'comment' + elif self.target_comment_id: + return f'comment' @property @lazy diff --git a/files/classes/sub_logs.py b/files/classes/sub_logs.py index f3c412e82..ebd65a509 100644 --- a/files/classes/sub_logs.py +++ b/files/classes/sub_logs.py @@ -25,6 +25,7 @@ class SubAction(Base): user = relationship("User", primaryjoin="User.id==SubAction.user_id") target_user = relationship("User", primaryjoin="User.id==SubAction.target_user_id") target_post = relationship("Post") + target_comment = relationship("Comment") def __init__(self, *args, **kwargs): if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time()) @@ -48,10 +49,12 @@ class SubAction(Base): @property @lazy def target_link(self): - if self.target_user: return f'@{self.target_user.username}' - elif self.target_post: + if self.target_user_id: + return f'@{self.target_user.username}' + elif self.target_post_id: return censor_slurs(f'{self.target_post.title_html}', None) - elif self.target_comment_id: return f'comment' + elif self.target_comment_id: + return f'comment' @property @lazy