forked from MarseyWorld/MarseyWorld
fdfd
parent
1ce5e63961
commit
a23bdfc1f6
|
@ -43,21 +43,16 @@ def flagged_posts(v):
|
|||
|
||||
page = max(1, int(request.args.get("page", 1)))
|
||||
|
||||
posts = g.db.query(Submission).filter_by(
|
||||
is_approved=0,
|
||||
is_banned=False
|
||||
).join(Submission.flags
|
||||
).options(contains_eager(Submission.flags)
|
||||
).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
|
||||
posts = g.db.query(Submission).filter_by(is_approved=0, is_banned=False).order_by(Submission.id.desc())
|
||||
posts = [p for p in posts if p.active_flags > 0]
|
||||
|
||||
listing = [p.id for p in posts]
|
||||
next_exists = (len(listing) == 26)
|
||||
listing = listing[:25]
|
||||
|
||||
listing = get_posts(listing, v=v)
|
||||
firstrange = 25 * (page - 1)
|
||||
secondrange = firstrange+26
|
||||
posts = posts[firstrange:secondrange]
|
||||
next_exists = (len(posts) == 26)
|
||||
|
||||
return render_template("admin/flagged_posts.html",
|
||||
next_exists=next_exists, listing=listing, page=page, v=v)
|
||||
next_exists=next_exists, listing=posts[:25], page=page, v=v)
|
||||
|
||||
|
||||
@app.get("/admin/image_posts")
|
||||
|
@ -80,20 +75,19 @@ def image_posts_listing(v):
|
|||
@app.get("/admin/flagged/comments")
|
||||
@admin_level_required(3)
|
||||
def flagged_comments(v):
|
||||
|
||||
page = max(1, int(request.args.get("page", 1)))
|
||||
|
||||
posts = g.db.query(Comment).filter_by(is_approved=0, is_banned=False).join(Comment.flags).options(contains_eager(Comment.flags)).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
posts = g.db.query(Comment).filter_by(is_approved=0, is_banned=False).order_by(Comment.id.desc())
|
||||
posts = [p for p in posts if p.active_flags > 0]
|
||||
|
||||
listing = [p.id for p in posts]
|
||||
next_exists = (len(listing) == 26)
|
||||
listing = listing[:25]
|
||||
|
||||
listing = get_comments(listing, v=v)
|
||||
firstrange = 25 * (page - 1)
|
||||
secondrange = firstrange+26
|
||||
posts = posts[firstrange:secondrange]
|
||||
next_exists = (len(posts) == 26)
|
||||
|
||||
return render_template("admin/flagged_comments.html",
|
||||
next_exists=next_exists,
|
||||
listing=listing,
|
||||
listing=posts,
|
||||
page=page,
|
||||
v=v,
|
||||
standalone=True)
|
||||
|
|
|
@ -73,9 +73,27 @@ def notifications(v):
|
|||
is_notification_page=True)
|
||||
|
||||
@cache.memoize()
|
||||
def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words='', **kwargs):
|
||||
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', **kwargs):
|
||||
|
||||
posts = g.db.query(Submission).options(lazyload('*'))
|
||||
|
||||
if t != 'all':
|
||||
cutoff = 0
|
||||
now = int(time.time())
|
||||
if t == 'hour':
|
||||
cutoff = now - 3600
|
||||
elif t == 'day':
|
||||
cutoff = now - 86400
|
||||
elif t == 'week':
|
||||
cutoff = now - 604800
|
||||
elif t == 'month':
|
||||
cutoff = now - 2592000
|
||||
elif t == 'year':
|
||||
cutoff = now - 31536000
|
||||
posts = posts.filter(Submission.created_utc >= cutoff)
|
||||
|
||||
posts = posts.filter_by(is_banned=False,stickied=False,private=False).filter(Submission.deleted_utc == 0)
|
||||
|
||||
posts = g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=False,stickied=False,private=False).filter(Submission.deleted_utc == 0)
|
||||
if v and v.admin_level == 0:
|
||||
blocking = g.db.query(
|
||||
UserBlock.target_id).filter_by(
|
||||
|
@ -96,21 +114,6 @@ def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words=''
|
|||
for word in filter_words:
|
||||
posts=posts.filter(not_(SubmissionAux.title.ilike(f'%{word}%')))
|
||||
|
||||
if t != 'all':
|
||||
cutoff = 0
|
||||
now = int(time.time())
|
||||
if t == 'hour':
|
||||
cutoff = now - 3600
|
||||
elif t == 'day':
|
||||
cutoff = now - 86400
|
||||
elif t == 'week':
|
||||
cutoff = now - 604800
|
||||
elif t == 'month':
|
||||
cutoff = now - 2592000
|
||||
elif t == 'year':
|
||||
cutoff = now - 31536000
|
||||
posts = posts.filter(Submission.created_utc >= cutoff)
|
||||
|
||||
gt = kwargs.get("gt")
|
||||
lt = kwargs.get("lt")
|
||||
|
||||
|
|
Loading…
Reference in New Issue