remotes/1693045480750635534/spooky-22
Aevann1 2021-07-23 17:18:21 +02:00
parent 17df5f1513
commit d6b0f54579
12 changed files with 44 additions and 14 deletions

View File

@ -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))

View File

@ -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)

View File

@ -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/<pid>/comment/<cid>", methods=["GET"])

View File

@ -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/<pid>", methods=["POST"])
@is_not_banned

View File

@ -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'

View File

@ -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("/@<username>/css")
def get_css(username):

View File

@ -13,9 +13,9 @@
{% for user in users %}
<tr>
<td style="font-weight:bold;">{{users.index(user)+1}}</td>
<td><a {% if user.patron %}class="patron"{% endif %} style="color:#{{user.namecolor}}; font-weight:bold;" href="/@{{user.username}}">{{user.username}}</a></td>
<td><a {% if user.animatedname %}class="{% if user.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} style="color:#{{user.namecolor}}; font-weight:bold;" href="/@{{user.username}}">{{user.username}}</a></td>
<td style="font-weight:bold;">{% if user.ban_reason %}{{user.ban_reason}}{% endif %}</td>
<td><a {% if user.banned_by.patron %}class="patron"{% endif %} style="color:#{{user.banned_by.namecolor}}; font-weight:bold;" href="/@{{user.banned_by.username}}">{{user.banned_by.username}}</a></td>
<td><a {% if user.banned_by.animatedname %}class="{% if user.banned_by.patron %}patron{% else %}leaderboard{% endif %} style="color:#{{user.banned_by.namecolor}}; font-weight:bold;" href="/@{{user.banned_by.username}}">{{user.banned_by.username}}</a></td>
</tr>
{% endfor %}
</table>

View File

@ -14,8 +14,8 @@
</thead>
{% for user in users %}
<tr>
<td><a {% if user.patron %}class="patron"{% endif %} style="font-weight:bold;color:#{{user.namecolor}};" href="/@{{user.username}}">{{user.username}}</a></td>
<td><a {% if targets[loop.index-1].patron %}class="patron"{% endif %} style="font-weight:bold;color:#{{targets[loop.index-1].namecolor}};" href="/@{{targets[loop.index-1].username}}">{{targets[loop.index-1].username}}</a></td>
<td><a {% if user.animatedname %}class="{% if user.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} style="font-weight:bold;color:#{{user.namecolor}};" href="/@{{user.username}}">{{user.username}}</a></td>
<td><a {% if targets[loop.index-1].animatedname %}class="{% if targets[loop.index-1].patron %}patron{% else %}leaderboard{% endif %}"{% endif %} style="font-weight:bold;color:#{{targets[loop.index-1].namecolor}};" href="/@{{targets[loop.index-1].username}}">{{targets[loop.index-1].username}}</a></td>
</tr>
{% endfor %}
</table>

View File

@ -125,7 +125,7 @@
{% if c.is_blocking %}<i class="fas fa-user-minus text-warning" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="You're blocking this user, but you can see this comment because {{'it\'s an admin comment' if c.distinguish_level else 'you\'re an admin'}}."></i>&nbsp;{% endif %}
{% if c.is_blocked %}<i class="fas fa-user-minus text-danger" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="This user is blocking you, but you can see this comment because {{'it\'s an admin comment' if c.distinguish_level else 'you\'re an admin'}}."></i>&nbsp;{% endif %}
{% if c.author.is_deleted %}[deleted account]{% else %}<a {% if c.author.patron %}class="patron"{% endif %} style="color:#{{c.author.namecolor}}; font-size:12px; font-weight:bold;" href="/@{{c.author.username}}">{{c.author.username}}</a>{% if c.author.customtitle %}&nbsp;<bdi style="color: #{{c.author.titlecolor}}">&nbsp;{{c.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
{% if c.author.is_deleted %}[deleted account]{% else %}<a {% if c.author.animatedname %}class="{% if c.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} style="color:#{{c.author.namecolor}}; font-size:12px; font-weight:bold;" href="/@{{c.author.username}}">{{c.author.username}}</a>{% if c.author.customtitle %}&nbsp;<bdi style="color: #{{c.author.titlecolor}}">&nbsp;{{c.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
<span id="timestamp-{{c.id}}" data-toggle="tooltip" data-placement="bottom" title="" class="time-stamp">&nbsp;{{c.age_string}}</span>
{% if c.edited_utc %}

View File

@ -337,6 +337,27 @@
</form>
</div>
<div class="d-lg-flex border-bottom">
<div class="title w-lg-25">
<label for="animatedname">Animated Username</label>
</div>
<div class="body w-lg-100">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="animatedname" name="animatedname"{% if v.animatedname%} checked{% endif %} onchange="post_toast('/settings/profile?animatedname='+document.getElementById('animatedname').checked)">
<label class="custom-control-label" for="animatedname"></label>
</div>
<span class="text-small-extra text-muted">Enable animated username (only available to users in the leaderboard and patrons)</span>
</div>
</div>
</div>

View File

@ -233,7 +233,7 @@
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">unlisted</span>{% endif %}
{% if p.is_repost %}<span class="badge border-warning border-1 text-small-extra"><a class="text-warning" href="{{p.reposts.permalink}}">repost</a></span>{% endif %}
{% if p.active_flags %}<a class="btn btn-primary" href="javascript:void(0)" style="padding:1px 5px;" onclick="document.getElementById('flaggers').classList.toggle('d-none')">{{p.active_flags}} Flags</a>{% endif %}
{% if p.author.is_deleted %}[deleted account]{% else %}&nbsp;<a {% if p.author.patron %}class="patron"{% endif %} href="{{p.author.permalink}}" style="color: #{{p.author.namecolor}}; font-weight: bold;" class="user-name">&nbsp;&nbsp;{{p.author.username}}</a>{% if p.author.customtitle %}&nbsp;<bdi style="color: #{{p.author.titlecolor}}">&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
{% if p.author.is_deleted %}[deleted account]{% else %}&nbsp;<a {% if p.author.animatedname %}class="{% if p.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} href="{{p.author.permalink}}" style="color: #{{p.author.namecolor}}; font-weight: bold;" class="user-name">&nbsp;&nbsp;{{p.author.username}}</a>{% if p.author.customtitle %}&nbsp;<bdi style="color: #{{p.author.titlecolor}}">&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
<span data-toggle="tooltip" data-placement="bottom" id="timestamp" title="">&nbsp;{{p.age_string}}</span>
({% if p.realurl(v) %}<a href="/search/posts/?q=domain%3A{{p.domain}}&sort=new&t=all" {% if v and v.newtabexternal %}target="_blank"{% endif %}>{{p.domain}}</a>{% else %}text post{% endif %})

View File

@ -141,7 +141,7 @@
{% if p.private %}<span class="text-warning"><i class="far fa-eye-slash text-small mr-1"></i>unlisted</span>&nbsp;{% endif %}
{% if p.is_repost %}<span class="text-warning"><i class="far fa-sync text-small mr-1"></i><a class="text-warning" href="{{p.reposts.permalink}}">repost</a></span>&nbsp;{% endif %}
{% if p.active_flags %}&nbsp;<a class="btn btn-primary" style="padding:1px 5px;" href="javascript:void(0)" onclick="document.getElementById('flaggers-{{p.id}}').classList.toggle('d-none')">{{p.active_flags}} Flags</a>{% endif %}
{% if p.author.is_deleted %}[deleted account]{% else %}&nbsp;<a {% if p.author.patron %}class="patron"{% endif %} href="{{p.author.permalink}}" style="color: #{{p.author.namecolor}}; font-weight: bold;; font-weight: bold;" class="user-name">{{p.author.username}}</a>{% if p.author.customtitle %}<bdi style="color: #{{p.author.titlecolor}}">&nbsp;&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}
{% if p.author.is_deleted %}[deleted account]{% else %}&nbsp;<a {% if p.author.animatedname %}class="{% if p.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} href="{{p.author.permalink}}" style="color: #{{p.author.namecolor}}; font-weight: bold;; font-weight: bold;" class="user-name">{{p.author.username}}</a>{% if p.author.customtitle %}<bdi style="color: #{{p.author.titlecolor}}">&nbsp;&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}
<span data-toggle="tooltip" data-placement="bottom" id="timestamp-{{p.id}}" title="">&nbsp;{{p.age_string}}</span>
{% endif %}&nbsp;({{p.domain}})
@ -163,7 +163,7 @@
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">unlisted</span>{% endif %}
{% if p.is_repost %}&nbsp;<span class="badge border-warning border-1 text-small-extra"><a class="text-warning" href="{{p.reposts.permalink}}">repost</a></span>{% endif %}
{% if p.active_flags %}<a class="btn btn-primary" href="javascript:void(0)" style="padding:1px 5px;" onclick="document.getElementById('flaggers-{{p.id}}').classList.toggle('d-none')">{{p.active_flags}} Flags</a>{% endif %}
{% if p.author.is_deleted %}[deleted account]{% else %}&nbsp;<a {% if p.author.patron %}class="patron"{% endif %} href="{{p.author.permalink}}" style="color: #{{p.author.namecolor}}; font-weight: bold;" class="user-name">{{p.author.username}}</a>{% if p.author.customtitle %}<bdi style="color: #{{p.author.titlecolor}}">&nbsp;&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
{% if p.author.is_deleted %}[deleted account]{% else %}&nbsp;<a {% if p.author.animatedname %}class="{% if p.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} href="{{p.author.permalink}}" style="color: #{{p.author.namecolor}}; font-weight: bold;" class="user-name">{{p.author.username}}</a>{% if p.author.customtitle %}<bdi style="color: #{{p.author.titlecolor}}">&nbsp;&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
<span data-toggle="tooltip" data-placement="bottom" id="timestamp-{{p.id}}-2" title="">&nbsp;{{p.age_string}}</span>
&nbsp;
({% if p.realurl(v) %}<a href="/search/posts/?q=domain%3A{{p.domain}}&sort=new&t=all" target="_blank">{{p.domain}}</a>{% else %}text post{% endif %})