From d6b0f5457992c3cce79e6195a2bbe733c4a5599e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Jul 2021 17:18:21 +0200 Subject: [PATCH 01/10] sneed --- drama/classes/user.py | 1 + drama/routes/admin.py | 1 + drama/routes/comments.py | 2 +- drama/routes/posts.py | 2 +- drama/routes/settings.py | 8 ++++++++ drama/routes/users.py | 7 +++---- drama/templates/banned.html | 4 ++-- drama/templates/blocks.html | 4 ++-- drama/templates/comments.html | 2 +- drama/templates/settings_profile.html | 21 +++++++++++++++++++++ drama/templates/submission.html | 2 +- drama/templates/submission_listing.html | 4 ++-- 12 files changed, 44 insertions(+), 14 deletions(-) diff --git a/drama/classes/user.py b/drama/classes/user.py index cb1ebdcc3..2b59db650 100644 --- a/drama/classes/user.py +++ b/drama/classes/user.py @@ -32,6 +32,7 @@ class User(Base, Stndrd, Age_times): profileurl = Column(String, default=None) bannerurl = Column(String, default=None) patron = Column(Boolean, default=False) + animatedname = Column(Boolean, default=False) email = Column(String, default=None) css = deferred(Column(String, default=None)) profilecss = deferred(Column(String, default=None)) diff --git a/drama/routes/admin.py b/drama/routes/admin.py index 634b4feeb..62cbe5c98 100644 --- a/drama/routes/admin.py +++ b/drama/routes/admin.py @@ -195,6 +195,7 @@ def badge_grant_post(v): if badge_id in [21,22,23,24]: user.patron = True + user.animatedname = True g.db.add(user) return redirect(user.permalink) diff --git a/drama/routes/comments.py b/drama/routes/comments.py index 91838063d..b0a6f9b0d 100644 --- a/drama/routes/comments.py +++ b/drama/routes/comments.py @@ -50,7 +50,7 @@ def banawardcomment(comment_id, v): comment.banaward = v.username g.db.add(comment) - return jsonify({"message": "User banned successfully!"}), 200 + return jsonify({"message": "User banned successfully!"}), 204 @app.route("/api/v1/post//comment/", methods=["GET"]) diff --git a/drama/routes/posts.py b/drama/routes/posts.py index 071ccfbe5..6b810b58c 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -70,7 +70,7 @@ def postbanaward(post_id, v): post.banaward = v.username g.db.add(post) - return jsonify({"message": "User banned successfully!"}), 200 + return jsonify({"message": "User banned successfully!"}), 204 @app.route("/api/publish/", methods=["POST"]) @is_not_banned diff --git a/drama/routes/settings.py b/drama/routes/settings.py index 1e5041f38..e3ef39f00 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -7,6 +7,7 @@ from drama.helpers.discord import remove_user, set_nick from drama.mail import * from .front import frontlist from drama.__main__ import app, cache +from .users import leaderboard import youtube_dl valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$") @@ -63,6 +64,13 @@ def settings_profile_post(v): updated = True v.is_private = request.values.get("private", None) == 'true' + if request.values.get("animatedname", v.animatedname) != v.animatedname: + if v.animatedname == False: + users1, users2 = leaderboard() + if v not in users1 and v not in users2: return jsonify({"error": "You must be in the leaderboard to apply animated name!"}), 403 + updated = True + v.animatedname = request.values.get("animatedname", None) == 'true' + if request.values.get("nofollow", v.is_nofollow) != v.is_nofollow: updated = True v.is_nofollow = request.values.get("nofollow", None) == 'true' diff --git a/drama/routes/users.py b/drama/routes/users.py index 7a81cad86..28d92f2bd 100644 --- a/drama/routes/users.py +++ b/drama/routes/users.py @@ -25,7 +25,6 @@ def user_info(v, username): user = get_user(username, v=v) return jsonify(user.json) - @app.route("/leaderboard", methods=["GET"]) @auth_desired def leaderboard(v): @@ -39,9 +38,9 @@ def leaderboard(v): @cache.memoize(timeout=86400) def leaderboard(): users = g.db.query(User).options(lazyload('*')) - users1= sorted(users, key=lambda x: x.dramacoins, reverse=True)[:100] - users2 = sorted(users1, key=lambda x: x.follower_count, reverse=True)[:10] - return users1[:25], users2 + users1= sorted(users, key=lambda x: x.dramacoins, reverse=True)[:25] + users2 = users.order_by(User.follower_count.desc()).limit(10).all() + return users1, users2 @app.get("/@/css") def get_css(username): diff --git a/drama/templates/banned.html b/drama/templates/banned.html index e4faf1261..914764d80 100644 --- a/drama/templates/banned.html +++ b/drama/templates/banned.html @@ -13,9 +13,9 @@ {% for user in users %} {{users.index(user)+1}} - {{user.username}} + {{user.username}} {% if user.ban_reason %}{{user.ban_reason}}{% endif %} - {{user.banned_by.username}} + {{user.banned_by.username}} {% endfor %} diff --git a/drama/templates/blocks.html b/drama/templates/blocks.html index 1122e029a..f0494a2c3 100644 --- a/drama/templates/blocks.html +++ b/drama/templates/blocks.html @@ -14,8 +14,8 @@ {% for user in users %} - {{user.username}} - {{targets[loop.index-1].username}} + {{user.username}} + {{targets[loop.index-1].username}} {% endfor %} diff --git a/drama/templates/comments.html b/drama/templates/comments.html index a1a212d51..adf0ca06c 100644 --- a/drama/templates/comments.html +++ b/drama/templates/comments.html @@ -125,7 +125,7 @@ {% if c.is_blocking %} {% endif %} {% if c.is_blocked %} {% endif %} - {% if c.author.is_deleted %}[deleted account]{% else %}{{c.author.username}}{% if c.author.customtitle %}  {{c.author.customtitle | safe}}{% endif %}{% endif %} + {% if c.author.is_deleted %}[deleted account]{% else %}{{c.author.username}}{% if c.author.customtitle %}  {{c.author.customtitle | safe}}{% endif %}{% endif %}  {{c.age_string}} {% if c.edited_utc %} diff --git a/drama/templates/settings_profile.html b/drama/templates/settings_profile.html index 70bbf7d7a..f68c299f6 100644 --- a/drama/templates/settings_profile.html +++ b/drama/templates/settings_profile.html @@ -337,6 +337,27 @@ + + +
+ +
+ +
+ +
+ +
+ + +
+ + Enable animated username (only available to users in the leaderboard and patrons) + +
+ +
+ diff --git a/drama/templates/submission.html b/drama/templates/submission.html index 0f2da86d6..da804bc18 100644 --- a/drama/templates/submission.html +++ b/drama/templates/submission.html @@ -233,7 +233,7 @@ {% if p.private %}unlisted{% endif %} {% if p.is_repost %}repost{% endif %} {% if p.active_flags %}{{p.active_flags}} Flags{% endif %} - {% if p.author.is_deleted %}[deleted account]{% else %}   {{p.author.username}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %}{% endif %} + {% if p.author.is_deleted %}[deleted account]{% else %}   {{p.author.username}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %}{% endif %}  {{p.age_string}} ({% if p.realurl(v) %}{{p.domain}}{% else %}text post{% endif %}) diff --git a/drama/templates/submission_listing.html b/drama/templates/submission_listing.html index 84944fb68..19a9b4ca8 100644 --- a/drama/templates/submission_listing.html +++ b/drama/templates/submission_listing.html @@ -141,7 +141,7 @@ {% if p.private %}unlisted {% endif %} {% if p.is_repost %}repost {% endif %} {% if p.active_flags %} {{p.active_flags}} Flags{% endif %} - {% if p.author.is_deleted %}[deleted account]{% else %} {{p.author.username}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %} + {% if p.author.is_deleted %}[deleted account]{% else %} {{p.author.username}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %}  {{p.age_string}} {% endif %} ({{p.domain}}) @@ -163,7 +163,7 @@ {% if p.private %}unlisted{% endif %} {% if p.is_repost %} repost{% endif %} {% if p.active_flags %}{{p.active_flags}} Flags{% endif %} - {% if p.author.is_deleted %}[deleted account]{% else %} {{p.author.username}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %}{% endif %} + {% if p.author.is_deleted %}[deleted account]{% else %} {{p.author.username}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %}{% endif %}  {{p.age_string}}   ({% if p.realurl(v) %}{{p.domain}}{% else %}text post{% endif %}) From 3a7bddc9ed0eecdf74e020fad9a9af1c59d6e83a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Jul 2021 17:25:47 +0200 Subject: [PATCH 03/10] sneed --- drama/routes/settings.py | 1 + drama/templates/settings_profile.html | 63 +++++++++++++-------------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/drama/routes/settings.py b/drama/routes/settings.py index e3ef39f00..4c0c9c146 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -67,6 +67,7 @@ def settings_profile_post(v): if request.values.get("animatedname", v.animatedname) != v.animatedname: if v.animatedname == False: users1, users2 = leaderboard() + print(users1) if v not in users1 and v not in users2: return jsonify({"error": "You must be in the leaderboard to apply animated name!"}), 403 updated = True v.animatedname = request.values.get("animatedname", None) == 'true' diff --git a/drama/templates/settings_profile.html b/drama/templates/settings_profile.html index f68c299f6..86e55e085 100644 --- a/drama/templates/settings_profile.html +++ b/drama/templates/settings_profile.html @@ -314,53 +314,50 @@
- + -
+
-
- + + - {% for color in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58'] %} - - - {% endfor %} + {% for color in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58'] %} + + + {% endfor %} -
+ -
- - -
- -
-
- -
- + +
+ + +
+ + + +
+
- + Enable animated username (only available to users in the leaderboard and patrons) -
- +
- -
- + {% if not v.flairchanged %}
From e0406ee6eb66c87f5a3ae52fa465c7d258f3c1b1 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Jul 2021 17:27:00 +0200 Subject: [PATCH 04/10] sneed --- drama/routes/settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drama/routes/settings.py b/drama/routes/settings.py index 4c0c9c146..fcab20437 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -68,7 +68,8 @@ def settings_profile_post(v): if v.animatedname == False: users1, users2 = leaderboard() print(users1) - if v not in users1 and v not in users2: return jsonify({"error": "You must be in the leaderboard to apply animated name!"}), 403 + print(v) + if v not in users1 and v not in users2: return jsonify({"error": "You must be in the leaderboard to apply animated name!"}), 403 updated = True v.animatedname = request.values.get("animatedname", None) == 'true' From 02053d2b88bb004d012de16a1c3e284118ebeb82 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Jul 2021 17:27:21 +0200 Subject: [PATCH 05/10] css --- drama/routes/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drama/routes/settings.py b/drama/routes/settings.py index fcab20437..09f38c6cd 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -66,10 +66,10 @@ def settings_profile_post(v): if request.values.get("animatedname", v.animatedname) != v.animatedname: if v.animatedname == False: - users1, users2 = leaderboard() + users1 = leaderboard() print(users1) print(v) - if v not in users1 and v not in users2: return jsonify({"error": "You must be in the leaderboard to apply animated name!"}), 403 + if v not in users1: return jsonify({"error": "You must be in the top 25 leaderboard to apply animated name!"}), 403 updated = True v.animatedname = request.values.get("animatedname", None) == 'true' From 17219b0c9c6e3b48075398bb35e6e031aaa0e80c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Jul 2021 17:28:05 +0200 Subject: [PATCH 06/10] sneed --- drama/routes/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drama/routes/settings.py b/drama/routes/settings.py index 09f38c6cd..e7ab9dd29 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -69,7 +69,7 @@ def settings_profile_post(v): users1 = leaderboard() print(users1) print(v) - if v not in users1: return jsonify({"error": "You must be in the top 25 leaderboard to apply animated name!"}), 403 + if v not in users1: return jsonify({"error": "You must be in the top 25 leaderboard or be a patron to apply an animated name!"}), 403 updated = True v.animatedname = request.values.get("animatedname", None) == 'true' From cf604cc616ed4c4a93b1c620ab8f8d15b3f3f0f2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Jul 2021 17:28:33 +0200 Subject: [PATCH 07/10] sneed --- drama/routes/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drama/routes/settings.py b/drama/routes/settings.py index e7ab9dd29..ac8c7f4ef 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -66,7 +66,7 @@ def settings_profile_post(v): if request.values.get("animatedname", v.animatedname) != v.animatedname: if v.animatedname == False: - users1 = leaderboard() + users1, users2 = leaderboard() print(users1) print(v) if v not in users1: return jsonify({"error": "You must be in the top 25 leaderboard or be a patron to apply an animated name!"}), 403 From 26d29773cc263a956245235f88db906a5b4108c5 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Jul 2021 17:30:15 +0200 Subject: [PATCH 08/10] sneed --- drama/routes/settings.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drama/routes/settings.py b/drama/routes/settings.py index ac8c7f4ef..5444d21a8 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -67,9 +67,8 @@ def settings_profile_post(v): if request.values.get("animatedname", v.animatedname) != v.animatedname: if v.animatedname == False: users1, users2 = leaderboard() - print(users1) - print(v) - if v not in users1: return jsonify({"error": "You must be in the top 25 leaderboard or be a patron to apply an animated name!"}), 403 + users1 = [x.id for x in users1] + if v.id not in users1: return jsonify({"error": "You must be in the top 25 leaderboard or be a patron to apply an animated name!"}), 403 updated = True v.animatedname = request.values.get("animatedname", None) == 'true' From b10f318b8a1c6d1206aa465bf2a706400be42e69 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Jul 2021 17:39:16 +0200 Subject: [PATCH 09/10] sneed --- drama/templates/header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drama/templates/header.html b/drama/templates/header.html index dcdb72002..0fa62dc01 100644 --- a/drama/templates/header.html +++ b/drama/templates/header.html @@ -84,7 +84,7 @@
-
{{v.username}}
+
{{v.username}}
{{v.dramacoins}} Dramacoins
From ffc6d1ee51f7aa8dd5a6aa16289aea5a443d649b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Jul 2021 17:43:26 +0200 Subject: [PATCH 10/10] sneed --- drama/templates/settings_profile.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drama/templates/settings_profile.html b/drama/templates/settings_profile.html index 86e55e085..c6264db2d 100644 --- a/drama/templates/settings_profile.html +++ b/drama/templates/settings_profile.html @@ -352,7 +352,7 @@
- Enable animated username (only available to users in the leaderboard and patrons) + Enable animated username (only available to users in the dramacoin leaderboard and patrons)