dfs
This commit is contained in:
parent
96efdf55e9
commit
4b27cbad1c
6 changed files with 6 additions and 20 deletions
|
@ -1,6 +1,5 @@
|
||||||
from files.classes import *
|
from files.classes import *
|
||||||
from flask import g
|
from flask import g
|
||||||
from sqlalchemy.orm import joinedload
|
|
||||||
|
|
||||||
def get_user(username, v=None, graceful=False):
|
def get_user(username, v=None, graceful=False):
|
||||||
|
|
||||||
|
@ -83,8 +82,6 @@ def get_post(i, v=None, graceful=False, **kwargs):
|
||||||
blocking.c.id,
|
blocking.c.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
if v.admin_level>=4:
|
|
||||||
items=items.options(joinedload(Submission.oauth_app))
|
|
||||||
items=items.filter(Submission.id == i
|
items=items.filter(Submission.id == i
|
||||||
).join(
|
).join(
|
||||||
vt,
|
vt,
|
||||||
|
@ -214,7 +211,7 @@ def get_comments(cids, v=None, load_parent=False):
|
||||||
|
|
||||||
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
|
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()]
|
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.filter(Comment.author_id.notin_(shadowbanned))
|
||||||
|
|
||||||
comments = comments.join(
|
comments = comments.join(
|
||||||
votes,
|
votes,
|
||||||
|
|
|
@ -86,11 +86,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):
|
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()]
|
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.filter(Comment.author_id.notin_(shadowbanned))
|
||||||
|
|
||||||
if v.admin_level >=4:
|
|
||||||
comments=comments.options(joinedload(Comment.oauth_app))
|
|
||||||
|
|
||||||
comments=comments.filter(
|
comments=comments.filter(
|
||||||
Comment.parent_submission == post.id
|
Comment.parent_submission == post.id
|
||||||
).join(
|
).join(
|
||||||
|
|
|
@ -193,12 +193,9 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
||||||
for word in filter_words:
|
for word in filter_words:
|
||||||
posts=posts.filter(not_(Submission.title.ilike(f'%{word}%')))
|
posts=posts.filter(not_(Submission.title.ilike(f'%{word}%')))
|
||||||
|
|
||||||
gt = kwargs.get("gt")
|
|
||||||
lt = kwargs.get("lt")
|
|
||||||
|
|
||||||
if not (v and v.shadowbanned):
|
if not (v and v.shadowbanned):
|
||||||
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()]
|
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))
|
posts = posts.filter(Submission.author_id.notin_(shadowbanned))
|
||||||
|
|
||||||
if sort == "hot":
|
if sort == "hot":
|
||||||
ti = int(time.time()) + 3600
|
ti = int(time.time()) + 3600
|
||||||
|
|
|
@ -5,6 +5,7 @@ from files.helpers.const import *
|
||||||
from files.classes import *
|
from files.classes import *
|
||||||
from flask import *
|
from flask import *
|
||||||
from files.__main__ import app
|
from files.__main__ import app
|
||||||
|
from sqlalchemy.orm import joinedload
|
||||||
|
|
||||||
@app.get("/authorize")
|
@app.get("/authorize")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
|
|
@ -112,10 +112,6 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
blocked = v.blocked.subquery()
|
blocked = v.blocked.subquery()
|
||||||
|
|
||||||
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).options(lazyload('*')).filter(Comment.author_id.notin_(shadowbanned))
|
|
||||||
|
|
||||||
comments = g.db.query(
|
comments = g.db.query(
|
||||||
Comment,
|
Comment,
|
||||||
votes.c.vote_type,
|
votes.c.vote_type,
|
||||||
|
@ -126,9 +122,6 @@ def post_id(pid, anything=None, v=None):
|
||||||
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
|
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()]
|
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()]
|
||||||
comments = comments.filter(Comment.author_id.notin_(shadowbanned))
|
comments = comments.filter(Comment.author_id.notin_(shadowbanned))
|
||||||
|
|
||||||
if v.admin_level >=4:
|
|
||||||
comments=comments.options(joinedload(Comment.oauth_app))
|
|
||||||
|
|
||||||
comments=comments.filter(
|
comments=comments.filter(
|
||||||
Comment.parent_submission == post.id
|
Comment.parent_submission == post.id
|
||||||
|
|
|
@ -3,6 +3,7 @@ from files.helpers.get import *
|
||||||
from files.classes import *
|
from files.classes import *
|
||||||
from flask import *
|
from flask import *
|
||||||
from files.__main__ import app
|
from files.__main__ import app
|
||||||
|
from sqlalchemy.orm import joinedload
|
||||||
|
|
||||||
|
|
||||||
@app.get("/votes")
|
@app.get("/votes")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue