From 66b3efab36f4337e0b9095f5e566cb54b321e8e2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 27 May 2022 01:08:23 +0200 Subject: [PATCH] award refactor --- files/classes/comment.py | 6 +- files/routes/admin.py | 10 +- files/routes/awards.py | 304 +++-------------------- files/routes/comments.py | 20 +- files/routes/posts.py | 22 +- files/templates/comments.html | 24 +- files/templates/post_actions.html | 2 +- files/templates/post_actions_mobile.html | 2 +- schema.sql | 4 +- 9 files changed, 77 insertions(+), 317 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 0d892e25b..4e1156b79 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -34,8 +34,8 @@ class Comment(Base): top_comment_id = Column(Integer) over_18 = Column(Boolean, default=False) is_bot = Column(Boolean, default=False) - is_pinned = Column(String) - is_pinned_utc = Column(Integer) + stickied = Column(String) + stickied_utc = Column(Integer) sentto = Column(Integer, ForeignKey("users.id")) app_id = Column(Integer, ForeignKey("oauth_apps.id")) upvotes = Column(Integer, default=1) @@ -278,7 +278,7 @@ class Comment(Base): 'deleted_utc': self.deleted_utc, 'is_nsfw': self.over_18, 'permalink': f'/comment/{self.id}', - 'is_pinned': self.is_pinned, + 'stickied': self.stickied, 'distinguish_level': self.distinguish_level, 'post_id': self.post.id if self.post else 0, 'score': self.score, diff --git a/files/routes/admin.py b/files/routes/admin.py index 1230e72ef..686dea0ff 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1443,8 +1443,8 @@ def sticky_comment(cid, v): comment = get_comment(cid, v=v) - if not comment.is_pinned: - comment.is_pinned = v.username + if not comment.stickied: + comment.stickied = v.username g.db.add(comment) ma=ModAction( @@ -1468,10 +1468,10 @@ def unsticky_comment(cid, v): comment = get_comment(cid, v=v) - if comment.is_pinned: - if comment.is_pinned.endswith("(pin award)"): return {"error": "Can't unpin award pins!"}, 403 + if comment.stickied: + if comment.stickied.endswith("(pin award)"): return {"error": "Can't unpin award pins!"}, 403 - comment.is_pinned = None + comment.stickied = None g.db.add(comment) ma=ModAction( diff --git a/files/routes/awards.py b/files/routes/awards.py index 4c43ff2e4..9729f7e17 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -124,11 +124,17 @@ def buy(v, award): return {"message": "Award bought!"} -@app.post("/award_post/") +@app.post("/award//") @limiter.limit("1/second;30/minute;200/hour;1000/day") @limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}') @is_not_permabanned -def award_post(pid, v): +def award_thing(v, thing_type, id): + + if thing_type == 'post': thing = g.db.query(Submission).filter_by(id=id).one_or_none() + else: thing = g.db.query(Comment).filter_by(id=id).one_or_none() + + if not thing: return {"error": f"That {thing_type} doesn't exist."}, 404 + if v.shadowbanned: return render_template('errors/500.html', err=True, v=v), 500 kind = request.values.get("kind", "").strip() @@ -136,27 +142,24 @@ def award_post(pid, v): if kind not in AWARDS: return {"error": "That award doesn't exist."}, 404 - post_award = g.db.query(AwardRelationship).filter( + award = g.db.query(AwardRelationship).filter( AwardRelationship.kind == kind, AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None ).first() - if not post_award: + if not award: return {"error": "You don't have that award."}, 404 - post = g.db.query(Submission).filter_by(id=pid).one_or_none() + if thing_type == 'post': award.submission_id = thing.id + else: award.comment_id = thing.id - if not post: - return {"error": "That post doesn't exist."}, 404 - - post_award.submission_id = post.id - g.db.add(post_award) + g.db.add(award) note = request.values.get("note", "").strip() - author = post.author + author = thing.author if author.id in (PIZZASHILL_ID, DAD_ID) and v.id not in (PIZZASHILL_ID, DAD_ID): return {"error": "This user is immune to awards."}, 403 @@ -166,21 +169,21 @@ def award_post(pid, v): if v.id != author.id: if author.deflector and AWARDS[kind]['price'] > 500 and kind not in ('pin','unpin','benefactor'): - msg = f"@{v.username} has tried to give your [post]({post.shortlink}) the {AWARDS[kind]['title']} Award but it was deflected and applied to them :marseytroll:" + msg = f"@{v.username} has tried to give your [{thing_type}]({thing.shortlink}) the {AWARDS[kind]['title']} Award but it was deflected and applied to them :marseytroll:" send_repeatable_notification(author.id, msg) msg = f"@{author.username} is under the effect of a deflector award; your {AWARDS[kind]['title']} Award has been deflected back to you :marseytroll:" send_repeatable_notification(v.id, msg) author = v else: - msg = f"@{v.username} has given your [post]({post.shortlink}) the {AWARDS[kind]['title']} Award!" + msg = f"@{v.username} has given your [{thing_type}]({thing.shortlink}) the {AWARDS[kind]['title']} Award!" if note: msg += f"\n\n> {note}" send_repeatable_notification(author.id, msg) if kind == "ban": - link = f"[this post]({post.shortlink})" + link = f"[this {thing_type}]({thing.shortlink})" if not author.is_suspended: - author.ban(reason=f"1-Day ban award used by @{v.username} on /post/{post.id}", days=1) + author.ban(reason=f"1-Day ban award used by @{v.username} on /{thing_type}/{thing.id}", days=1) send_repeatable_notification(author.id, f"Your account has been banned for **a day** for {link}. It sucked and you should feel bad.") elif author.unban_utc: author.unban_utc += 86400 @@ -200,29 +203,29 @@ def award_post(pid, v): send_repeatable_notification(author.id, "You have been unbanned!") elif kind == "grass": author.is_banned = AUTOJANNY_ID - author.ban_reason = f"grass award used by @{v.username} on /post/{post.id}" + author.ban_reason = f"grass award used by @{v.username} on /{thing_type}/{thing.id}" author.unban_utc = int(time.time()) + 30 * 86400 - link = f"[this post]({post.shortlink})" + link = f"[this {thing_type}]({thing.shortlink})" send_repeatable_notification(author.id, f"Your account has been banned permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass/snow/sand/ass to get unbanned!") if request.host == 'rdrama.net' and v.id == CARP_ID: send_repeatable_notification(AEVANN_ID, link) elif kind == "pin": - if post.stickied and post.stickied_utc: - post.stickied_utc += 3600 + if thing.stickied and thing.stickied_utc: + thing.stickied_utc += 3600 else: - post.stickied = f'{v.username} (pin award)' - post.stickied_utc = int(time.time()) + 3600 - g.db.add(post) + thing.stickied = f'{v.username} (pin award)' + thing.stickied_utc = int(time.time()) + 3600 + g.db.add(thing) cache.delete_memoized(frontlist) elif kind == "unpin": - if not post.stickied_utc: abort(403) - t = post.stickied_utc - 3600 + if not thing.stickied_utc: abort(403) + t = thing.stickied_utc - 3600 if time.time() > t: - post.stickied = None - post.stickied_utc = None + thing.stickied = None + thing.stickied_utc = None cache.delete_memoized(frontlist) - else: post.stickied_utc = t - g.db.add(post) + else: thing.stickied_utc = t + g.db.add(thing) elif kind == "agendaposter" and not (author.agendaposter and author.agendaposter == 0): if author.marseyawarded: return {"error": "This user is the under the effect of a conflicting award: Marsey award."}, 404 @@ -365,254 +368,11 @@ def award_post(pid, v): g.db.commit() if request.referrer and len(request.referrer) > 1: - if request.referrer == f'{SITE_FULL}/submit': return redirect(post.permalink) + if request.referrer == f'{SITE_FULL}/submit': return redirect(thing.permalink) elif request.referrer.startswith(f'{SITE_FULL}/'): return redirect(request.referrer) return redirect(SITE_FULL) -@app.post("/award_comment/") -@limiter.limit("1/second;30/minute;200/hour;1000/day") -@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}') -@is_not_permabanned -def award_comment(cid, v): - if v.shadowbanned: return render_template('errors/500.html', err=True, v=v), 500 - - kind = request.values.get("kind", "").strip() - - if kind not in AWARDS: - return {"error": "That award doesn't exist."}, 404 - - comment_award = g.db.query(AwardRelationship).filter( - AwardRelationship.kind == kind, - AwardRelationship.user_id == v.id, - AwardRelationship.submission_id == None, - AwardRelationship.comment_id == None - ).first() - - if not comment_award: - return {"error": "You don't have that award."}, 404 - - c = g.db.query(Comment).filter_by(id=cid).one_or_none() - - if not c: - return {"error": "That comment doesn't exist."}, 404 - - comment_award.comment_id = c.id - g.db.add(comment_award) - - note = request.values.get("note", "").strip() - - author = c.author - - if author.id in (PIZZASHILL_ID, DAD_ID) and v.id not in (PIZZASHILL_ID, DAD_ID): - return {"error": "This user is immune to awards."}, 403 - - if v.id != author.id: - if author.deflector and AWARDS[kind]['price'] > 500 and kind not in ('pin','unpin','benefactor'): - msg = f"@{v.username} has tried to give your [comment]({c.shortlink}) the {AWARDS[kind]['title']} Award but it was deflected and applied to them :marseytroll:" - send_repeatable_notification(author.id, msg) - msg = f"@{author.username} is under the effect of a deflector award; your {AWARDS[kind]['title']} Award has been deflected back to you :marseytroll:" - send_repeatable_notification(v.id, msg) - author = v - else: - msg = f"@{v.username} has given your [comment]({c.shortlink}) the {AWARDS[kind]['title']} Award!" - if note: msg += f"\n\n> {note}" - send_repeatable_notification(author.id, msg) - - if kind == "benefactor" and author.id == v.id: - return {"error": "You can't use this award on yourself."}, 400 - - if author.deflector: author = v - - if kind == "ban": - link = f"[this comment]({c.shortlink})" - - if not author.is_suspended: - author.ban(reason=f"1-Day ban award used by @{v.username} on /comment/{c.id}", days=1) - send_repeatable_notification(author.id, f"Your account has been banned for **a day** for {link}. It sucked and you should feel bad.") - elif author.unban_utc: - author.unban_utc += 86400 - send_repeatable_notification(author.id, f"Your account has been banned for **yet another day** for {link}. Seriously man?") - if request.host == 'rdrama.net' and v.id == CARP_ID: - send_repeatable_notification(AEVANN_ID, link) - - elif kind == "unban": - if not author.is_suspended or not author.unban_utc or time.time() > author.unban_utc: abort(403) - - if author.unban_utc - time.time() > 86400: - author.unban_utc -= 86400 - send_repeatable_notification(author.id, "Your ban duration has been reduced by 1 day!") - else: - author.unban_utc = 0 - author.is_banned = 0 - author.ban_evade = 0 - send_repeatable_notification(author.id, "You have been unbanned!") - elif kind == "grass": - author.is_banned = AUTOJANNY_ID - author.ban_reason = f"grass award used by @{v.username} on /comment/{c.id}" - author.unban_utc = int(time.time()) + 30 * 86400 - link = f"[this comment]({c.shortlink})" - send_repeatable_notification(author.id, f"Your account has been banned permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass/snow/sand/ass to get unbanned!") - if request.host == 'rdrama.net' and v.id == CARP_ID: - send_repeatable_notification(AEVANN_ID, link) - elif kind == "pin": - if c.is_pinned and c.is_pinned_utc: c.is_pinned_utc += 3600 - else: - c.is_pinned = f'{v.username} (pin award)' - c.is_pinned_utc = int(time.time()) + 3600 - g.db.add(c) - elif kind == "unpin": - if not c.is_pinned_utc: abort(403) - t = c.is_pinned_utc - 3600 - if time.time() > t: - c.is_pinned = None - c.is_pinned_utc = None - else: c.is_pinned_utc = t - g.db.add(c) - elif kind == "agendaposter" and not (author.agendaposter and author.agendaposter == 0): - if author.marseyawarded: - return {"error": "This user is the under the effect of a conflicting award: Marsey award."}, 404 - - if author.agendaposter and time.time() < author.agendaposter: author.agendaposter += 86400 - else: author.agendaposter = int(time.time()) + 86400 - - if not author.has_badge(28): - badge = Badge(user_id=author.id, badge_id=28) - g.db.add(badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") - elif kind == "flairlock": - new_name = note[:100].replace("𒐪","") - if not new_name and author.flairchanged: - author.flairchanged += 86400 - else: - author.customtitleplain = new_name - author.customtitle = filter_emojis_only(new_name) - if len(author.customtitle) > 1000: abort(403) - author.flairchanged = int(time.time()) + 86400 - if not author.has_badge(96): - badge = Badge(user_id=author.id, badge_id=96) - g.db.add(badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") - elif kind == "pause": - author.mute = True - if not author.has_badge(68): - new_badge = Badge(badge_id=68, user_id=author.id) - g.db.add(new_badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") - elif kind == "unpausable": - author.unmutable = True - if not author.has_badge(67): - new_badge = Badge(badge_id=67, user_id=author.id) - g.db.add(new_badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") - elif kind == "marsey": - if author.marseyawarded: author.marseyawarded += 86400 - else: author.marseyawarded = int(time.time()) + 86400 - if not author.has_badge(98): - badge = Badge(user_id=author.id, badge_id=98) - g.db.add(badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") - elif kind == "pizzashill": - if author.bird: - return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404 - if author.longpost: author.longpost += 86400 - else: author.longpost = int(time.time()) + 86400 - if not author.has_badge(97): - badge = Badge(user_id=author.id, badge_id=97) - g.db.add(badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") - elif kind == "bird": - if author.longpost: - return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404 - if author.bird: author.bird += 86400 - else: author.bird = int(time.time()) + 86400 - if not author.has_badge(95): - badge = Badge(user_id=author.id, badge_id=95) - g.db.add(badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") - elif kind == "eye": - author.eye = True - if not author.has_badge(83): - new_badge = Badge(badge_id=83, user_id=author.id) - g.db.add(new_badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") - elif kind == "alt": - author.alt = True - if not author.has_badge(84): - new_badge = Badge(badge_id=84, user_id=author.id) - g.db.add(new_badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") - elif kind == "unblockable": - author.unblockable = True - if not author.has_badge(87): - new_badge = Badge(badge_id=87, user_id=author.id) - g.db.add(new_badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") - for block in g.db.query(UserBlock).filter_by(target_id=author.id).all(): g.db.delete(block) - elif kind == "fish": - author.fish = True - if not author.has_badge(90): - new_badge = Badge(badge_id=90, user_id=author.id) - g.db.add(new_badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") - elif kind == "progressivestack": - if author.progressivestack: author.progressivestack += 21600 - else: author.progressivestack = int(time.time()) + 21600 - if not author.has_badge(94): - badge = Badge(user_id=author.id, badge_id=94) - g.db.add(badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") - elif kind == "benefactor": - author.patron = 1 - if author.patron_utc: author.patron_utc += 2629746 - else: author.patron_utc = int(time.time()) + 2629746 - author.procoins += 2500 - if author.discord_id: add_role(author, "1") - if not v.has_badge(103): - badge = Badge(user_id=v.id, badge_id=103) - g.db.add(badge) - g.db.flush() - send_notification(v.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") - elif kind == "rehab": - if author.rehab: author.rehab += 86400 - else: author.rehab = int(time.time()) + 86400 - if not author.has_badge(109): - badge = Badge(user_id=author.id, badge_id=109) - g.db.add(badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") - elif kind == "deflector": - if author.deflector: author.deflector += 36000 - else: author.deflector = int(time.time()) + 36000 - elif kind == "beano": - if not author.has_badge(128): - badge = Badge(user_id=author.id, badge_id=128) - g.db.add(badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") - elif kind == "checkmark": - author.verified = "Verified" - - if author.received_award_count: author.received_award_count += 1 - else: author.received_award_count = 1 - g.db.add(author) - - g.db.commit() - if request.referrer and len(request.referrer) > 1 and request.referrer.startswith(f'{SITE_FULL}/'): - return redirect(request.referrer) - return redirect(SITE_FULL) @app.get("/admin/awards") @admin_level_required(2) diff --git a/files/routes/comments.py b/files/routes/comments.py index 86648c661..0836e4f5c 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -896,11 +896,11 @@ def pin_comment(cid, v): comment = get_comment(cid, v=v) - if not comment.is_pinned: + if not comment.stickied: if v.id != comment.post.author_id: abort(403) - if comment.post.ghost: comment.is_pinned = "(OP)" - else: comment.is_pinned = v.username + " (OP)" + if comment.post.ghost: comment.stickied = "(OP)" + else: comment.stickied = v.username + " (OP)" g.db.add(comment) @@ -919,13 +919,13 @@ def unpin_comment(cid, v): comment = get_comment(cid, v=v) - if comment.is_pinned: + if comment.stickied: if v.id != comment.post.author_id: abort(403) - if not comment.is_pinned.endswith(" (OP)"): + if not comment.stickied.endswith(" (OP)"): return {"error": "You can only unpin comments you have pinned!"} - comment.is_pinned = None + comment.stickied = None g.db.add(comment) if v.id != comment.author_id: @@ -941,10 +941,10 @@ def mod_pin(cid, v): comment = get_comment(cid, v=v) - if not comment.is_pinned: + if not comment.stickied: if not (comment.post.sub and v.mods(comment.post.sub)): abort(403) - comment.is_pinned = v.username + " (Mod)" + comment.stickied = v.username + " (Mod)" g.db.add(comment) @@ -962,10 +962,10 @@ def mod_unpin(cid, v): comment = get_comment(cid, v=v) - if comment.is_pinned: + if comment.stickied: if not (comment.post.sub and v.mods(comment.post.sub)): abort(403) - comment.is_pinned = None + comment.stickied = None g.db.add(comment) if v.id != comment.author_id: diff --git a/files/routes/posts.py b/files/routes/posts.py index 29046f2ff..6623ddc23 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -181,9 +181,9 @@ def post_id(pid, anything=None, v=None, sub=None): comment.is_blocked = c[3] or 0 output.append(comment) - pinned = [c[0] for c in comments.filter(Comment.is_pinned != None).all()] + pinned = [c[0] for c in comments.filter(Comment.stickied != None).all()] - comments = comments.filter(Comment.level == 1, Comment.is_pinned == None) + comments = comments.filter(Comment.level == 1, Comment.stickied == None) if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) @@ -200,9 +200,9 @@ def post_id(pid, anything=None, v=None, sub=None): second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None, Comment.wordle_result != None), func.length(Comment.body_html) <= 100).all()] comments = first + second else: - pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all() + pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.stickied != None).all() - comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.level == 1, Comment.is_pinned == None) + comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.level == 1, Comment.stickied == None) if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) @@ -243,9 +243,9 @@ def post_id(pid, anything=None, v=None, sub=None): comments = comments2 for pin in pinned: - if pin.is_pinned_utc and int(time.time()) > pin.is_pinned_utc: - pin.is_pinned = None - pin.is_pinned_utc = None + if pin.stickied_utc and int(time.time()) > pin.stickied_utc: + pin.stickied = None + pin.stickied_utc = None g.db.add(pin) pinned.remove(pin) @@ -285,7 +285,7 @@ def viewmore(v, pid, sort, offset): votes.c.vote_type, blocking.c.target_id, blocked.c.target_id, - ).filter(Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.is_pinned == None, Comment.id.notin_(ids)) + ).filter(Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.stickied == None, Comment.id.notin_(ids)) if not (v and v.shadowbanned) and not (v and v.admin_level > 2): comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None) @@ -329,7 +329,7 @@ def viewmore(v, pid, sort, offset): second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None, Comment.wordle_result != None), func.length(Comment.body_html) <= 100).all()] comments = first + second else: - comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.level == 1, Comment.is_pinned == None, Comment.id.notin_(ids)) + comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.level == 1, Comment.stickied == None, Comment.id.notin_(ids)) if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) @@ -532,7 +532,7 @@ def edit_post(pid, v): over_18=False, is_bot=True, app_id=None, - is_pinned='AutoJanny', + stickied='AutoJanny', distinguish_level=6, body_html=body_jannied_html, ghost=p.ghost @@ -1224,7 +1224,7 @@ def submit_post(v, sub=None): over_18=False, is_bot=True, app_id=None, - is_pinned='AutoJanny', + stickied='AutoJanny', distinguish_level=6, body_html=body_jannied_html, ) diff --git a/files/templates/comments.html b/files/templates/comments.html index 1e1818a8b..2f124c5bb 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -186,8 +186,8 @@ {% if c.active_flags(v) %}{{c.active_flags(v)}} Reports{% endif %} {% if c.over_18 %}+18{% endif %} {% if v and v.admin_level > 1 and c.author.shadowbanned %}{% endif %} - {% if c.is_pinned %} - + {% if c.stickied %} + {% endif %} {% if c.distinguish_level and not c.ghost %}{% endif %} {% if c.is_op %}{% endif %} @@ -441,7 +441,7 @@ - + @@ -486,9 +486,9 @@ {% endif %} {% if url != "" %} - + - + {% endif %} {% endif %} @@ -641,7 +641,7 @@ {% if v %} Report - Give Award + Give Award Save @@ -675,11 +675,11 @@ {% if v.admin_level < 2 %} {% if c.post and v.id == c.post.author_id %} - Pin - Unpin + Pin + Unpin {% elif c.post.sub and v.mods(c.post.sub) %} - Pin - Unpin + Pin + Unpin {% endif %} {% endif %} @@ -720,8 +720,8 @@ Undistinguish {% endif %} - Pin - Unpin + Pin + Unpin Mark +18 Unmark +18 diff --git a/files/templates/post_actions.html b/files/templates/post_actions.html index 806a6ec2d..e9d5cc72d 100644 --- a/files/templates/post_actions.html +++ b/files/templates/post_actions.html @@ -9,7 +9,7 @@ {% if not p.ghost or v.id == AEVANN_ID %}Votes{% endif %} {% if v %} - Give Award + Give Award {% endif %} Copy link diff --git a/files/templates/post_actions_mobile.html b/files/templates/post_actions_mobile.html index 782a591b6..d60a35e7f 100644 --- a/files/templates/post_actions_mobile.html +++ b/files/templates/post_actions_mobile.html @@ -12,7 +12,7 @@ - + diff --git a/schema.sql b/schema.sql index ba21c97c6..c498cbe7f 100644 --- a/schema.sql +++ b/schema.sql @@ -273,13 +273,13 @@ CREATE TABLE public.comments ( app_id integer, sentto integer, bannedfor boolean, - is_pinned character varying(40), + stickied character varying(40), body character varying(10000), body_html character varying(40000), ban_reason character varying(25), realupvotes integer DEFAULT 1 NOT NULL, top_comment_id integer, - is_pinned_utc integer, + stickied_utc integer, ghost boolean DEFAULT false NOT NULL, slots_result character varying(32), blackjack_result character varying(860),