fix prev commit

master
Aevann 2023-08-05 17:12:25 +03:00
parent 747a880cdb
commit 668725266a
2 changed files with 18 additions and 10 deletions

View File

@ -40,10 +40,13 @@ class ModAction(Base):
@property
def note(self):
if self.kind=="ban_user":
if self.target_post: return f'for <a href="{self.target_post.permalink}">post</a>'
if self.target_comment: return f'for <a href="{self.target_comment.permalink}">comment</a>'
else: return self._note
if self.kind == "ban_user":
if self.target_post_id:
return f'for <a href="{self.target_post.permalink}">post</a>'
elif self.target_comment_id:
return f'for <a href="{self.target_comment.permalink}">comment</a>'
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'<a href="{self.target_user.url}">@{self.target_user.username}</a>'
elif self.target_post:
if self.target_user_id:
return f'<a href="{self.target_user.url}">@{self.target_user.username}</a>'
elif self.target_post_id:
return censor_slurs(f'<a href="{self.target_post.permalink}">{self.target_post.title_html}</a>', None)
elif self.target_comment_id: return f'<a href="/comment/{self.target_comment_id}#context">comment</a>'
elif self.target_comment_id:
return f'<a href="{self.target_comment.permalink}">comment</a>'
@property
@lazy

View File

@ -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'<a href="{self.target_user.url}">@{self.target_user.username}</a>'
elif self.target_post:
if self.target_user_id:
return f'<a href="{self.target_user.url}">@{self.target_user.username}</a>'
elif self.target_post_id:
return censor_slurs(f'<a href="{self.target_post.permalink}">{self.target_post.title_html}</a>', None)
elif self.target_comment_id: return f'<a href="/comment/{self.target_comment_id}#context">comment</a>'
elif self.target_comment_id:
return f'<a href="{self.target_comment.permalink}">comment</a>'
@property
@lazy