diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 0be237064..db4b75af4 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -707,10 +707,6 @@ a.btn.disabled, fieldset:disabled a.btn { text-decoration: underline; box-shadow: none; } -.btn-link:disabled, .btn-link.disabled { - color: #6c757d; - pointer-events: none; -} .btn-lg { padding: 0.5rem 1rem; font-size: 1.25rem; @@ -1055,7 +1051,7 @@ input[type=submit].btn-block, input[type=reset].btn-block, input[type=button].bt .nav-link:hover, .nav-link:focus { text-decoration: none; } -.nav-link.disabled { +.disabled { color: #6c757d; pointer-events: none; cursor: default; @@ -1215,9 +1211,6 @@ input[type=submit].btn-block, input[type=reset].btn-block, input[type=button].bt .navbar-light .navbar-nav .nav-link:hover, .navbar-light .navbar-nav .nav-link:focus { color: rgba(0, 0, 0, 0.7); } -.navbar-light .navbar-nav .nav-link.disabled { - color: rgba(0, 0, 0, 0.3); -} .navbar-light .navbar-toggler { color: rgba(0, 0, 0, 0.5); border-color: rgba(0, 0, 0, 0.1); @@ -1237,9 +1230,6 @@ input[type=submit].btn-block, input[type=reset].btn-block, input[type=button].bt .navbar-dark .navbar-nav .nav-link:hover, .navbar-dark .navbar-nav .nav-link:focus { color: rgba(255, 255, 255, 0.75); } -.navbar-dark .navbar-nav .nav-link.disabled { - color: rgba(255, 255, 255, 0.25); -} .navbar-dark .navbar-nav .show > .nav-link, .navbar-dark .navbar-nav .active > .nav-link, .navbar-dark .navbar-nav .nav-link.show, .navbar-dark .navbar-nav .nav-link.active { color: #fff; } @@ -1577,9 +1567,6 @@ button.close { border: 0; appearance: none; } -a.close.disabled { - pointer-events: none; -} .toast { max-width: 350px; overflow: hidden; diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 3b46cdd35..ba0008e33 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -7,7 +7,9 @@ function post(url) { xhr.send(form); }; -function post_toast3(url, button1, button2) { +function post_toast3(t, url, button1, button2) { + t.disabled=true; + t.classList.add("disabled"); const xhr = new XMLHttpRequest(); xhr.open("POST", url); xhr.setRequestHeader('xhr', 'xhr'); @@ -39,6 +41,10 @@ function post_toast3(url, button1, button2) { if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"]; bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show(); } + setTimeout(() => { + t.disabled = false; + t.classList.remove("disabled"); + }, 500); }; xhr.send(form); @@ -127,6 +133,7 @@ function delete_commentModal(id) { function post_reply(id){ const btn = document.getElementById(`save-reply-to-${id}`) + btn.disabled = true; btn.classList.add('disabled'); var form = new FormData(); @@ -150,13 +157,17 @@ function post_reply(id){ catch(e) {console.log(e)} bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show(); } - btn.classList.remove('disabled'); + setTimeout(() => { + btn.disabled = false; + btn.classList.remove('disabled'); + }, 500); } xhr.send(form) } function comment_edit(id){ const btn = document.getElementById(`edit-btn-${id}`) + btn.disabled = true btn.classList.add('disabled'); var form = new FormData(); @@ -183,13 +194,17 @@ function comment_edit(id){ catch(e) {console.log(e)} bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show(); } - btn.classList.remove('disabled'); + setTimeout(() => { + btn.disabled = false; + btn.classList.remove('disabled'); + }, 500); } xhr.send(form) } function post_comment(fullname){ const btn = document.getElementById('save-reply-to-'+fullname) + btn.disabled = true btn.classList.add('disabled'); var form = new FormData(); @@ -217,7 +232,10 @@ function post_comment(fullname){ catch(e) {console.log(e)} bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show(); } - btn.classList.remove('disabled'); + setTimeout(() => { + btn.disabled = false; + btn.classList.remove('disabled'); + }, 500); } xhr.send(form) } diff --git a/files/assets/js/followers.js b/files/assets/js/followers.js index 40134830b..42d1e7a16 100644 --- a/files/assets/js/followers.js +++ b/files/assets/js/followers.js @@ -1,5 +1,5 @@ function removeFollower(event, username) { - post_toast('/remove_follow/' + username); + post_toast(event.target,'/remove_follow/' + username); let table = document.getElementById("followers-table"); table.removeChild(event.target.parentElement.parentElement); } \ No newline at end of file diff --git a/files/assets/js/following.js b/files/assets/js/following.js index bb04c2815..633c2503c 100644 --- a/files/assets/js/following.js +++ b/files/assets/js/following.js @@ -1,5 +1,5 @@ function removeFollowing(event, username) { - post_toast('/unfollow/' + username); + post_toast(event.target,'/unfollow/' + username); let table = document.getElementById("followers-table"); table.removeChild(event.target.parentElement.parentElement); } \ No newline at end of file diff --git a/files/assets/js/header.js b/files/assets/js/header.js index df83d7b5d..f2b5465f7 100644 --- a/files/assets/js/header.js +++ b/files/assets/js/header.js @@ -9,7 +9,9 @@ tooltipTriggerList.map(function(element){ return bootstrap.Tooltip.getOrCreateInstance(element); }); -function post_toast(url, reload, data) { +function post_toast(t, url, reload, data) { + t.disabled = true; + t.classList.add("disabled"); const xhr = new XMLHttpRequest(); xhr.open("POST", url); xhr.setRequestHeader('xhr', 'xhr'); @@ -35,6 +37,10 @@ function post_toast(url, reload, data) { if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"]; bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show(); } + setTimeout(() => { + t.disabled = false; + t.classList.remove("disabled"); + }, 500); }; xhr.send(form); diff --git a/files/assets/js/post_toast2.js b/files/assets/js/post_toast2.js index 61c398697..93a76e54f 100644 --- a/files/assets/js/post_toast2.js +++ b/files/assets/js/post_toast2.js @@ -1,4 +1,6 @@ -function post_toast2(url, button1, button2) { +function post_toast2(t, url, button1, button2) { + t.disabled=true; + t.classList.add("disabled"); const xhr = new XMLHttpRequest(); xhr.open("POST", url); xhr.setRequestHeader('xhr', 'xhr'); @@ -30,6 +32,10 @@ function post_toast2(url, button1, button2) { if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"]; bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show(); } + setTimeout(() => { + t.disabled = false; + t.classList.remove("disabled"); + }, 500); }; xhr.send(form); diff --git a/files/classes/badges.py b/files/classes/badges.py index 659892d0b..6b88898a0 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 bfe75fb41..20f4003ae 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 ff097cb28..3a226ec9d 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 6dc1c714d..568251cad 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 5eaa50b3c..109cd81b0 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 35ac606b1..1bb904ed6 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 1a937e191..4aebf932e 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 6f4a3870f..db97895d7 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 09bcce398..ac1da9b8c 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 cbd5c6c5c..2d0545775 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 a55dd8541..f5cf8ffff 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 1d645926d..7e45a44de 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 14f38df27..5c4b4f6da 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 2b2eb03ec..9348aa026 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 a4c3d5048..f478fdc94 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 @@