master
Aevann1 2021-09-28 21:39:51 +02:00
parent 9bf9491d96
commit e613f7864f
8 changed files with 15 additions and 44 deletions

View File

@ -422,38 +422,6 @@ class User(Base):
return output
@lazy
def alts_threaded(self, db):
subq = db.query(Alt).filter(
or_(
Alt.user1 == self.id,
Alt.user2 == self.id
)
).subquery()
data = db.query(
User,
aliased(Alt, alias=subq)
).join(
subq,
or_(
subq.c.user1 == User.id,
subq.c.user2 == User.id
)
).filter(
User.id != self.id
).order_by(User.username.asc()).all()
data = [x for x in data]
output = []
for x in data:
user = x[0]
user._is_manual = x[1].is_manual
output.append(user)
return output
def has_follower(self, user):
return g.db.query(Follow).options(lazyload('*')).filter_by(target_id=self.id, user_id=user.id).first()

View File

@ -213,7 +213,8 @@ def get_comments(cids, v=None, load_parent=False):
).filter(Comment.id.in_(cids))
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
comments = comments.join(Comment.author).filter(User.shadowbanned == False)
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()]
comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id.notin_(shadowbanned))
comments = comments.join(
votes,
@ -238,7 +239,8 @@ def get_comments(cids, v=None, load_parent=False):
output.append(comment)
else:
output = g.db.query(Comment).join(Comment.author).options(lazyload('*')).filter(Comment.id.in_(cids), User.shadowbanned == False).all()
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()]
output = g.db.query(Comment).options(lazyload('*')).filter(Comment.id.in_(cids), Comment.author_id.notin_(shadowbanned)).all()
if load_parent:
parents = [x.parent_comment_id for x in output if x.parent_comment_id]

View File

@ -244,7 +244,7 @@ def award_post(pid, v):
g.db.add(post.author)
g.db.commit()
if len(request.referrer) > 1: return redirect(request.referrer)
if request.referrer and len(request.referrer) > 1: return redirect(request.referrer)
else: return redirect("/")

View File

@ -85,7 +85,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
)
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
comments = comments.join(Comment.author).filter(User.shadowbanned == False)
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()]
comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id.notin_(shadowbanned))
if v.admin_level >=4:
comments=comments.options(joinedload(Comment.oauth_app))

View File

@ -197,7 +197,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
lt = kwargs.get("lt")
if not (v and v.shadowbanned):
posts = posts.join(Submission.author).filter(User.shadowbanned == False)
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()]
posts = g.db.query(Submission).options(lazyload('*')).filter(Submission.author_id.notin_(shadowbanned))
if sort == "hot":
ti = int(time.time()) + 3600
@ -273,7 +274,8 @@ def changeloglist(v=None, sort="new", page=1 ,t="all", **kwargs):
Submission.author_id.notin_(blocked)
)
posts=posts.filter(Submission.title.ilike(f'_changelog%', User.admin_level == 6))
admins = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.admin_level == 6).all()]
posts = posts.filter(Submission.title.ilike('_changelog%'), Submission.author_id.in_(admins))
if t != 'all':
cutoff = 0
@ -348,8 +350,6 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", **kwargs):
if not v or not v.admin_level >= 3:
comments = comments.filter_by(is_banned=False).filter(Comment.deleted_utc == 0)
comments = comments.join(posts, Comment.parent_submission == posts.c.id)
now = int(time.time())
if t == 'hour':
cutoff = now - 3600

View File

@ -114,7 +114,7 @@ def post_id(pid, anything=None, v=None):
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()]
comments = g.db.query(Comment).filter(Comment.author_id.notin_(shadowbanned))
comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id.notin_(shadowbanned))
comments = g.db.query(
Comment,

View File

@ -138,7 +138,7 @@
{% endif %}
{% endblock %}
<div class="{% if request.path == '/banned' or request.path == '/blocks' %}container-fluid{% else %}container{% endif %} mt-3 {% if request.path in ['/leaderboard', '/paypigs', '/patrons'] %}px-0{% endif %}">
<div class="{% if request.path == '/banned' or request.path == '/blocks' %}container-fluid{% else %}container{% endif %} mt-3 {% if request.path in ['/leaderboard', '/paypigs', '/patrons'] %}px-0{% elif request.path == 'changelog' %}px-2{% endif %}">
{% block content %}
{% endblock %}

View File

@ -245,7 +245,7 @@
</div>
</div>
<div class="card-footer d-md-none mt-2">
<div class="card-footer d-md-none mt-2 {% if request.path == '/changelog' %}px-0{% endif %}">
<div class="post-actions">
<ul class="list-inline text-right d-flex">
<li class="list-inline-item mr-auto">
@ -255,7 +255,7 @@
</a>
</li>
<a href="javascript:void(0);" role="button" data-clipboard-text="{% if 'rdrama' in request.host %}https://taytay.life{{p.permalink}}{% else %}{{p.permalink | full_link}}{% endif %}" style="margin-right: 15px;"><i class="fas fa-link"></i></a>
<a class="copy-link" href="javascript:void(0);" role="button" data-clipboard-text="{% if 'rdrama' in request.host %}https://taytay.life{{p.permalink}}{% else %}{{p.permalink | full_link}}{% endif %}" style="margin-right: 15px;"><i class="fas fa-link"></i></a>
{% if p.realbody(v) and request.path != "/changelog"%}
<a class="list-inline-item text-expand" href="javascript:void(0)" data-bs-id="{{p.id}}"><i class="fas fa-expand-alt mr-0 text-expand-icon-{{p.id}}"></i></a>