From 6df9369d60735eff1355a9f313a9c7aba512fa9d Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 17 Jan 2022 23:26:03 +0200 Subject: [PATCH] fdsfds --- files/classes/comment.py | 6 ++++++ files/helpers/const.py | 2 +- files/routes/awards.py | 4 ++++ files/routes/comments.py | 2 +- files/templates/comments.html | 32 ++++++++++++++++++-------------- files/templates/submission.html | 16 ++++++++-------- 6 files changed, 38 insertions(+), 24 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 412d0d1fd5..60aad3240c 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -225,6 +225,12 @@ class Comment(Base): def shortlink(self): return f"/comment/{self.id}#context" + @property + @lazy + def author_name(self): + if self.post and (self.award_count('ghosts') or self.post.award_count('ghosts')): return '👻' + else: return self.author.username + @property @lazy def permalink(self): diff --git a/files/helpers/const.py b/files/helpers/const.py index cbfa61e79a..fd43407af9 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -548,7 +548,7 @@ AWARDS = { "ghosts": { "kind": "ghosts", "title": "Ghosts", - "description": "???", + "description": "Hides the usernames of everyone in the thread", "icon": "fas fa-ghost", "color": "text-white", "price": 200 diff --git a/files/routes/awards.py b/files/routes/awards.py index 6a4ed52d27..6798845aa5 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -207,6 +207,8 @@ def award_post(pid, v): if not post: return {"error": "That post doesn't exist."}, 404 + if kind == "ghosts" and post.distinguish_level: return {"error": "You can't use the ghosts award on distinguished posts."}, 403 + post_award.submission_id = post.id g.db.add(post_award) @@ -405,6 +407,8 @@ def award_comment(cid, v): if not c: return {"error": "That comment doesn't exist."}, 404 + if kind == "ghosts" and c.distinguish_level: return {"error": "You can't use the ghosts award on distinguished comments."}, 403 + comment_award.comment_id = c.id g.db.add(comment_award) diff --git a/files/routes/comments.py b/files/routes/comments.py index 7a8218f272..158e07a708 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -126,7 +126,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): else: if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html" else: template = "submission.html" - return render_template(template, v=v, p=post, sort=sort, linked_comment=comment, comment_info=comment_info, render_replies=True) + return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True) @app.post("/comment") diff --git a/files/templates/comments.html b/files/templates/comments.html index 2e3e98f602..3d4e9d5356 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -97,7 +97,7 @@
{% if standalone and c.over_18 %}+18 {% endif %} - {% if c.is_banned %}removed by @{{c.ban_reason}}{% elif c.deleted_utc %}Deleted by author{% elif c.is_blocking %}You are blocking @{{c.author.username}}{% endif %} + {% if c.is_banned %}removed by @{{c.ban_reason}}{% elif c.deleted_utc %}Deleted by author{% elif c.is_blocking %}You are blocking @{{c.author_name}}{% endif %}
@@ -178,9 +178,9 @@ {% set isreply = False %} {% endif %} -
+
{% if not isreply %} - + {% endif %}
@@ -215,10 +215,14 @@ {% if c.author.verified %} {% endif %} - @{{c.author.username}}'s profile picture{{c.author.username}} - {% if c.author.customtitle %}  {% if c.author.quadrant %}{{c.author.quadrant}} quadrant{% endif %}{{c.author.customtitle | safe}}{% endif %} + {% if c.author_name == '👻' %} + 👻 + {% else %} + @{{c.author_name}}'s profile picture{{c.author_name}} + {% if c.author.customtitle %}  {% if c.author.quadrant %}{{c.author.quadrant}} quadrant{% endif %}{{c.author.customtitle | safe}}{% endif %} + {% endif %} - {% if c.parent_comment_id and not standalone and level != 1 %}{{c.parent_comment.author.username}}{% endif %} + {% if c.parent_comment_id and not standalone and level != 1 %}{{c.parent_comment.author_name}}{% endif %} {% if c.created_utc %}  {{c.age_string}} @@ -413,7 +417,7 @@ {% if v %} - + {% endif %} {% if c.parent_submission %} @@ -436,9 +440,9 @@ {% endif %} {% if v and not v.id==c.author_id %} - + - + {% endif %} @@ -473,7 +477,7 @@ {% if v and v.admin_level > 1 and v.id != c.author_id %} - + {% endif %} {% if v and v.admin_level > 1 and c.oauth_app %} @@ -585,7 +589,7 @@ Context {% if v %} - Report + Report Give Award @@ -615,8 +619,8 @@ Hide source {% endif %} - Unblock user - Are you sure? + Unblock user + Are you sure? Block user {% endif %} @@ -663,7 +667,7 @@ {% endif %} {% if v.id != c.author_id %} - Ban user + Ban user Unban user {% endif %} diff --git a/files/templates/submission.html b/files/templates/submission.html index 005db3326d..774e4344e8 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -174,16 +174,16 @@ -{% if comment_info and not comment_info.is_banned and not linked_comment.deleted_utc %} -{{'@'+comment_info.author.username}} comments on "{{p.plaintitle(v)}} - {{SITE_NAME}}" +{% if comment_info and not comment_info.is_banned and not comment_info.deleted_utc %} +{{'@'+comment_info.author_name}} comments on "{{p.plaintitle(v)}} - {{SITE_NAME}}" - + {% if comment_info.edited_utc %}{% endif %} - - + + {% if p.is_video %} @@ -193,8 +193,8 @@ - - + + @@ -779,7 +779,7 @@ {% if sort != "old" %}Old{% endif %} {% if sort != "controversial" %}Controversial{% endif %}
- {% if linked_comment and p.comment_count >= 2%} + {% if comment_info and p.comment_count >= 2%}

 					
 				{% endif %}