diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index 090aa3374..0ee962549 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -20,7 +20,7 @@ def post_embed(id, v): p = get_post(id, v, graceful=True) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}submission_listing.html", listing=[p], v=v) diff --git a/files/mail/__init__.py b/files/mail/__init__.py index 450bd1278..853dbb796 100644 --- a/files/mail/__init__.py +++ b/files/mail/__init__.py @@ -61,7 +61,7 @@ def activate(v): token = request.values.get("token", "").strip() if int(time.time()) - timestamp > 3600: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}message.html", v=v, title="Verification link expired.", message="That link has expired. Visit your settings to send yourself another verification email."), 410 @@ -74,7 +74,7 @@ def activate(v): abort(404) if user.is_activated and user.email == email: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}message_success.html", v=v, title="Email already verified.", message="Email already verified."), 404 @@ -90,6 +90,6 @@ def activate(v): g.db.add(user) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}message_success.html", v=v, title="Email verified.", message=f"Your email {email} has been verified. Thank you.") diff --git a/files/routes/admin.py b/files/routes/admin.py index 0df68cd63..2c6816a8b 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -45,7 +45,7 @@ def distribute(v, cid): @admin_level_required(2) def truescore(v): users = g.db.query(User).order_by(User.truecoins.desc()).limit(25).all() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}truescore.html", v=v, users=users) @@ -254,7 +254,7 @@ def post_rules(v): def shadowbanned(v): if not (v and v.admin_level > 1): abort(404) users = [x for x in g.db.query(User).filter(User.shadowbanned != None).all()] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}shadowbanned.html", v=v, users=users) @@ -264,7 +264,7 @@ def shadowbanned(v): def agendaposters(v): if not (v and v.admin_level > 1): abort(404) users = [x for x in g.db.query(User).filter_by(agendaposter = True).all()] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}agendaposters.html", v=v, users=users) @@ -284,7 +284,7 @@ def image_posts_listing(v): next_exists = (len(posts) > 25) posts = get_posts(posts[:25], v=v) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/image_posts.html", v=v, listing=posts, next_exists=next_exists, page=page, sort="new") @@ -306,7 +306,7 @@ def reported_posts(v): listing = get_posts(listing, v=v) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/reported_posts.html", next_exists=next_exists, listing=listing, page=page, v=v) @@ -330,7 +330,7 @@ def reported_comments(v): listing = get_comments(listing, v=v) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/reported_comments.html", next_exists=next_exists, @@ -344,7 +344,7 @@ def reported_comments(v): def admin_home(v): with open('disablesignups', 'r') as f: x = f.read() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/admin_home.html", v=v, x=x) @@ -370,7 +370,7 @@ def badge_grant_get(v): "no_user": "That user doesn't exist." } - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/badge_grant.html", v=v, @@ -438,7 +438,7 @@ def users_list(v): next_exists = (len(users) > 25) users = users[:25] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/new_users.html", v=v, @@ -452,7 +452,7 @@ def users_list(v): def alt_votes_get(v): if not request.values.get("u1") or not request.values.get("u2"): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/alt_votes.html", v=v) @@ -550,7 +550,7 @@ def alt_votes_get(v): data['u2_only_comment_downs'] // len( u2_comment_downs) if u2_comment_downs else 0 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/alt_votes.html", u1=u1, @@ -597,7 +597,7 @@ def admin_removed(v): posts = get_posts(ids, v=v) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/removed_posts.html", v=v, @@ -623,7 +623,7 @@ def admin_removed_comments(v): comments = get_comments(ids, v=v) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/removed_comments.html", v=v, @@ -1126,7 +1126,7 @@ def admin_dump_cache(v): def admin_banned_domains(v): banned_domains = g.db.query(BannedDomain).all() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/banned_domains.html", v=v, banned_domains=banned_domains) diff --git a/files/routes/awards.py b/files/routes/awards.py index 1db10fb22..8e043844e 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -69,7 +69,7 @@ def shop(v): val["price"] = int(val["price"]*discount) sales = g.db.query(Vote.id).count() + g.db.query(CommentVote.id).count() - g.db.query(func.sum(User.coins)).scalar() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}shop.html", awards=list(AWARDS.values()), v=v, sales=sales) @@ -505,7 +505,7 @@ def award_comment(cid, v): @app.get("/admin/awards") @admin_level_required(2) def admin_userawards_get(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' if v.admin_level != 3: @@ -518,7 +518,7 @@ def admin_userawards_get(v): @admin_level_required(2) @validate_formkey def admin_userawards_post(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' try: u = request.values.get("username").strip() diff --git a/files/routes/comments.py b/files/routes/comments.py index ecd7d447a..1ecf12668 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -602,7 +602,7 @@ def api_comment(v): g.db.commit() if request.headers.get("Authorization"): return c.json - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}comments.html", v=v, comments=[c]) @@ -686,7 +686,7 @@ def edit_comment(cid, v): if ban.reason: reason += f" {ban.reason}" if request.headers.get("Authorization"): return {'error': f'A blacklisted domain was used.'}, 400 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}comment_failed.html", action=f"/edit_comment/{c.id}", diff --git a/files/routes/discord.py b/files/routes/discord.py index 8ae79db89..bc382fc06 100644 --- a/files/routes/discord.py +++ b/files/routes/discord.py @@ -98,7 +98,7 @@ def discord_redirect(v): requests.delete(url, headers=headers, timeout=5) if g.db.query(User).filter(User.id!=v.id, User.discord_id==x["id"]).first(): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}message.html", title="Discord account already linked.", error="That Discord account is already in use by another user.", v=v) diff --git a/files/routes/front.py b/files/routes/front.py index bbe8395ac..2e18b5b8b 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -107,7 +107,7 @@ def notifications(v): if request.headers.get("Authorization"): return {"data":[x.json for x in listing]} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}notifications.html", v=v, @@ -192,7 +192,7 @@ def front_all(v): g.db.commit() if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page) @@ -303,7 +303,7 @@ def changelog(v): posts = get_posts(ids, v=v) if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}changelog.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page) @@ -447,6 +447,6 @@ def all_comments(v): idlist = idlist[:25] if request.headers.get("Authorization"): return {"data": [x.json for x in comments]} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}home_comments.html", v=v, sort=sort, t=t, page=page, comments=comments, standalone=True, next_exists=next_exists) \ No newline at end of file diff --git a/files/routes/login.py b/files/routes/login.py index 80dd26478..1aecccb90 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -16,7 +16,7 @@ def login_get(v): if v: return redirect(redir) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}login.html", failed=False, @@ -190,7 +190,7 @@ def sign_up_get(v): ref_user = None if ref_user and (ref_user.id in session.get("history", [])): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}sign_up_failed_ref.html") @@ -209,7 +209,7 @@ def sign_up_get(v): error = request.values.get("error", None) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}sign_up.html", formkey=formkey, @@ -459,7 +459,7 @@ def post_reset(v): now = int(time.time()) if now - timestamp > 600: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}message.html", title="Password reset expired", @@ -473,7 +473,7 @@ def post_reset(v): abort(404) if not password == confirm_password: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}reset_password.html", v=user, @@ -486,7 +486,7 @@ def post_reset(v): g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}message_success.html", title="Password reset successful!", diff --git a/files/routes/oauth.py b/files/routes/oauth.py index cf37f208d..fb29effab 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -13,7 +13,7 @@ def authorize_prompt(v): client_id = request.values.get("client_id") application = g.db.query(OauthApp).filter_by(client_id=client_id).first() if not application: return {"oauth_error": "Invalid `client_id`"}, 401 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}oauth.html", v=v, application=application) @@ -208,7 +208,7 @@ def admin_app_id(v, aid): posts=get_posts(pids, v=v) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/app.html", v=v, @@ -237,7 +237,7 @@ def admin_app_id_comments(v, aid): comments=get_comments(cids, v=v) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/app.html", v=v, @@ -254,7 +254,7 @@ def admin_apps_list(v): apps = g.db.query(OauthApp).all() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/apps.html", v=v, apps=apps) diff --git a/files/routes/posts.py b/files/routes/posts.py index acac27771..4987fd2a8 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -81,7 +81,7 @@ def publish(pid, v): @auth_required def submit_get(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}submit.html", v=v) @@ -92,7 +92,7 @@ def submit_get(v): @app.get("/logged_out/post//") @auth_desired def post_id(pid, anything=None, v=None): - if v and v.oldsite: template2 = '' + if not v or v.oldsite: template2 = '' else: template2 = 'CHRISTMAS/' if not v and not request.path.startswith('/logged_out') and not request.headers.get("Authorization"): return redirect(f"/logged_out{request.full_path}") @@ -324,7 +324,7 @@ def viewmore(v, pid, sort, offset): if len(comments) == len(comments2): offset = None comments = comments2 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}comments.html", v=v, comments=comments, render_replies=True, pid=pid, sort=sort, offset=offset) @@ -371,7 +371,7 @@ def morecomments(v, cid): c = g.db.query(Comment).filter_by(id=cid).first() comments = c.replies - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}comments.html", v=v, comments=comments, render_replies=True) @@ -786,7 +786,7 @@ def submit_post(v): domain_obj = get_domain(domain) if domain_obj: if request.headers.get("Authorization"): return {"error":domain_obj.reason}, 400 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}submit.html", v=v, error=domain_obj.reason, title=title, url=url, body=request.values.get("body", "")), 400 elif "twitter.com" == domain: @@ -809,13 +809,13 @@ def submit_post(v): if not url and not request.values.get("body") and not request.files.get("file", None): if request.headers.get("Authorization"): return {"error": "`url` or `body` parameter required."}, 400 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}submit.html", v=v, error="Please enter a url or some text.", title=title, url=url, body=request.values.get("body", "")), 400 if not title: if request.headers.get("Authorization"): return {"error": "Please enter a better title"}, 400 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}submit.html", v=v, error="Please enter a better title.", title=title, url=url, body=request.values.get("body", "")), 400 @@ -907,14 +907,14 @@ def submit_post(v): if len(str(body)) > 10000: if request.headers.get("Authorization"): return {"error":"10000 character limit for text body."}, 400 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}submit.html", v=v, error="10000 character limit for text body.", title=title, url=url, body=request.values.get("body", "")), 400 if len(url) > 2048: if request.headers.get("Authorization"): return {"error":"2048 character limit for URLs."}, 400 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}submit.html", v=v, error="2048 character limit for URLs.", title=title, url=url,body=request.values.get("body", "")), 400 @@ -951,7 +951,7 @@ def submit_post(v): body += f"\n\n{url}" else: if request.headers.get("Authorization"): return {"error": f"Image/Video files only"}, 400 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}submit.html", v=v, error=f"Image/Video files only."), 400 @@ -972,7 +972,7 @@ def submit_post(v): reason = f"Remove the {ban.domain} link from your post and try again." if ban.reason: reason += f" {ban.reason}" if request.headers.get("Authorization"): return {"error": reason}, 403 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}submit.html", v=v, error=reason, title=title, url=url, body=request.values.get("body", "")), 403 @@ -1034,7 +1034,7 @@ def submit_post(v): if not file.content_type.startswith(('image/', 'video/')): if request.headers.get("Authorization"): return {"error": f"File type not allowed"}, 400 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}submit.html", v=v, error=f"File type not allowed.", title=title, body=request.values.get("body", "")), 400 diff --git a/files/routes/search.py b/files/routes/search.py index 0f196602f..05c79a902 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -161,7 +161,7 @@ def searchposts(v): domain_obj=None if request.headers.get("Authorization"): return {"total":total, "data":[x.json for x in posts]} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}search.html", v=v, @@ -253,7 +253,7 @@ def searchcomments(v): comments = get_comments(ids, v=v) if request.headers.get("Authorization"): return {"total":total, "data":[x.json for x in comments]} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}search_comments.html", v=v, query=query, total=total, page=page, comments=comments, sort=sort, t=t, next_exists=next_exists) @@ -284,6 +284,6 @@ def searchusers(v): if request.headers.get("Authorization"): return [x.json for x in users] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}search_users.html", v=v, query=query, total=total, page=page, users=users, sort=sort, t=t, next_exists=next_exists) \ No newline at end of file diff --git a/files/routes/settings.py b/files/routes/settings.py index 5cc689a28..c64b658de 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -126,7 +126,7 @@ def settings_profile_post(v): v.bio_html = None g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, msg="Your bio has been updated.") @@ -135,7 +135,7 @@ def settings_profile_post(v): v.sig_html = None g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, msg="Your sig has been updated.") @@ -144,7 +144,7 @@ def settings_profile_post(v): v.friends_html = None g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, msg="Your friends list has been updated.") @@ -153,7 +153,7 @@ def settings_profile_post(v): v.enemies_html = None g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, msg="Your enemies list has been updated.") @@ -177,7 +177,7 @@ def settings_profile_post(v): return {"error": reason}, 401 if len(sig_html) > 1000: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -187,7 +187,7 @@ def settings_profile_post(v): v.sig_html=sig_html g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -213,7 +213,7 @@ def settings_profile_post(v): return {"error": reason}, 401 if len(friends_html) > 2000: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -234,7 +234,7 @@ def settings_profile_post(v): v.friends_html=friends_html g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -258,7 +258,7 @@ def settings_profile_post(v): return {"error": reason}, 401 if len(enemies_html) > 2000: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -280,7 +280,7 @@ def settings_profile_post(v): v.enemies_html=enemies_html g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -307,7 +307,7 @@ def settings_profile_post(v): bio += f"\n\n{url}" else: if request.headers.get("Authorization"): return {"error": f"Image/Video files only"}, 400 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, error=f"Image/Video files only."), 400 @@ -316,7 +316,7 @@ def settings_profile_post(v): bans = filter_comment_html(bio_html) if len(bio_html) > 10000: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -347,7 +347,7 @@ def settings_profile_post(v): v.bio_html=bio_html g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -445,14 +445,14 @@ def filters(v): filters=request.values.get("filters")[:1000].strip() if filters == v.custom_filter_list: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_filters.html", v=v, error="You didn't change anything") v.custom_filter_list=filters g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_filters.html", v=v, msg="Your custom filters have been updated.") @@ -474,7 +474,7 @@ def changelogsub(v): @auth_required @validate_formkey def namecolor(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' color = str(request.values.get("color", "")).strip() @@ -490,7 +490,7 @@ def namecolor(v): @auth_required @validate_formkey def themecolor(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' themecolor = str(request.values.get("themecolor", "")).strip() @@ -530,7 +530,7 @@ def gumroad(v): response = requests.get('https://api.gumroad.com/v2/sales', data=data, timeout=5).json()["sales"][0] tier = tiers[response["variants_and_quantity"]] - + if v.patron == tier: return {"error": f"{patron} rewards already claimed"}, 400 existing = g.db.query(User.id).filter_by(email=v.email, is_activated=True, patron=tier).one_or_none() @@ -570,7 +570,7 @@ def gumroad(v): @auth_required @validate_formkey def titlecolor(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' titlecolor = str(request.values.get("titlecolor", "")).strip() @@ -586,7 +586,7 @@ def titlecolor(v): @auth_required @validate_formkey def verifiedcolor(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' verifiedcolor = str(request.values.get("verifiedcolor", "")).strip() @@ -718,7 +718,7 @@ def settings_log_out_others(v): submitted_password = request.values.get("password", "").strip() if not v.verifyPass(submitted_password): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_security.html", v=v, error="Incorrect Password"), 401 @@ -730,7 +730,7 @@ def settings_log_out_others(v): g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_security.html", v=v, msg="All other devices have been logged out") @@ -768,7 +768,7 @@ def settings_images_profile(v): g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, msg="Profile picture successfully updated.") @@ -796,7 +796,7 @@ def settings_images_banner(v): g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, msg="Banner successfully updated.") @@ -812,7 +812,7 @@ def settings_delete_profile(v): g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, msg="Profile picture successfully removed.") @@ -828,7 +828,7 @@ def settings_delete_banner(v): g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, msg="Banner successfully removed.") @@ -837,7 +837,7 @@ def settings_delete_banner(v): @auth_required def settings_blockedpage(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_blocks.html", v=v) @@ -845,7 +845,7 @@ def settings_blockedpage(v): @auth_required def settings_css_get(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_css.html", v=v) @@ -860,7 +860,7 @@ def settings_css(v): g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_css.html", v=v) @@ -869,7 +869,7 @@ def settings_css(v): def settings_profilecss_get(v): if v.truecoins < 1000 and not v.patron and v.admin_level == 0 : return f"You must have +1000 {COINS_NAME} or be a paypig to set profile css." - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profilecss.html", v=v) @@ -884,7 +884,7 @@ def settings_profilecss(v): g.db.add(v) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profilecss.html", v=v) @@ -954,7 +954,7 @@ def settings_unblock_user(v): @auth_required def settings_apps(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_apps.html", v=v) @@ -978,7 +978,7 @@ def settings_remove_discord(v): @auth_required def settings_content_get(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_filters.html", v=v) @@ -993,14 +993,14 @@ def settings_name_change(v): new_name=request.values.get("name").strip() if new_name==v.username: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, error="You didn't change anything") if not re.match(valid_username_regex, new_name): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -1016,7 +1016,7 @@ def settings_name_change(v): ).first() if x and x.id != v.id: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -1054,7 +1054,7 @@ def settings_song_change(v): id = song.split("v=")[1] elif song.startswith("https://youtu.be/"): id = song.split("https://youtu.be/")[1] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, error=f"Not a youtube link.") @@ -1071,19 +1071,19 @@ def settings_song_change(v): req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json() duration = req['items'][0]['contentDetails']['duration'] if duration == 'P0D': - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, error=f"Can't use a live youtube video!") if "H" in duration: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, error=f"Duration of the video must not exceed 10 minutes.") if "M" in duration: duration = int(duration.split("PT")[1].split("M")[0]) if duration > 10: - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, error=f"Duration of the video must not exceed 10 minutes.") @@ -1105,7 +1105,7 @@ def settings_song_change(v): try: ydl.download([f"https://youtube.com/watch?v={id}"]) except Exception as e: print(e) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v, @@ -1128,7 +1128,7 @@ def settings_song_change(v): @auth_required @validate_formkey def settings_title_change(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' if v.flairchanged: abort(403) diff --git a/files/routes/static.py b/files/routes/static.py index 504a3d6ca..27797366e 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -16,7 +16,7 @@ site_name = environ.get("SITE_NAME").strip() @auth_desired def emojis(v): emojis = (x.replace('.webp','') for x in os.listdir("files/assets/images/emojis")) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}emojis.html", v=v, emojis=emojis) @@ -70,7 +70,7 @@ def participation_stats(v): } - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admin/content_stats.html", v=v, title="Content Statistics", data=data) @@ -161,7 +161,7 @@ def cached_chart(days): def patrons(v): users = g.db.query(User).filter(User.patron > 0).order_by(User.patron.desc(), User.id).all() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}patrons.html", v=v, users=users) @@ -170,7 +170,7 @@ def patrons(v): @auth_desired def admins(v): admins = g.db.query(User).filter(User.admin_level>0).order_by(User.truecoins.desc()).all() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}admins.html", v=v, admins=admins) @@ -205,7 +205,7 @@ def log(v): admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level > 1).all()] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}log.html", v=v, admins=admins, types=types, admin=admin, type=kind, actions=actions, next_exists=next_exists, page=page) @@ -231,7 +231,7 @@ def log_item(id, v): if v and v.admin_level > 1: types = ACTIONTYPES else: types = ACTIONTYPES2 - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}log.html", v=v, actions=[action], next_exists=False, page=1, action=action, admins=admins, types=types) @@ -242,7 +242,7 @@ def favicon(): @app.get("/api") @auth_desired def api(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}api.html", v=v) @@ -252,7 +252,7 @@ def api(v): @auth_required def contact(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}contact.html", v=v) @@ -264,7 +264,7 @@ def submit_contact(v): message = f'This message has been sent automatically to all admins via [/contact](/contact), user email is "{v.email}"\n\nMessage:\n\n' + request.values.get("message", "") send_admin(v.id, message) g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}contact.html", v=v, msg="Your message has been sent.") @@ -336,7 +336,7 @@ def settings(v): def settings_profile(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_profile.html", v=v) @@ -344,7 +344,7 @@ def settings_profile(v): @app.get("/badges") @auth_desired def badges(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}badges.html", v=v, badges=BADGES) @@ -360,7 +360,7 @@ def blocks(v): users.append(get_account(x.user_id)) targets.append(get_account(x.target_id)) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}blocks.html", v=v, users=users, targets=targets) @@ -369,7 +369,7 @@ def blocks(v): def banned(v): users = [x for x in g.db.query(User).filter(User.is_banned > 0, User.unban_utc == 0).all()] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}banned.html", v=v, users=users) @@ -377,7 +377,7 @@ def banned(v): @auth_desired def formatting(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}formatting.html", v=v) @@ -390,7 +390,7 @@ def serviceworker(): def settings_security(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}settings_security.html", v=v, diff --git a/files/routes/users.py b/files/routes/users.py index 9afc5111d..7d99c4a1c 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -35,7 +35,7 @@ def upvoters(v, username): users = sorted(users2, key=lambda x: x[1], reverse=True)[:25] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}voters.html", v=v, users=users, name='Up', name2=f'@{username} biggest simps') @@ -56,7 +56,7 @@ def downvoters(v, username): users = sorted(users2, key=lambda x: x[1], reverse=True)[:25] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}voters.html", v=v, users=users, name='Down', name2=f'@{username} biggest haters') @@ -77,7 +77,7 @@ def upvoting(v, username): users = sorted(users2, key=lambda x: x[1], reverse=True)[:25] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}voters.html", v=v, users=users, name='Up', name2=f'Who @{username} simps for') @@ -98,7 +98,7 @@ def downvoting(v, username): users = sorted(users2, key=lambda x: x[1], reverse=True)[:25] - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}voters.html", v=v, users=users, name='Down', name2=f'Who @{username} hates') @@ -162,7 +162,7 @@ def steal(v): @auth_desired def rentoids(v): users = g.db.query(User).filter(User.rent_utc > 0).all() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}rentoids.html", v=v, users=users) @@ -173,7 +173,7 @@ def thiefs(v): successful = g.db.query(User).filter(User.steal_utc > 0).all() failed = g.db.query(User).filter(User.fail_utc > 0).all() failed2 = g.db.query(User).filter(User.fail2_utc > 0).all() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}thiefs.html", v=v, successful=successful, failed=failed, failed2=failed2) @@ -287,10 +287,10 @@ def leaderboard(v): if 'pcmemes.net' == request.host: users6 = users.order_by(User.basedcount.desc()).limit(10).all() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6, users7=users7, users9=users9) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users7=users7, users9=users9) @@ -453,7 +453,7 @@ def messagereply(v): g.db.commit() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}comments.html", v=v, comments=[new_comment]) @@ -514,7 +514,7 @@ def followers(username, v): # if 'rdrama.net' in request.host and u.id == 147: abort(404) ids = [x[0] for x in g.db.query(Follow.user_id).filter_by(target_id=u.id).all()] users = g.db.query(User).filter(User.id.in_(ids)).all() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}followers.html", v=v, u=u, users=users) @@ -525,19 +525,19 @@ def following(username, v): # if 'rdrama.net' in request.host and u.id == 147: abort(404) ids = [x[0] for x in g.db.query(Follow.target_id).filter_by(user_id=u.id).all()] users = g.db.query(User).filter(User.id.in_(ids)).all() - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}following.html", v=v, u=u, users=users) @app.get("/views") @auth_required def visitors(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' if 'rdrama.net' in request.host and v.admin_level < 1 and not v.patron: return render_template(f"{template}errors/patron.html", v=v) viewers=sorted(v.viewers, key = lambda x: x.last_view_utc, reverse=True) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}viewers.html", v=v, viewers=viewers) @@ -562,7 +562,7 @@ def u_username(username, v=None): if u.reserved: if request.headers.get("Authorization"): return {"error": f"That username is reserved for: {u.reserved}"} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_reserved.html", u=u, v=v) @@ -589,26 +589,26 @@ def u_username(username, v=None): if v and u.id == LLM_ID: if int(time.time()) - v.rent_utc > 600: if request.headers.get("Authorization"): return {"error": "That userpage is private"} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_private.html", time=int(time.time()), u=u, v=v) else: if request.headers.get("Authorization"): return {"error": "That userpage is private"} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_private.html", time=int(time.time()), u=u, v=v) if v and hasattr(u, 'is_blocking') and u.is_blocking: if request.headers.get("Authorization"): return {"error": f"You are blocking @{u.username}."} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_blocking.html", u=u, v=v) if v and v.admin_level < 2 and hasattr(u, 'is_blocked') and u.is_blocked: if request.headers.get("Authorization"): return {"error": "This person is blocking you."} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_blocked.html", u=u, v=v) @@ -634,7 +634,7 @@ def u_username(username, v=None): if u.unban_utc: if request.headers.get("Authorization"): {"data": [x.json for x in listing]} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage.html", unban=u.unban_string, @@ -650,7 +650,7 @@ def u_username(username, v=None): if request.headers.get("Authorization"): return {"data": [x.json for x in listing]} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage.html", u=u, @@ -684,7 +684,7 @@ def u_username_comments(username, v=None): if u.reserved: if request.headers.get("Authorization"): return {"error": f"That username is reserved for: {u.reserved}"} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_reserved.html", u=u, @@ -695,24 +695,24 @@ def u_username_comments(username, v=None): if v and u.id == LLM_ID: if int(time.time()) - v.rent_utc > 600: if request.headers.get("Authorization"): return {"error": "That userpage is private"} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_private.html", time=int(time.time()), u=u, v=v) else: if request.headers.get("Authorization"): return {"error": "That userpage is private"} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_private.html", time=int(time.time()), u=u, v=v) if v and hasattr(u, 'is_blocking') and u.is_blocking: if request.headers.get("Authorization"): return {"error": f"You are blocking @{u.username}."} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_blocking.html", u=u, v=v) if v and v.admin_level < 2 and hasattr(u, 'is_blocked') and u.is_blocked: if request.headers.get("Authorization"): return {"error": "This person is blocking you."} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_blocked.html", u=u, v=v) @@ -765,7 +765,7 @@ def u_username_comments(username, v=None): is_following = (v and user.has_follower(v)) if request.headers.get("Authorization"): return {"data": [c.json for c in listing]} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_comments.html", u=user, v=v, listing=listing, page=page, sort=sort, t=t,next_exists=next_exists, is_following=is_following, standalone=True) @@ -893,7 +893,7 @@ def saved_posts(v, username): listing = get_posts(ids, v=v) if request.headers.get("Authorization"): return {"data": [x.json for x in listing]} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage.html", u=v, @@ -923,7 +923,7 @@ def saved_comments(v, username): if request.headers.get("Authorization"): return {"data": [x.json for x in listing]} - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}userpage_comments.html", u=v, diff --git a/files/routes/votes.py b/files/routes/votes.py index 3eece9126..42b454dd0 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -15,7 +15,7 @@ defaultcolor = environ.get("DEFAULT_COLOR").strip() @limiter.limit("5/second;60/minute;200/hour") @auth_desired def admin_vote_info_get(v): - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' if v and v.shadowbanned: return render_template('errors/500.html', error=True, v=v), 500 @@ -57,7 +57,7 @@ def admin_vote_info_get(v): else: abort(400) - if v and v.oldsite: template = '' + if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' return render_template(f"{template}votes.html", v=v,