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 %})