forked from rDrama/rDrama
Merge remote-tracking branch 'origin/master'
commit
936d93d5d3
|
@ -32,6 +32,7 @@ class User(Base, Stndrd, Age_times):
|
||||||
profileurl = Column(String, default=None)
|
profileurl = Column(String, default=None)
|
||||||
bannerurl = Column(String, default=None)
|
bannerurl = Column(String, default=None)
|
||||||
patron = Column(Boolean, default=False)
|
patron = Column(Boolean, default=False)
|
||||||
|
animatedname = Column(Boolean, default=False)
|
||||||
email = Column(String, default=None)
|
email = Column(String, default=None)
|
||||||
css = deferred(Column(String, default=None))
|
css = deferred(Column(String, default=None))
|
||||||
profilecss = deferred(Column(String, default=None))
|
profilecss = deferred(Column(String, default=None))
|
||||||
|
|
|
@ -195,6 +195,7 @@ def badge_grant_post(v):
|
||||||
|
|
||||||
if badge_id in [21,22,23,24]:
|
if badge_id in [21,22,23,24]:
|
||||||
user.patron = True
|
user.patron = True
|
||||||
|
user.animatedname = True
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
return redirect(user.permalink)
|
return redirect(user.permalink)
|
||||||
|
|
|
@ -50,7 +50,7 @@ def banawardcomment(comment_id, v):
|
||||||
comment.banaward = v.username
|
comment.banaward = v.username
|
||||||
g.db.add(comment)
|
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"])
|
@app.route("/api/v1/post/<pid>/comment/<cid>", methods=["GET"])
|
||||||
|
|
|
@ -70,7 +70,7 @@ def postbanaward(post_id, v):
|
||||||
post.banaward = v.username
|
post.banaward = v.username
|
||||||
g.db.add(post)
|
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"])
|
@app.route("/api/publish/<pid>", methods=["POST"])
|
||||||
@is_not_banned
|
@is_not_banned
|
||||||
|
|
|
@ -7,6 +7,7 @@ from drama.helpers.discord import remove_user, set_nick
|
||||||
from drama.mail import *
|
from drama.mail import *
|
||||||
from .front import frontlist
|
from .front import frontlist
|
||||||
from drama.__main__ import app, cache
|
from drama.__main__ import app, cache
|
||||||
|
from .users import leaderboard
|
||||||
import youtube_dl
|
import youtube_dl
|
||||||
|
|
||||||
valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$")
|
valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$")
|
||||||
|
@ -63,6 +64,14 @@ def settings_profile_post(v):
|
||||||
updated = True
|
updated = True
|
||||||
v.is_private = request.values.get("private", None) == '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()
|
||||||
|
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'
|
||||||
|
|
||||||
if request.values.get("nofollow", v.is_nofollow) != v.is_nofollow:
|
if request.values.get("nofollow", v.is_nofollow) != v.is_nofollow:
|
||||||
updated = True
|
updated = True
|
||||||
v.is_nofollow = request.values.get("nofollow", None) == 'true'
|
v.is_nofollow = request.values.get("nofollow", None) == 'true'
|
||||||
|
|
|
@ -25,7 +25,6 @@ def user_info(v, username):
|
||||||
user = get_user(username, v=v)
|
user = get_user(username, v=v)
|
||||||
return jsonify(user.json)
|
return jsonify(user.json)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/leaderboard", methods=["GET"])
|
@app.route("/leaderboard", methods=["GET"])
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def leaderboard(v):
|
def leaderboard(v):
|
||||||
|
@ -39,9 +38,9 @@ def leaderboard(v):
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
def leaderboard():
|
def leaderboard():
|
||||||
users = g.db.query(User).options(lazyload('*'))
|
users = g.db.query(User).options(lazyload('*'))
|
||||||
users1= sorted(users, key=lambda x: x.dramacoins, reverse=True)[:100]
|
users1= sorted(users, key=lambda x: x.dramacoins, reverse=True)[:25]
|
||||||
users2 = sorted(users1, key=lambda x: x.follower_count, reverse=True)[:10]
|
users2 = users.order_by(User.follower_count.desc()).limit(10).all()
|
||||||
return users1[:25], users2
|
return users1, users2
|
||||||
|
|
||||||
@app.get("/@<username>/css")
|
@app.get("/@<username>/css")
|
||||||
def get_css(username):
|
def get_css(username):
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="font-weight:bold;">{{users.index(user)+1}}</td>
|
<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 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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
</thead>
|
</thead>
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<tr>
|
<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 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].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 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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -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> {% endif %}
|
{% 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> {% 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> {% 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> {% 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 %} <bdi style="color: #{{c.author.titlecolor}}"> {{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 %} <bdi style="color: #{{c.author.titlecolor}}"> {{c.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
|
||||||
|
|
||||||
<span id="timestamp-{{c.id}}" data-toggle="tooltip" data-placement="bottom" title="" class="time-stamp"> {{c.age_string}}</span>
|
<span id="timestamp-{{c.id}}" data-toggle="tooltip" data-placement="bottom" title="" class="time-stamp"> {{c.age_string}}</span>
|
||||||
{% if c.edited_utc %}
|
{% if c.edited_utc %}
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<div><img src="{{v.profile_url}}" class="profile-pic-35"></div>
|
<div><img src="{{v.profile_url}}" class="profile-pic-35"></div>
|
||||||
<div class="text-left pl-2">
|
<div class="text-left pl-2">
|
||||||
<div class="text-small font-weight-bold">{{v.username}}</div>
|
<div style="color: #{{v.namecolor}}" class="text-small font-weight-bold {% if v.animatedname %}{% if v.patron %}patron{% else %}leaderboard{% endif %}{% endif %}">{{v.username}}</div>
|
||||||
<div class="text-small-extra text-purple"><i class="fad fa-diamond mr-1"></i>{{v.dramacoins}} Dramacoins</div>
|
<div class="text-small-extra text-purple"><i class="fad fa-diamond mr-1"></i>{{v.dramacoins}} Dramacoins</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -340,6 +340,24 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="body d-lg-flex border-bottom">
|
||||||
|
|
||||||
|
<label for="bio" class="text-black w-lg-25">Animated Username</label>
|
||||||
|
|
||||||
|
<div class="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 dramacoin leaderboard and patrons)</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% if not v.flairchanged %}
|
{% if not v.flairchanged %}
|
||||||
<div class="body d-lg-flex border-bottom">
|
<div class="body d-lg-flex border-bottom">
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@
|
||||||
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">unlisted</span>{% endif %}
|
{% 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.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.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 %} <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}}"> {{p.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
|
{% if p.author.is_deleted %}[deleted account]{% else %} <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}}"> {{p.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
|
||||||
<span data-toggle="tooltip" data-placement="bottom" id="timestamp" title=""> {{p.age_string}}</span>
|
<span data-toggle="tooltip" data-placement="bottom" id="timestamp" title=""> {{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 %})
|
({% 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 %})
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@
|
||||||
{% if p.private %}<span class="text-warning"><i class="far fa-eye-slash text-small mr-1"></i>unlisted</span> {% endif %}
|
{% if p.private %}<span class="text-warning"><i class="far fa-eye-slash text-small mr-1"></i>unlisted</span> {% 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> {% 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> {% endif %}
|
||||||
{% if p.active_flags %} <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.active_flags %} <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 %} <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}}"> {{p.author.customtitle | safe}}</bdi>{% endif %}
|
{% if p.author.is_deleted %}[deleted account]{% else %} <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}}"> {{p.author.customtitle | safe}}</bdi>{% endif %}
|
||||||
<span data-toggle="tooltip" data-placement="bottom" id="timestamp-{{p.id}}" title=""> {{p.age_string}}</span>
|
<span data-toggle="tooltip" data-placement="bottom" id="timestamp-{{p.id}}" title=""> {{p.age_string}}</span>
|
||||||
{% endif %} ({{p.domain}})
|
{% endif %} ({{p.domain}})
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">unlisted</span>{% endif %}
|
{% 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.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-{{p.id}}').classList.toggle('d-none')">{{p.active_flags}} Flags</a>{% 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 %} <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}}"> {{p.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
|
{% if p.author.is_deleted %}[deleted account]{% else %} <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}}"> {{p.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
|
||||||
<span data-toggle="tooltip" data-placement="bottom" id="timestamp-{{p.id}}-2" title=""> {{p.age_string}}</span>
|
<span data-toggle="tooltip" data-placement="bottom" id="timestamp-{{p.id}}-2" title=""> {{p.age_string}}</span>
|
||||||
|
|
||||||
({% 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 %})
|
({% 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 %})
|
||||||
|
|
Loading…
Reference in New Issue