From bf3e14bba3d01df844d897c7be3407b1033e5250 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 13 Feb 2022 03:08:12 +0200 Subject: [PATCH] big big chungus big chungus big chungus --- files/classes/badges.py | 2 +- files/classes/comment.py | 2 +- files/classes/mod_logs.py | 8 +- files/classes/submission.py | 4 +- files/classes/subscriptions.py | 2 +- files/classes/user.py | 4 +- files/helpers/const.py | 1 - files/routes/admin.py | 53 ++++++----- files/routes/comments.py | 116 +++++++++++------------- files/templates/admin/admin_home.html | 6 +- files/templates/admin/app.html | 6 +- files/templates/admin/apps.html | 6 +- files/templates/admin/awards.html | 2 +- files/templates/changelog.html | 6 +- files/templates/comments.html | 86 ++++++++++-------- files/templates/default.html | 2 +- files/templates/header.html | 6 +- files/templates/notifications.html | 2 +- files/templates/settings_apps.html | 4 +- files/templates/settings_blocks.html | 2 +- files/templates/settings_filters.html | 28 +++--- files/templates/settings_profile.html | 16 ++-- files/templates/settings_security.html | 4 +- files/templates/shop.html | 4 +- files/templates/submission.html | 110 +++++++++++----------- files/templates/submission_listing.html | 108 +++++++++++----------- files/templates/user_listing.html | 4 +- files/templates/userpage.html | 62 ++++++------- files/templates/userpage_comments.html | 2 +- files/templates/userpage_private.html | 6 +- 30 files changed, 334 insertions(+), 330 deletions(-) diff --git a/files/classes/badges.py b/files/classes/badges.py index 659892d0bb..6b88898a0f 100644 --- a/files/classes/badges.py +++ b/files/classes/badges.py @@ -24,7 +24,7 @@ class Badge(Base): id = Column(Integer, primary_key=True) user_id = Column(Integer, ForeignKey('users.id')) - badge_id = Column(Integer) + badge_id = Column(Integer, ForeignKey('badge_defs.id')) description = Column(String) url = Column(String) diff --git a/files/classes/comment.py b/files/classes/comment.py index bfe75fb410..20f4003ae6 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -20,7 +20,7 @@ class Comment(Base): id = Column(Integer, primary_key=True) author_id = Column(Integer, ForeignKey("users.id")) parent_submission = Column(Integer, ForeignKey("submissions.id")) - created_utc = Column(Integer, default=0) + created_utc = Column(Integer) edited_utc = Column(Integer, default=0) is_banned = Column(Boolean, default=False) ghost = Column(Boolean) diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py index ff097cb282..3a226ec9d4 100644 --- a/files/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -12,11 +12,11 @@ class ModAction(Base): id = Column(Integer, primary_key=True) user_id = Column(Integer, ForeignKey("users.id")) kind = Column(String) - target_user_id = Column(Integer, ForeignKey("users.id"), default=0) - target_submission_id = Column(Integer, ForeignKey("submissions.id"), default=0) - target_comment_id = Column(Integer, ForeignKey("comments.id"), default=0) + target_user_id = Column(Integer, ForeignKey("users.id")) + target_submission_id = Column(Integer, ForeignKey("submissions.id")) + target_comment_id = Column(Integer, ForeignKey("comments.id")) _note=Column(String) - created_utc = Column(Integer, default=0) + created_utc = Column(Integer) user = relationship("User", primaryjoin="User.id==ModAction.user_id", viewonly=True) target_user = relationship("User", primaryjoin="User.id==ModAction.target_user_id", viewonly=True) diff --git a/files/classes/submission.py b/files/classes/submission.py index 6dc1c714d2..568251cadf 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -21,7 +21,7 @@ class Submission(Base): id = Column(Integer, primary_key=True) author_id = Column(Integer, ForeignKey("users.id")) edited_utc = Column(Integer, default=0) - created_utc = Column(Integer, default=0) + created_utc = Column(Integer) thumburl = Column(String) is_banned = Column(Boolean, default=False) bannedfor = Column(Boolean) @@ -412,7 +412,7 @@ class Submission(Base): body += ''' (cost of entry: 200 coins)''' body += "" if v and v.admin_level > 2: - body += f'''''' + body += f'''''' body += "" diff --git a/files/classes/subscriptions.py b/files/classes/subscriptions.py index 5eaa50b3ca..109cd81b06 100644 --- a/files/classes/subscriptions.py +++ b/files/classes/subscriptions.py @@ -7,7 +7,7 @@ class Subscription(Base): __tablename__ = "subscriptions" id = Column(Integer, primary_key=True) user_id = Column(Integer, ForeignKey("users.id")) - submission_id = Column(Integer, default=0) + submission_id = Column(Integer, ForeignKey("submissions.id")) user = relationship("User", uselist=False, viewonly=True) diff --git a/files/classes/user.py b/files/classes/user.py index 35ac606b19..1bb904ed66 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -63,7 +63,7 @@ class User(Base): post_count = Column(Integer, default=0) comment_count = Column(Integer, default=0) received_award_count = Column(Integer, default=0) - created_utc = Column(Integer, default=0) + created_utc = Column(Integer) suicide_utc = Column(Integer, default=0) rent_utc = Column(Integer, default=0) steal_utc = Column(Integer, default=0) @@ -107,7 +107,7 @@ class User(Base): is_banned = Column(Integer, default=0) unban_utc = Column(Integer, default=0) ban_reason = deferred(Column(String)) - club_allowed = Column(Boolean, default=False) + club_allowed = Column(Boolean) login_nonce = Column(Integer, default=0) reserved = deferred(Column(String)) coins = Column(Integer, default=0) diff --git a/files/helpers/const.py b/files/helpers/const.py index 1a937e1919..4aebf932e2 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -79,7 +79,6 @@ SLURS = { "mohammad": "Prophet Mohammad (PBUH)", "muhammad": "Prophet Mohammad (PBUH)", "i hate marsey": "i love marsey", - "billie eilish": "Billie Eilish (fat cow)", "dancing israelis": "i love Israel", "sodomite": "total dreamboat", "pajeet": "sexy Indian dude", diff --git a/files/routes/admin.py b/files/routes/admin.py index 6f4a3870f4..db97895d70 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1262,21 +1262,23 @@ def unsticky_post(post_id, v): def sticky_comment(cid, v): comment = get_comment(cid, v=v) - comment.is_pinned = v.username - g.db.add(comment) - ma=ModAction( - kind="pin_comment", - user_id=v.id, - target_comment_id=comment.id - ) - g.db.add(ma) + if not comment.is_pinned: + comment.is_pinned = v.username + g.db.add(comment) - if v.id != comment.author_id: - message = f"@{v.username} has pinned your [comment]({comment.permalink})!" - send_repeatable_notification(comment.author_id, message) + ma=ModAction( + kind="pin_comment", + user_id=v.id, + target_comment_id=comment.id + ) + g.db.add(ma) - g.db.commit() + if v.id != comment.author_id: + message = f"@{v.username} has pinned your [comment]({comment.permalink})!" + send_repeatable_notification(comment.author_id, message) + + g.db.commit() return {"message": "Comment pinned!"} @@ -1286,23 +1288,24 @@ def unsticky_comment(cid, v): comment = get_comment(cid, v=v) - if comment.is_pinned.endswith("(pin award)"): return {"error": "Can't unpin award pins!"}, 403 + if comment.is_pinned: + if comment.is_pinned.endswith("(pin award)"): return {"error": "Can't unpin award pins!"}, 403 - comment.is_pinned = None - g.db.add(comment) + comment.is_pinned = None + g.db.add(comment) - ma=ModAction( - kind="unpin_comment", - user_id=v.id, - target_comment_id=comment.id - ) - g.db.add(ma) + ma=ModAction( + kind="unpin_comment", + user_id=v.id, + target_comment_id=comment.id + ) + g.db.add(ma) - if v.id != comment.author_id: - message = f"@{v.username} has unpinned your [comment]({comment.permalink})!" - send_repeatable_notification(comment.author_id, message) + if v.id != comment.author_id: + message = f"@{v.username} has unpinned your [comment]({comment.permalink})!" + send_repeatable_notification(comment.author_id, message) - g.db.commit() + g.db.commit() return {"message": "Comment unpinned!"} diff --git a/files/routes/comments.py b/files/routes/comments.py index 09bcce3984..ac1da9b8c9 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -873,19 +873,19 @@ def edit_comment(cid, v): @auth_required def delete_comment(cid, v): - c = g.db.query(Comment).filter_by(id=cid).one_or_none() + comment = get_comment(cid, v=v) - if not c: abort(404) + if not comment.deleted_utc: - if c.author_id != v.id: abort(403) + if c.author_id != v.id: abort(403) - c.deleted_utc = int(time.time()) + c.deleted_utc = int(time.time()) - g.db.add(c) - - cache.delete_memoized(comment_idlist) + g.db.add(c) + + cache.delete_memoized(comment_idlist) - g.db.commit() + g.db.commit() return {"message": "Comment deleted!"} @@ -894,20 +894,18 @@ def delete_comment(cid, v): @auth_required def undelete_comment(cid, v): - c = g.db.query(Comment).filter_by(id=cid).one_or_none() + comment = get_comment(cid, v=v) - if not c: abort(404) + if comment.deleted_utc: + if c.author_id != v.id: abort(403) - if c.author_id != v.id: - abort(403) + c.deleted_utc = 0 - c.deleted_utc = 0 + g.db.add(c) - g.db.add(c) + cache.delete_memoized(comment_idlist) - cache.delete_memoized(comment_idlist) - - g.db.commit() + g.db.commit() return {"message": "Comment undeleted!"} @@ -918,19 +916,18 @@ def pin_comment(cid, v): comment = get_comment(cid, v=v) - if not comment: abort(404) + if not comment.is_pinned: + if v.id != comment.post.author_id: abort(403) + + comment.is_pinned = v.username + " (OP)" - if v.id != comment.post.author_id: abort(403) - - comment.is_pinned = v.username + " (OP)" + g.db.add(comment) - g.db.add(comment) + if v.id != comment.author_id: + message = f"@{v.username} (OP) has pinned your [comment]({comment.permalink})!" + send_repeatable_notification(comment.author_id, message) - if v.id != comment.author_id: - message = f"@{v.username} (OP) has pinned your [comment]({comment.permalink})!" - send_repeatable_notification(comment.author_id, message) - - g.db.commit() + g.db.commit() return {"message": "Comment pinned!"} @@ -940,20 +937,19 @@ def unpin_comment(cid, v): comment = get_comment(cid, v=v) - if not comment: abort(404) + if comment.is_pinned: + if v.id != comment.post.author_id: abort(403) - if v.id != comment.post.author_id: abort(403) + if not comment.is_pinned.endswith(" (OP)"): + return {"error": "You can only unpin comments you have pinned!"} - if not comment.is_pinned.endswith(" (OP)"): - return {"error": "You can only unpin comments you have pinned!"} + comment.is_pinned = None + g.db.add(comment) - comment.is_pinned = None - g.db.add(comment) - - if v.id != comment.author_id: - message = f"@{v.username} (OP) has unpinned your [comment]({comment.permalink})!" - send_repeatable_notification(comment.author_id, message) - g.db.commit() + if v.id != comment.author_id: + message = f"@{v.username} (OP) has unpinned your [comment]({comment.permalink})!" + send_repeatable_notification(comment.author_id, message) + g.db.commit() return {"message": "Comment unpinned!"} @@ -963,39 +959,37 @@ def mod_pin(cid, v): comment = get_comment(cid, v=v) - if not comment: abort(404) + if not comment.is_pinned: + if not (comment.post.sub and v.mods(comment.post.sub)): abort(403) + + comment.is_pinned = v.username + " (Mod)" - if not (comment.post.sub and v.mods(comment.post.sub)): abort(403) - - comment.is_pinned = v.username + " (Mod)" + g.db.add(comment) - g.db.add(comment) + if v.id != comment.author_id: + message = f"@{v.username} (Mod) has pinned your [comment]({comment.permalink})!" + send_repeatable_notification(comment.author_id, message) - if v.id != comment.author_id: - message = f"@{v.username} (Mod) has pinned your [comment]({comment.permalink})!" - send_repeatable_notification(comment.author_id, message) - - g.db.commit() + g.db.commit() return {"message": "Comment pinned!"} -@app.post("/mod_unpin/") +@app.post("/unmod_pin/") @auth_required def mod_unpin(cid, v): comment = get_comment(cid, v=v) - if not comment: abort(404) + if comment.is_pinned: + if not (comment.post.sub and v.mods(comment.post.sub)): abort(403) - if not (comment.post.sub and v.mods(comment.post.sub)): abort(403) + comment.is_pinned = None + g.db.add(comment) - comment.is_pinned = None - g.db.add(comment) - - if v.id != comment.author_id: - message = f"@{v.username} (Mod) has unpinned your [comment]({comment.permalink})!" - send_repeatable_notification(comment.author_id, message) - g.db.commit() + if v.id != comment.author_id: + message = f"@{v.username} (Mod) has unpinned your [comment]({comment.permalink})!" + send_repeatable_notification(comment.author_id, message) + g.db.commit() return {"message": "Comment unpinned!"} @@ -1040,10 +1034,8 @@ def handle_blackjack_action(cid, v): action = request.values.get("action", "") blackjack = Blackjack(g) - if action == 'hit': - blackjack.player_hit(comment) - elif action == 'stay': - blackjack.player_stayed(comment) + if action == 'hit': blackjack.player_hit(comment) + elif action == 'stay': blackjack.player_stayed(comment) g.db.add(comment) g.db.add(v) diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index cbd5c6c5c5..2d05457750 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -59,16 +59,16 @@ {% if v.admin_level > 2 %}
- +
- +
- + {% endif %} {% endblock %} \ No newline at end of file diff --git a/files/templates/admin/app.html b/files/templates/admin/app.html index a55dd85415..f5cf8ffff0 100644 --- a/files/templates/admin/app.html +++ b/files/templates/admin/app.html @@ -34,12 +34,12 @@
{% if not app.client_id%} - Approve - Reject + Approve + Reject {% else %} - Revoke + Revoke {% endif %}
diff --git a/files/templates/admin/apps.html b/files/templates/admin/apps.html index 1d645926d1..7e45a44deb 100644 --- a/files/templates/admin/apps.html +++ b/files/templates/admin/apps.html @@ -39,12 +39,12 @@
{% if not app.client_id %} - Approve - Reject + Approve + Reject {% else %} - Revoke + Revoke {% endif %}
diff --git a/files/templates/admin/awards.html b/files/templates/admin/awards.html index 14f38df277..5c4b4f6da7 100644 --- a/files/templates/admin/awards.html +++ b/files/templates/admin/awards.html @@ -64,6 +64,6 @@

 	{% if SITE_NAME != 'Drama' or v.id == AEVANN_ID %}
-		
Grant Monthly Marseybux
+
Grant Monthly Marseybux
{% endif %} {% endblock %} \ No newline at end of file diff --git a/files/templates/changelog.html b/files/templates/changelog.html index 2b2eb03ec7..9348aa026f 100644 --- a/files/templates/changelog.html +++ b/files/templates/changelog.html @@ -67,8 +67,8 @@ {% block content %} {% if v %} - - + + {% endif %}
@@ -104,6 +104,6 @@ {% endif %} - + {% endblock %} \ No newline at end of file diff --git a/files/templates/comments.html b/files/templates/comments.html index a4c3d5048a..f478fdc948 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -286,7 +286,7 @@

 				
    {% for f in c.flags %} -
  • {{f.user.username}}{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level > 1 %}[remove]{% endif %}
  • +
  • {{f.user.username}}{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level > 1 %}[remove]{% endif %}
  • {% endfor %}
@@ -461,9 +461,9 @@ {% if v %} - + - + {% endif %} @@ -481,7 +481,7 @@ {% if c.deleted_utc %} - + {% else %} {% endif %} @@ -491,27 +491,33 @@ {% endif %} {% if v and v.admin_level and v.id==c.author_id %} - - + + {% endif %} {% if v and v.id != c.author_id and not c.ghost %} - + - + {% endif %} {% if v and c.post %} + {% set url = "" %} + {% if v.admin_level > 1%} - - - - {% elif v.id == c.post.author_id or c.post.sub and v.mods(c.post.sub) %} - + {% set url = "sticky_comment" %} + {% elif v.id == c.post.author_id %} + {% set url = "pin_comment" %} + {% elif c.post.sub and v.mods(c.post.sub) %} + {% set url = "mod_pin" %} + {% endif %} + + {% if url != "" %} + - + {% endif %} {% endif %} @@ -527,12 +533,12 @@ {% endif %} {% if v and c.parent_submission and (c.author_id==v.id or v.admin_level > 1) %} - - + + {% endif %} {% if v and v.admin_level > 1 and v.id != c.author_id %} - + {% endif %} @@ -649,26 +655,26 @@ Give Award - Save + Save - Unsave + Unsave {% if c.author_id == v.id %} Edit {% if v.admin_level == 1 %} - Distinguish - Undistinguish + Distinguish + Undistinguish {% endif %} {% if c.deleted_utc %} - Undelete + Undelete {% else %} Delete {% endif %} - Mark +18 - Unmark +18 + Mark +18 + Unmark +18 {% else %} {% if c.body %} View source @@ -676,16 +682,20 @@ {% endif %} {% if not c.ghost %} - Unblock user - Are you sure? + Unblock user + Are you sure? Block user {% endif %} {% endif %} - - {% if c.post and v.id == c.post.author_id and v.admin_level < 2 or c.post.sub and v.mods(c.post.sub) %} - Pin - Unpin + {% if v.admin_level < 2 %} + {% if c.post and v.id == c.post.author_id %} + Pin + Unpin + {% elif c.post.sub and v.mods(c.post.sub) %} + Pin + Unpin + {% endif %} {% endif %} {% endif %} @@ -713,20 +723,20 @@
    {% if c.parent_submission %} {% if v.id == c.author_id %} - Distinguish - Undistinguish + Distinguish + Undistinguish {% endif %} - Pin - Unpin + Pin + Unpin - Mark +18 - Unmark +18 + Mark +18 + Unmark +18 {% endif %} {% if v.id != c.author_id %} Ban user - Unban user + Unban user {% endif %} {% if "/reported/" in request.path %} @@ -928,7 +938,7 @@ {% if v %} - + {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index 2f9aa70780..beeb5944c3 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -330,7 +330,7 @@ {% if v %} - + {% endif %} diff --git a/files/templates/header.html b/files/templates/header.html index a64d6fb27f..f987a91655 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -171,7 +171,7 @@ Contact us @@ -231,7 +231,7 @@ Contact us {% else %}