From 20306e5d120d5bbfe0d94f84691a0155559a432b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 1 Nov 2021 20:25:10 +0200 Subject: [PATCH] fdsfds --- files/helpers/const.py | 19 +++---- files/routes/admin.py | 4 +- files/routes/awards.py | 66 ++++++++++++++----------- files/routes/comments.py | 1 - files/routes/posts.py | 6 +-- files/routes/search.py | 2 +- files/routes/settings.py | 2 +- files/templates/authforms.html | 4 +- files/templates/comments.html | 2 +- files/templates/default.html | 4 +- files/templates/log.html | 4 +- files/templates/login_2fa.html | 2 +- files/templates/settings.html | 2 +- files/templates/settings2.html | 4 +- files/templates/sign_up.html | 2 +- files/templates/sign_up_failed_ref.html | 4 +- files/templates/submission.html | 18 ++++--- files/templates/submit.html | 4 +- files/templates/userpage.html | 4 +- 19 files changed, 82 insertions(+), 72 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 4bc2b6564..0e0768d90 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -53,7 +53,6 @@ SLURS = { "tenant": "renthog", "renter": "rentoid", "autistic": "neurodivergent", - "anime": "p-dophilic japanese cartoons", "holohoax": "i tried to claim the Holocaust didn't happen because I am a pencil-dicked imbecile and the word filter caught me lol", "groomercord": "discord (actually a pretty cool service)", "pedocord": "discord (actually a pretty cool service)", @@ -62,8 +61,6 @@ SLURS = { "gamer": "g*mer", "journalist": "journ*list", "journalism": "journ*lism", - "buttcheeks": "bulva", - "asscheeks": "bulva", "wuhan flu": "SARS-CoV-2 syndemic", "china flu": "SARS-CoV-2 syndemic", "china virus": "SARS-CoV-2 syndemic", @@ -150,7 +147,7 @@ if SITE_NAME == "Drama": "shit": { "kind": "shit", "title": "Shit", - "description": "Makes flies swarm a post.", + "description": "Makes flies swarm the post.", "icon": "fas fa-poop", "color": "text-black-50", "price": 500 @@ -158,7 +155,7 @@ if SITE_NAME == "Drama": "fireflies": { "kind": "fireflies", "title": "Fireflies", - "description": "Puts fireflies on the post.", + "description": "Makes fireflies swarm the post.", "icon": "fas fa-sparkles", "color": "text-warning", "price": 500 @@ -174,7 +171,7 @@ if SITE_NAME == "Drama": "pin": { "kind": "pin", "title": "1-Hour Pin", - "description": "Pins the post.", + "description": "Pins the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-warning", "price": 750 @@ -182,7 +179,7 @@ if SITE_NAME == "Drama": "unpin": { "kind": "unpin", "title": "1-Hour Unpin", - "description": "Removes 1 hour from the pin duration of the post.", + "description": "Removes 1 hour from the pin duration of the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-black", "price": 1000 @@ -257,7 +254,7 @@ else: "shit": { "kind": "shit", "title": "Shit", - "description": "Makes flies swarm a post.", + "description": "Makes flies swarm the post.", "icon": "fas fa-poop", "color": "text-black-50", "price": 500 @@ -265,7 +262,7 @@ else: "fireflies": { "kind": "fireflies", "title": "Fireflies", - "description": "Puts fireflies on the post.", + "description": "Makes fireflies swarm the post.", "icon": "fas fa-sparkles", "color": "text-warning", "price": 500 @@ -281,7 +278,7 @@ else: "pin": { "kind": "pin", "title": "1-Hour Pin", - "description": "Pins the post.", + "description": "Pins the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-warning", "price": 750 @@ -289,7 +286,7 @@ else: "unpin": { "kind": "unpin", "title": "1-Hour Unpin", - "description": "Removes 1 hour from the pin duration of the post.", + "description": "Removes 1 hour from the pin duration of the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-black", "price": 1000 diff --git a/files/routes/admin.py b/files/routes/admin.py index 9a44861d8..542565529 100755 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -357,13 +357,13 @@ def badge_grant_post(v): except: abort(400) if user.has_badge(badge_id): - g.db.query(Badge).options(lazyload('*')).filter_by(badge_id=badge_id, user_id=user.id,).delete() + g.db.delete(g.db.query(Badge).options(lazyload('*')).filter_by(badge_id=badge_id, user_id=user.id)) g.db.commit() return redirect("/admin/badge_grant") if badge_id == 16: badge = user.has_badge(17) - if badge: badge.delete() + if badge: g.db.delete(badge) elif badge_id == 17 and user.has_badge(16): abort(403) diff --git a/files/routes/awards.py b/files/routes/awards.py index 6bf67b201..ffd767bc0 100755 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -8,6 +8,14 @@ from .front import frontlist from flask import g, request from files.helpers.sanitize import filter_title +discounts = { + 69: 0.02, + 70: 0.04, + 71: 0.06, + 72: 0.08, + 73: 0.10, +} + AWARDS2 = { "ban": { "kind": "ban", @@ -20,7 +28,7 @@ AWARDS2 = { "fireflies": { "kind": "fireflies", "title": "Fireflies", - "description": "Puts fireflies on the post.", + "description": "Makes fireflies swarm the post.", "icon": "fas fa-sparkles", "color": "text-warning", "price": 500 @@ -28,7 +36,7 @@ AWARDS2 = { "shit": { "kind": "shit", "title": "Shit", - "description": "Makes flies swarm a post.", + "description": "Makes flies swarm the post.", "icon": "fas fa-poop", "color": "text-black-50", "price": 500 @@ -44,7 +52,7 @@ def shop(v): "shit": { "kind": "shit", "title": "Shit", - "description": "Makes flies swarm a post.", + "description": "Makes flies swarm the post.", "icon": "fas fa-poop", "color": "text-black-50", "owned": 0, @@ -53,7 +61,7 @@ def shop(v): "fireflies": { "kind": "fireflies", "title": "Fireflies", - "description": "Puts fireflies on the post.", + "description": "Makes fireflies swarm the post.", "icon": "fas fa-sparkles", "color": "text-warning", "owned": 0, @@ -71,7 +79,7 @@ def shop(v): "pin": { "kind": "pin", "title": "1-Hour Pin", - "description": "Pins the post.", + "description": "Pins the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-warning", "owned": 0, @@ -80,7 +88,7 @@ def shop(v): "unpin": { "kind": "unpin", "title": "1-Hour Unpin", - "description": "Removes 1 hour from the pin duration of the post.", + "description": "Removes 1 hour from the pin duration of the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-black", "owned": 0, @@ -164,7 +172,7 @@ def shop(v): "shit": { "kind": "shit", "title": "Shit", - "description": "Makes flies swarm a post.", + "description": "Makes flies swarm the post.", "icon": "fas fa-poop", "color": "text-black-50", "owned": 0, @@ -173,7 +181,7 @@ def shop(v): "fireflies": { "kind": "fireflies", "title": "Fireflies", - "description": "Puts fireflies on the post.", + "description": "Makes fireflies swarm the post.", "icon": "fas fa-sparkles", "color": "text-warning", "owned": 0, @@ -191,7 +199,7 @@ def shop(v): "pin": { "kind": "pin", "title": "1-Hour Pin", - "description": "Pins the post.", + "description": "Pins the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-warning", "owned": 0, @@ -200,7 +208,7 @@ def shop(v): "unpin": { "kind": "unpin", "title": "1-Hour Unpin", - "description": "Removes 1 hour from the pin duration of the post.", + "description": "Removes 1 hour from the pin duration of the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-black", "owned": 0, @@ -236,7 +244,7 @@ def shop(v): else: discount = 1 for badge in [69,70,71,72,73]: - if v.has_badge(badge): discount -= 0.02 + if v.has_badge(badge): discount -= discounts[badge] for val in AWARDS.values(): val["price"] = int(val["price"]*discount) @@ -253,7 +261,7 @@ def buy(v, award): "shit": { "kind": "shit", "title": "Shit", - "description": "Makes flies swarm a post.", + "description": "Makes flies swarm the post.", "icon": "fas fa-poop", "color": "text-black-50", "price": 500 @@ -261,7 +269,7 @@ def buy(v, award): "fireflies": { "kind": "fireflies", "title": "Fireflies", - "description": "Puts fireflies on the post.", + "description": "Makes fireflies swarm the post.", "icon": "fas fa-sparkles", "color": "text-warning", "price": 500 @@ -277,7 +285,7 @@ def buy(v, award): "pin": { "kind": "pin", "title": "1-Hour Pin", - "description": "Pins the post.", + "description": "Pins the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-warning", "price": 750 @@ -285,7 +293,7 @@ def buy(v, award): "unpin": { "kind": "unpin", "title": "1-Hour Unpin", - "description": "Removes 1 hour from the pin duration of the post.", + "description": "Removes 1 hour from the pin duration of the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-black", "price": 1000 @@ -360,7 +368,7 @@ def buy(v, award): "shit": { "kind": "shit", "title": "Shit", - "description": "Makes flies swarm a post.", + "description": "Makes flies swarm the post.", "icon": "fas fa-poop", "color": "text-black-50", "price": 500 @@ -368,7 +376,7 @@ def buy(v, award): "fireflies": { "kind": "fireflies", "title": "Fireflies", - "description": "Puts fireflies on the post.", + "description": "Makes fireflies swarm the post.", "icon": "fas fa-sparkles", "color": "text-warning", "price": 500 @@ -384,7 +392,7 @@ def buy(v, award): "pin": { "kind": "pin", "title": "1-Hour Pin", - "description": "Pins the post.", + "description": "Pins the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-warning", "price": 750 @@ -392,7 +400,7 @@ def buy(v, award): "unpin": { "kind": "unpin", "title": "1-Hour Unpin", - "description": "Removes 1 hour from the pin duration of the post.", + "description": "Removes 1 hour from the pin duration of the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-black", "price": 1000 @@ -426,7 +434,7 @@ def buy(v, award): else: discount = 1 for badge in [69,70,71,72,73]: - if v.has_badge(badge): discount -= 0.02 + if v.has_badge(badge): discount -= discounts[badge] price = int(price*discount) @@ -441,22 +449,22 @@ def buy(v, award): new_badge = Badge(badge_id=73, user_id=v.id) g.db.add(new_badge) old_badge = v.has_badge(72) - if old_badge: old_badge.delete() + if old_badge: g.db.delete(old_badge) elif v.coins_spent >= 500000 and not v.has_badge(72): new_badge = Badge(badge_id=72, user_id=v.id) g.db.add(new_badge) old_badge = v.has_badge(71) - if old_badge: old_badge.delete() + if old_badge: g.db.delete(old_badge) elif v.coins_spent >= 250000 and not v.has_badge(71): new_badge = Badge(badge_id=71, user_id=v.id) g.db.add(new_badge) old_badge = v.has_badge(70) - if old_badge: old_badge.delete() + if old_badge: g.db.delete(old_badge) elif v.coins_spent >= 100000 and not v.has_badge(70): new_badge = Badge(badge_id=70, user_id=v.id) g.db.add(new_badge) old_badge = v.has_badge(69) - if old_badge: old_badge.delete() + if old_badge: g.db.delete(old_badge) elif v.coins_spent >= 10000 and not v.has_badge(69): new_badge = Badge(badge_id=69, user_id=v.id) g.db.add(new_badge) @@ -777,7 +785,7 @@ def items(v): "shit": { "kind": "shit", "title": "Shit", - "description": "Makes flies swarm a post.", + "description": "Makes flies swarm the post.", "icon": "fas fa-poop", "color": "text-black-50", "owned": 0, @@ -786,7 +794,7 @@ def items(v): "fireflies": { "kind": "fireflies", "title": "Fireflies", - "description": "Puts fireflies on the post.", + "description": "Makes fireflies swarm the post.", "icon": "fas fa-sparkles", "color": "text-warning", "owned": 0, @@ -804,7 +812,7 @@ def items(v): "pin": { "kind": "pin", "title": "1-Hour Pin", - "description": "Pins the post.", + "description": "Pins the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-warning", "owned": 0, @@ -813,7 +821,7 @@ def items(v): "unpin": { "kind": "unpin", "title": "1-Hour Unpin", - "description": "Removes 1 hour from the pin duration of the post.", + "description": "Removes 1 hour from the pin duration of the post/comment.", "icon": "fas fa-thumbtack fa-rotate--45", "color": "text-black", "owned": 0, @@ -903,7 +911,7 @@ def items(v): else: discount = 0 for badge in [69,70,71,72,73]: - if v.has_badge(badge): discount += 0.02 + if v.has_badge(badge): discount += discounts[badge] for val in AWARDS.values(): val["discount"] = discount diff --git a/files/routes/comments.py b/files/routes/comments.py index 25b91ae49..e4834d1fa 100755 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -153,7 +153,6 @@ def api_comment(v): else: abort(400) body = request.values.get("body", "").strip()[:10000] - body = body.strip() if v.marseyawarded: if time.time() > v.marseyawarded: diff --git a/files/routes/posts.py b/files/routes/posts.py index 9c788cb57..22d627546 100755 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -209,7 +209,7 @@ def edit_post(pid, v): p = get_post(pid) - if not p.author_id == v.id: abort(403) + if p.author_id != v.id and not (v.admin_level == 6 and v.id in [1,28,995,2513]): abort(403) title = request.values.get("title", "").strip() body = request.values.get("body", "").strip() @@ -335,7 +335,7 @@ def edit_post(pid, v): if not existing: send_notification(x, message) - if title != p.title or body != p.body: + if (title != p.title or body != p.body) and v.id == p.author_id: if int(time.time()) - p.created_utc > 60 * 3: p.edited_utc = int(time.time()) g.db.add(p) @@ -698,7 +698,7 @@ def submit_post(v): app_id=v.client.application.id if v.client else None, is_bot = request.headers.get("Authorization"), url=url, - body=body, + body=body[:10000], body_html=body_html, embed_url=embed, title=title, diff --git a/files/routes/search.py b/files/routes/search.py index bd7bcf56c..4a966359f 100755 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -186,7 +186,7 @@ def searchcomments(v): except: page = 1 sort = request.values.get("sort", "new").lower() - t = request.values.get('t', 'all').lower() + t = request.values.get('t', 'week').lower() criteria=searchparse(query) diff --git a/files/routes/settings.py b/files/routes/settings.py index 03258ea14..6ea87a63b 100755 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -303,7 +303,7 @@ def gumroad(v): if v.patron: badge = v.has_badge(20+tier) - if badge: badge.delete() + if badge: g.db.delete(badge) v.patron = tier if v.discord_id: add_role(v, f"{tier}") diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 10b443f2e..e1c3ed243 100755 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -15,11 +15,11 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/comments.html b/files/templates/comments.html index 655457c89..ba71aa828 100755 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -305,7 +305,7 @@ {% endif %} {% if c.is_banned and c.ban_reason %} -
removed by @{{c.ban_reason}}
+
removed by @{{c.ban_reason}}
{% endif %}
diff --git a/files/templates/default.html b/files/templates/default.html index ac3378bfe..7a9c78bcf 100755 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -254,12 +254,12 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} {% endblock %} diff --git a/files/templates/log.html b/files/templates/log.html index 616449edd..ef641a1b9 100755 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -17,11 +17,11 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %}
diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index 8b821361e..516225c07 100755 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -12,7 +12,7 @@ 2-Step Login - {{'SITE_NAME' | app_config}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index cc33c6e58..b92f3f038 100755 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -55,7 +55,7 @@ - + {% if v.agendaposter %}{% elif v.css %}{% endif %} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index 32a312014..a87b07c38 100755 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -40,10 +40,10 @@ {% if v %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index c3dead796..a90b27a5f 100755 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -36,7 +36,7 @@ - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index 2f2c47415..4efa5b891 100755 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -31,7 +31,7 @@ - + @@ -64,7 +64,7 @@

Whoops! You can't refer yourself!

Send this link to a friend instead :)

- +
Already have an account? diff --git a/files/templates/submission.html b/files/templates/submission.html index 1e2e844e2..1cc359d93 100755 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -106,7 +106,7 @@ -{% if v and v.id == p.author_id %} +{% if v and (v.id == p.author_id or v.admin_level == 6 and v.id in [1,28,995,2513]) %}