From c53c916e6e13ceedbcf4cf68c52826bbe24a03d7 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 21 Feb 2022 08:24:35 +0200 Subject: [PATCH] cv --- files/routes/front.py | 32 ++++++++++++++++++++------------ files/templates/home.html | 26 ++++++++++++++++---------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index b805f2af4..31a3c1dbe 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -162,6 +162,7 @@ def front_all(v, sub=None): sort=request.values.get("sort", defaultsorting) t=request.values.get('t', defaulttime) ccmode=request.values.get('ccmode', "false") + subs=request.values.get('subs', "false") try: gt=int(request.values.get("utc_greater_than", 0)) except: gt=0 @@ -174,6 +175,7 @@ def front_all(v, sub=None): t=t, v=v, ccmode=ccmode, + subs=subs, filter_words=v.filter_words if v else [], gt=gt, lt=lt, @@ -259,22 +261,25 @@ def front_all(v, sub=None): g.db.commit() if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists} - return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, ccmode=ccmode, sub=sub, home=True) + return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, ccmode=ccmode, subs=subs, sub=sub, home=True) @cache.memoize(timeout=86400) -def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", filter_words='', gt=0, lt=0, sub=None, site=None): +def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", subs="false", filter_words='', gt=0, lt=0, sub=None, site=None): posts = g.db.query(Submission) if sub: posts = posts.filter_by(sub=sub.name) - elif SITE_NAME == 'Drama': posts = posts.filter(Submission.sub == None) + elif subs == "true": + if v and v.all_blocks: posts = posts.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) else: - if SITE_NAME == 'Ruqqus': - posts = posts.filter(Submission.sub != None) - if v and v.all_blocks: posts = posts.filter(Submission.sub.notin_(v.all_blocks)) - elif v and v.all_blocks: posts = posts.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) + if SITE_NAME == 'Drama': posts = posts.filter(Submission.sub == None) + else: + if SITE_NAME == 'Ruqqus': + posts = posts.filter(Submission.sub != None) + if v and v.all_blocks: posts = posts.filter(Submission.sub.notin_(v.all_blocks)) + elif v and v.all_blocks: posts = posts.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) if gt: posts = posts.filter(Submission.created_utc > gt) if lt: posts = posts.filter(Submission.created_utc < lt) @@ -348,12 +353,15 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" if (sort == "hot" or (v and v.id == Q_ID)) and page == 1 and ccmode == "false" and not gt and not lt: pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False) if sub: pins = pins.filter_by(sub=sub.name) - elif SITE_NAME == 'Drama': pins = pins.filter(Submission.sub == None) + elif subs == "true": + if v and v.all_blocks: posts = posts.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) else: - if SITE_NAME == 'Ruqqus': - pins = pins.filter(Submission.sub != None) - if v and v.all_blocks: pins = pins.filter(Submission.sub.notin_(v.all_blocks)) - elif v and v.all_blocks: pins = pins.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) + if SITE_NAME == 'Drama': pins = pins.filter(Submission.sub == None) + else: + if SITE_NAME == 'Ruqqus': + pins = pins.filter(Submission.sub != None) + if v and v.all_blocks: pins = pins.filter(Submission.sub.notin_(v.all_blocks)) + elif v and v.all_blocks: pins = pins.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) if v and v.admin_level == 0: blocking = [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=v.id).all()] diff --git a/files/templates/home.html b/files/templates/home.html index f5f7c15f1..7ae976086 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -43,8 +43,14 @@
{% if request.path == '/' and v.paid_dues %} - {% if ccmode=="true"%}CC Mode: Activated{% endif %} - {% if ccmode=="false" %}CC Mode{% endif %} + {% if ccmode=="true"%}CC{% endif %} + {% if ccmode=="false" %}CC{% endif %} +
+ {% endif %} + + {% if request.path == '/' and v and v.admin_level > 1 %} + {% if subs=="true"%}Subs{% endif %} + {% if subs=="false" %}Subs{% endif %}
{% endif %} @@ -60,12 +66,12 @@ {{t | capitalize}} @@ -155,14 +161,14 @@