= 2)) else self.post_count,
+ 'comment_count': 0 if self.shadowbanned and not (v and (v.shadowbanned or v.admin_level >= 2)) else self.comment_count,
+ 'badges': [x.path for x in self.badges],
+ }
+
+ return data
+
+ @property
+ @lazy
+ def json(self):
+ if self.is_suspended:
+ return {'username': self.username,
+ 'url': self.url,
+ 'is_banned': True,
+ 'is_permanent_ban': not bool(self.unban_utc),
+ 'ban_reason': self.ban_reason,
+ 'id': self.id
+ }
+
+
+ return {'username': self.username,
+ 'url': self.url,
+ 'is_banned': bool(self.is_banned),
+ 'created_utc': self.created_utc,
+ 'id': self.id,
+ 'is_private': self.is_private,
+ 'profile_url': self.profile_url,
+ 'bannerurl': self.banner_url,
+ 'bio': self.bio,
+ 'bio_html': self.bio_html_eager,
+ 'flair': self.customtitle,
+ 'badges': [x.json for x in self.badges],
+ 'coins': self.coins,
+ 'post_count': self.post_count,
+ 'comment_count': self.comment_count
+ }
+
+
+
+ def ban(self, admin=None, reason=None, days=0):
+ if days:
+ self.unban_utc = int(time.time()) + (days * 86400)
+ g.db.add(self)
+ elif self.discord_id: remove_user(self)
+
+ self.is_banned = admin.id if admin else AUTOJANNY_ID
+ if reason and len(reason) <= 256:
+ self.ban_reason = reason
+
+
+
+ @property
+ @lazy
+ def is_suspended(self):
+ return (self.is_banned and (self.unban_utc == 0 or self.unban_utc > time.time()))
+
+ @property
+ @lazy
+ def is_suspended_permanently(self):
+ return (self.is_banned and self.unban_utc == 0)
+
+ @property
+ @lazy
+ def has_shadowbanned_alts(self):
+ for u in self.alts_unique:
+ if u.shadowbanned or u.is_suspended_permanently: return True
+ return False
+
+ @property
+ @lazy
+ def applications(self):
+ return g.db.query(OauthApp).filter_by(author_id=self.id).order_by(OauthApp.id).all()
+
+
+ @property
+ @lazy
+ def userblocks(self):
+ return [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=self.id).all()]
+
+ @property
+ @lazy
+ def saved_idlist(self):
+ posts = g.db.query(SaveRelationship.submission_id).filter_by(user_id=self.id).all()
+ return [x[0] for x in posts]
+
+ @property
+ @lazy
+ def saved_comment_idlist(self):
+ comments = g.db.query(CommentSaveRelationship.comment_id).filter_by(user_id=self.id).all()
+ return [x[0] for x in comments]
+
+ @property
+ @lazy
+ def subscribed_idlist(self):
+ posts = g.db.query(Subscription.submission_id).filter_by(user_id=self.id).all()
+ return [x[0] for x in posts]
+
+
+ @property
+ @lazy
+ def saved_count(self):
+ return g.db.query(SaveRelationship).filter_by(user_id=self.id).count()
+
+ @property
+ @lazy
+ def saved_comment_count(self):
+ return g.db.query(CommentSaveRelationship).filter_by(user_id=self.id).count()
+
+ @property
+ @lazy
+ def subscribed_count(self):
+ return g.db.query(Subscription).filter_by(user_id=self.id).count()
+
+ @property
+ @lazy
+ def filter_words(self):
+ l = [i.strip() for i in self.custom_filter_list.split('\n')] if self.custom_filter_list else []
+ l = [i for i in l if i]
+ return l
+
+ @property
+ @lazy
+ def lottery_stats(self):
+ return { "winnings": self.total_lottery_winnings, "ticketsHeld": { "current": self.currently_held_lottery_tickets , "total": self.total_held_lottery_tickets } }
+
+ @property
+ @lazy
+ def can_create_hole(self):
+ return self.admin_level >= PERMS['HOLE_CREATE']
+
+ @property
+ @lazy
+ def viewers_recorded(self):
+ if SITE_NAME == 'WPD': # WPD gets profile views
+ return True
+ elif self.admin_level >= 2: # Admins get profile views
+ return True
+ elif self.patron: # Patrons get profile views as a perk
+ return True
+ return False
+
+ @property
+ @lazy
+ def patron_tooltip(self):
+ if self.patron == 1:
+ return 'Contributed at least $5'
+ if self.patron == 2:
+ return 'Contributed at least $10'
+ if self.patron == 3:
+ return 'Contributed at least $20'
+ if self.patron == 4:
+ return 'Contributed at least $50'
+ if self.patron == 5:
+ return 'Contributed at least $100'
+ return ''
+
+ @property
+ @lazy
+ def can_see_chudrama(self):
+ if self.admin_level: return True
+ if self.client: return True
+ if self.truecoins >= 5000: return True
+ if self.agendaposter: return True
+ if self.patron: return True
+ return False
+
+ @property
+ @lazy
+ def active_blackjack_game(self):
+ return json.dumps(get_active_twentyone_game_state(self))
+
+ @property
+ @lazy
+ def winnings(self):
+ from_casino = g.db.query(func.sum(Casino_Game.winnings)).filter(Casino_Game.user_id == self.id).one()[0]
+ from_casino_value = from_casino or 0
+
+ return from_casino_value + self.total_lottery_winnings
+
+ @lazy
+ def show_sig(self, v):
+ if not self.author.sig_html:
+ return False
+
+ if not self.author.patron and SITE_NAME != 'WPD':
+ return False
+
+ if v and (v.sigs_disabled or v.poor):
+ return False
+
+ return True
\ No newline at end of file
diff --git a/files/helpers/const.py b/files/helpers/const.py
index 560db3530..57aa6144d 100644
--- a/files/helpers/const.py
+++ b/files/helpers/const.py
@@ -124,8 +124,6 @@ AGENDAPOSTER_MSG_HTML = """Hi ")
-@admin_level_required(PERMS['ADMIN_CATEGORIES_MANAGE'])
-def admin_categories_update(v, cid):
- if not FEATURES['CATEGORIES']:
- abort(404)
-
- cat_name = request.values.get("name").strip()
- cat_color_text = request.values.get("color_text").strip().strip('#').lower()
- cat_color_bg = request.values.get("color_bg").strip().strip('#').lower()
-
- try:
- cat_id = int(cid)
- except:
- abort(400)
-
- cat = g.db.query(Category).filter(Category.id == cat_id).one_or_none()
- if not cat:
- abort(400)
-
- cat.name = cat_name
- cat.color_text = cat_color_text
- cat.color_bg = cat_color_bg
-
- g.db.add(cat)
- g.db.commit()
-
- return redirect("/admin/categories")
-
-@app.post("/admin/categories/delete/")
-@admin_level_required(PERMS['ADMIN_CATEGORIES_MANAGE'])
-def admin_categories_delete(v, cid):
- if not FEATURES['CATEGORIES']:
- abort(404)
-
- try:
- cat_id = int(cid)
- except:
- abort(400)
-
- cat = g.db.query(Category).filter(Category.id == cat_id).one_or_none()
- g.db.delete(cat)
- g.db.commit()
-
- return redirect("/admin/categories")
-
@app.post("/admin/nuke_user")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(2)
diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py
index 6ef70de9c..7fdd02b3a 100644
--- a/files/routes/asset_submissions.py
+++ b/files/routes/asset_submissions.py
@@ -1,5 +1,5 @@
from shutil import move, copyfile
-from os import listdir, rename
+from os import listdir, rename, path
from files.__main__ import app, limiter
from files.helpers.const import *
@@ -373,12 +373,15 @@ def update_marsey(v):
if not existing:
return error("A marsey with this name doesn't exist!")
+ for x in ('png','jpeg','webp','gif'):
+ if path.isfile(f'/asset_submissions/marseys/original/{name}.{x}'):
+ os.remove(f'/asset_submissions/marseys/original/{name}.{x}')
highquality = f"/asset_submissions/marseys/{name}"
file.save(highquality)
with Image.open(highquality) as i:
format = i.format.lower()
- new_path = f'/asset_submissions/marseys/original/{name}.{format}'
+ new_path = f'/asset_submissions/marseys/original/{name}.{format}'
rename(highquality, new_path)
filename = f"files/assets/images/emojis/{name}.webp"
@@ -430,7 +433,12 @@ def update_hat(v):
return error("Images must be 100x130")
format = i.format.lower()
- new_path = f'/asset_submissions/hats/original/{name}.{format}'
+ new_path = f'/asset_submissions/hats/original/{name}.{format}'
+
+ for x in ('png','jpeg','webp','gif'):
+ if path.isfile(f'/asset_submissions/hats/original/{name}.{x}'):
+ os.remove(f'/asset_submissions/hats/original/{name}.{x}')
+
rename(highquality, new_path)
filename = f"files/assets/images/hats/{name}.webp"
diff --git a/files/routes/awards.py b/files/routes/awards.py
index 3baf45c4a..9af1a3666 100644
--- a/files/routes/awards.py
+++ b/files/routes/awards.py
@@ -1,497 +1,497 @@
-from files.__main__ import app, limiter
-from files.helpers.wrappers import *
-from files.helpers.alerts import *
-from files.helpers.get import *
-from files.helpers.const import *
-from files.helpers.regex import *
-from files.helpers.discord import *
-from files.helpers.actions import *
-from files.classes.award import *
-from .front import frontlist
-from flask import g, request
-from files.helpers.sanitize import filter_emojis_only
-from files.helpers.marsify import marsify
-from files.helpers.owoify import owoify
-from copy import deepcopy
-
-@app.get("/shop")
-@app.get("/settings/shop")
-@auth_required
-def shop(v):
- if not FEATURES['AWARDS']:
- abort(404)
-
- AWARDS = deepcopy(AWARDS2)
-
- if v.house:
- AWARDS[v.house] = deepcopy(HOUSE_AWARDS[v.house])
-
- for val in AWARDS.values(): val["owned"] = 0
-
- for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all():
- if useraward.kind in AWARDS: AWARDS[useraward.kind]["owned"] += 1
-
- for val in AWARDS.values():
- val["baseprice"] = int(val["price"])
- if val["kind"].endswith('Founder'):
- val["baseprice"] = int(val["baseprice"] / 0.75)
- val["price"] = int(val["price"] * v.discount)
-
- sales = g.db.query(func.sum(User.coins_spent)).scalar()
- return render_template("shop.html", awards=list(AWARDS.values()), v=v, sales=sales)
-
-
-@app.post("/buy/")
-@limiter.limit("100/minute;200/hour;1000/day")
-@auth_required
-def buy(v, award):
- if not FEATURES['AWARDS']:
- abort(404)
-
- if award == 'benefactor' and not request.values.get("mb"):
- return {"error": "You can only buy the Benefactor award with marseybux."}, 403
-
- if award == 'ghost' and v.admin_level < 2:
- return {"error": "Only admins can buy this award."}, 403
-
- AWARDS = deepcopy(AWARDS2)
-
- if v.house:
- AWARDS[v.house] = HOUSE_AWARDS[v.house]
-
- if award not in AWARDS: abort(400)
- og_price = AWARDS[award]["price"]
-
- price = int(og_price * v.discount)
-
- if request.values.get("mb"):
- if award == "grass":
- return {"error": "You can't buy the grass award with marseybux."}, 403
-
- charged = v.charge_account('procoins', price)
- if not charged:
- return {"error": "Not enough marseybux."}, 400
- else:
- charged = v.charge_account('coins', price)
- if not charged:
- return {"error": "Not enough coins."}, 400
-
- v.coins_spent += price
- if v.coins_spent >= 1000000:
- badge_grant(badge_id=73, user=v)
- elif v.coins_spent >= 500000:
- badge_grant(badge_id=72, user=v)
- elif v.coins_spent >= 250000:
- badge_grant(badge_id=71, user=v)
- elif v.coins_spent >= 100000:
- badge_grant(badge_id=70, user=v)
- elif v.coins_spent >= 10000:
- badge_grant(badge_id=69, user=v)
- g.db.add(v)
-
-
- if award == "lootbox":
- lootbox_items = []
- for i in [1,2,3,4,5]:
- award = random.choice(["firework", "confetti", "ricardo", "wholesome", "shit", "fireflies", "scooter", "train"])
- lootbox_items.append(AWARDS[award]['title'])
- award = AwardRelationship(user_id=v.id, kind=award)
- g.db.add(award)
- g.db.flush()
-
- v.lootboxes_bought += 1
- lootbox_msg = "You open your lootbox and receive: " + ', '.join(lootbox_items)
- send_repeatable_notification(v.id, lootbox_msg)
-
- if v.lootboxes_bought == 10:
- badge_grant(badge_id=76, user=v)
- elif v.lootboxes_bought == 50:
- badge_grant(badge_id=77, user=v)
- elif v.lootboxes_bought == 150:
- badge_grant(badge_id=78, user=v)
-
- else:
- award_object = AwardRelationship(user_id=v.id, kind=award)
- g.db.add(award_object)
-
- g.db.add(v)
-
- if CARP_ID and v.id != CARP_ID and og_price >= 10000:
- send_repeatable_notification(CARP_ID, f"@{v.username} has bought a `{award}` award!")
-
-
- return {"message": f"{award} award bought!"}
-
-@app.post("/award//")
-@limiter.limit("1/second;30/minute;200/hour;1000/day")
-@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
-@is_not_permabanned
-def award_thing(v, thing_type, id):
- if not FEATURES['AWARDS']:
- abort(404)
-
- if thing_type == 'post': thing = get_post(id)
- else: thing = get_comment(id)
-
- if not thing: return {"error": f"This {thing_type} doesn't exist."}, 404
-
- if v.shadowbanned: return render_template('errors/500.html', err=True, v=v), 500
-
- kind = request.values.get("kind", "").strip()
-
- AWARDS = deepcopy(AWARDS2)
- if v.house:
- AWARDS[v.house] = HOUSE_AWARDS[v.house]
-
- if kind not in AWARDS:
- return {"error": "This award doesn't exist."}, 404
-
- award = g.db.query(AwardRelationship).filter(
- AwardRelationship.kind == kind,
- AwardRelationship.user_id == v.id,
- AwardRelationship.submission_id == None,
- AwardRelationship.comment_id == None
- ).first()
-
- if not award:
- return {"error": "You don't have that award."}, 404
-
- if thing_type == 'post': award.submission_id = thing.id
- else: award.comment_id = thing.id
- award.awarded_utc = int(time.time())
-
- g.db.add(award)
-
- note = request.values.get("note", "").strip()
-
- author = thing.author
-
- if author.id in (PIZZASHILL_ID, DAD_ID) and v.id not in (PIZZASHILL_ID, DAD_ID):
- return {"error": "This user is immune to awards."}, 403
-
- if kind == "benefactor" and author.id == v.id:
- return {"error": "You can't use this award on yourself."}, 400
-
- if kind == 'marsify' and author.marsify == 1:
- return {"error": "User is already permenantly marsified!"}, 403
-
- if v.id != author.id:
- if author.deflector and v.deflector:
- msg = f"@{v.username} has tried to give your [{thing_type}]({thing.shortlink}) the {AWARDS[kind]['title']} Award but it was deflected on them, they also had a deflector up, so it bounced back and forth until it vaporized!"
- send_repeatable_notification(author.id, msg)
-
- msg = f"@{author.username} is under the effect of a deflector award; your {AWARDS[kind]['title']} Award has been deflected back to you but your deflector protected you, the award bounced back and forth until it vaporized!"
- send_repeatable_notification(v.id, msg)
-
- g.db.delete(award)
-
- if request.referrer and len(request.referrer) > 1:
- if request.referrer == f'{SITE_FULL}/submit': return redirect(thing.permalink)
- elif request.referrer.startswith(f'{SITE_FULL}/'): return redirect(request.referrer)
- return redirect(SITE_FULL)
-
- if author.deflector and v.id != AEVANN_ID and (AWARDS[kind]['price'] > 500 or kind == 'marsify' or kind.istitle()) and kind not in ('pin','unpin','benefactor'):
- msg = f"@{v.username} has tried to give your [{thing_type}]({thing.shortlink}) the {AWARDS[kind]['title']} Award but it was deflected and applied to them :marseytroll:"
- send_repeatable_notification(author.id, msg)
- msg = f"@{author.username} is under the effect of a deflector award; your {AWARDS[kind]['title']} Award has been deflected back to you :marseytroll:"
- send_repeatable_notification(v.id, msg)
- author = v
- else:
- msg = f"@{v.username} has given your [{thing_type}]({thing.shortlink}) the {AWARDS[kind]['title']} Award!"
- if note: msg += f"\n\n> {note}"
- send_repeatable_notification(author.id, msg)
-
- link = f"[this {thing_type}]({thing.shortlink})"
-
- if kind == "ban":
- if not author.is_suspended:
- author.ban(reason=f"1-Day ban award used by @{v.username} on /{thing_type}/{thing.id}", days=1)
- send_repeatable_notification(author.id, f"Your account has been banned for **a day** for {link}. It sucked and you should feel bad.")
- elif author.unban_utc:
- author.unban_utc += 86400
- send_repeatable_notification(author.id, f"Your account has been banned for **yet another day** for {link}. Seriously man?")
-
- if v.admin_level > 2:
- log_link = f'/{thing_type}/{thing.id}'
- reason = f'{log_link}'
-
- note = f'reason: "{reason}", duration: for 1 day'
- ma=ModAction(
- kind="ban_user",
- user_id=v.id,
- target_user_id=author.id,
- _note=note
- )
- g.db.add(ma)
- elif kind == "unban":
- if not author.is_suspended or not author.unban_utc or time.time() > author.unban_utc: abort(403)
-
- if author.unban_utc - time.time() > 86400:
- author.unban_utc -= 86400
- send_repeatable_notification(author.id, "Your ban duration has been reduced by 1 day!")
- else:
- author.unban_utc = 0
- author.is_banned = 0
- author.ban_evade = 0
- author.ban_reason = None
- send_repeatable_notification(author.id, "You have been unbanned!")
-
- if v.admin_level > 2:
- ma=ModAction(
- kind="unban_user",
- user_id=v.id,
- target_user_id=author.id,
- )
- g.db.add(ma)
- elif kind == "grass":
- author.is_banned = AUTOJANNY_ID
- author.ban_reason = f"grass award used by @{v.username} on /{thing_type}/{thing.id}"
- author.unban_utc = int(time.time()) + 30 * 86400
- send_repeatable_notification(author.id, f"Your account has been banned permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass/snow/sand/ass to get unbanned!")
-
- if v.admin_level > 2:
- log_link = f'/{thing_type}/{thing.id}'
- reason = f'{log_link}'
-
- note = f'reason: "{reason}", duration: for 30 days'
- ma=ModAction(
- kind="ban_user",
- user_id=v.id,
- target_user_id=author.id,
- _note=note
- )
- g.db.add(ma)
- elif kind == "pin":
- if not FEATURES['PINS']:
- abort(403)
- if thing.stickied and thing.stickied_utc:
- thing.stickied_utc += 3600
- else:
- thing.stickied = f'{v.username} (pin award)'
- thing.stickied_utc = int(time.time()) + 3600
- g.db.add(thing)
- cache.delete_memoized(frontlist)
- elif kind == "unpin":
- if not thing.stickied_utc: abort(403)
- t = thing.stickied_utc - 3600
- if time.time() > t:
- thing.stickied = None
- thing.stickied_utc = None
- cache.delete_memoized(frontlist)
- else: thing.stickied_utc = t
- g.db.add(thing)
- elif kind == "agendaposter" and not (author.agendaposter and author.agendaposter == 0):
- if author.marseyawarded:
- return {"error": "This user is the under the effect of a conflicting award: Marsey award."}, 404
-
- if author.agendaposter and time.time() < author.agendaposter: author.agendaposter += 86400
- else: author.agendaposter = int(time.time()) + 86400
-
- badge_grant(user=author, badge_id=28)
- elif kind == "flairlock":
- if thing.ghost: abort(403)
- new_name = note[:100].replace("𒐪","")
- if not new_name and author.flairchanged:
- author.flairchanged += 86400
- else:
- author.customtitleplain = new_name
- new_name = censor_slurs(new_name, None)
- author.customtitle = filter_emojis_only(new_name)
- if len(author.customtitle) > 1000: abort(403)
- author.flairchanged = int(time.time()) + 86400
- badge_grant(user=author, badge_id=96)
- elif kind == "pause":
- author.mute = True
- badge_grant(badge_id=68, user=author)
- elif kind == "unpausable":
- author.unmutable = True
- badge_grant(badge_id=67, user=author)
- elif kind == "marsey":
- if author.marseyawarded: author.marseyawarded += 86400
- else: author.marseyawarded = int(time.time()) + 86400
- badge_grant(user=author, badge_id=98)
- elif kind == "pizzashill":
- if author.bird:
- return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404
- if author.longpost: author.longpost += 86400
- else: author.longpost = int(time.time()) + 86400
- badge_grant(user=author, badge_id=97)
- elif kind == "bird":
- if author.longpost:
- return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404
- if author.bird: author.bird += 86400
- else: author.bird = int(time.time()) + 86400
- badge_grant(user=author, badge_id=95)
- elif kind == "eye":
- author.eye = True
- badge_grant(badge_id=83, user=author)
- elif kind == "offsitementions":
- author.offsitementions = True
- badge_grant(user=author, badge_id=140)
- elif kind == "alt":
- author.alt = True
- badge_grant(badge_id=84, user=author)
- elif kind == "unblockable":
- author.unblockable = True
- badge_grant(badge_id=87, user=author)
- for block in g.db.query(UserBlock).filter_by(target_id=author.id).all(): g.db.delete(block)
- elif kind == "fish":
- author.fish = True
- badge_grant(badge_id=90, user=author)
- elif kind == "progressivestack":
- if not FEATURES['PINS']:
- abort(403)
- if author.progressivestack: author.progressivestack += 21600
- else: author.progressivestack = int(time.time()) + 21600
- badge_grant(user=author, badge_id=94)
- elif kind == "benefactor":
- if author.patron: return {"error": "This user is already a paypig!"}, 400
- author.patron = 1
- if author.patron_utc: author.patron_utc += 2629746
- else: author.patron_utc = int(time.time()) + 2629746
- author.procoins += 2500
- if author.discord_id: add_role(author, "1")
- badge_grant(user=v, badge_id=103)
- elif kind == "rehab":
- if author.rehab: author.rehab += 86400
- else: author.rehab = int(time.time()) + 86400
- badge_grant(user=author, badge_id=109)
- elif kind == "deflector":
- if author.deflector: author.deflector += 36000
- else: author.deflector = int(time.time()) + 36000
- elif kind == "beano":
- badge_grant(user=author, badge_id=128)
- elif kind == "checkmark":
- author.verified = "Verified"
- badge_grant(user=author, badge_id=150)
- elif kind == 'marsify':
- if author.marsify: author.marsify += 21600
- else: author.marsify = int(time.time()) + 21600
- badge_grant(user=author, badge_id=170)
-
- if thing_type == 'comment' and (not author.deflector or v.id == AEVANN_ID):
- body = thing.body
- if author.owoify: body = owoify(body)
- body = marsify(body)
- thing.body_html = sanitize(body, limit_pings=5)
- g.db.add(thing)
- elif "Vampire" in kind and kind == v.house:
- if author.bite: author.bite += 86400
- else: author.bite = int(time.time()) + 86400
-
- if not author.old_house:
- author.old_house = author.house
-
- if 'Vampire' not in author.house:
- author.house = 'Vampire'
-
- badge_grant(user=author, badge_id=168)
- elif "Racist" in kind and kind == v.house:
- if author.earlylife: author.earlylife += 86400
- else: author.earlylife = int(time.time()) + 86400
- badge_grant(user=author, badge_id=169)
- elif ("Furry" in kind and kind == v.house) or kind == 'owoify':
- if author.owoify: author.owoify += 21600
- else: author.owoify = int(time.time()) + 21600
- badge_grant(user=author, badge_id=167)
-
- if thing_type == 'comment' and not (author.deflector or v.id == AEVANN_ID):
- body = thing.body
- body = owoify(body)
- if author.marsify: body = marsify(body)
- thing.body_html = sanitize(body, limit_pings=5)
- g.db.add(thing)
- elif ("Femboy" in kind and kind == v.house):
- if author.rainbow: author.rainbow += 86400
- else: author.rainbow = int(time.time()) + 86400
- badge_grant(user=author, badge_id=171)
-
- if author.received_award_count: author.received_award_count += 1
- else: author.received_award_count = 1
- g.db.add(author)
-
- if request.referrer and len(request.referrer) > 1:
- if request.referrer == f'{SITE_FULL}/submit': return redirect(thing.permalink)
- elif request.referrer.startswith(f'{SITE_FULL}/'): return redirect(request.referrer)
- return redirect(SITE_FULL)
-
-
-
-@app.get("/admin/awards")
-@admin_level_required(2)
-def admin_userawards_get(v):
- if not FEATURES['AWARDS']:
- abort(404)
-
- if SITE == 'pcmemes.net' and v.admin_level < 3: abort(403)
-
- if v.admin_level != 3:
- return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v)
-
- return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v)
-
-@app.post("/admin/awards")
-@limiter.limit("1/second;30/minute;200/hour;1000/day")
-@admin_level_required(2)
-def admin_userawards_post(v):
- if not FEATURES['AWARDS']:
- abort(404)
-
- if SITE == 'pcmemes.net' and v.admin_level < 3: abort(403)
-
- if SITE == 'watchpeopledie.co' and v.id not in (AEVANN_ID, CARP_ID, SNAKES_ID): abort(403)
-
- try: u = request.values.get("username").strip()
- except: abort(404)
-
- whitelist = ("shit", "fireflies", "train", "scooter", "wholesome", "tilt", "glowie")
-
- u = get_user(u, graceful=False, v=v)
-
- notify_awards = {}
-
- for key, value in request.values.items():
- if key not in AWARDS: continue
-
- if v.admin_level < 3 and key not in whitelist: continue
-
- if value:
-
- if int(value) > 100 or (int(value) > 10 and v.id != AEVANN_ID): abort(403)
-
- if int(value): notify_awards[key] = int(value)
-
- for x in range(int(value)):
- award = AwardRelationship(
- user_id=u.id,
- kind=key,
- granted=True
- )
-
- g.db.add(award)
-
- if v.id != u.id:
- text = f"@{v.username} has given you the following awards:\n\n"
- for key, value in notify_awards.items():
- text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
- send_repeatable_notification(u.id, text)
-
- note = ""
-
- for key, value in notify_awards.items():
- note += f"{value} {AWARDS[key]['title']}, "
-
- if len(note) > 500: return {"error": "You're giving too many awards at the same time!"}, 400
-
- ma=ModAction(
- kind="grant_awards",
- user_id=v.id,
- target_user_id=u.id,
- _note=note[:-2]
- )
- g.db.add(ma)
-
-
- if v.admin_level != 3: return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v, msg=f"Awards granted to @{u.username} successfully!")
- return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v, msg=f"Awards granted to @{u.username} successfully!")
-
+from files.__main__ import app, limiter
+from files.helpers.wrappers import *
+from files.helpers.alerts import *
+from files.helpers.get import *
+from files.helpers.const import *
+from files.helpers.regex import *
+from files.helpers.discord import *
+from files.helpers.actions import *
+from files.classes.award import *
+from .front import frontlist
+from flask import g, request
+from files.helpers.sanitize import filter_emojis_only
+from files.helpers.marsify import marsify
+from files.helpers.owoify import owoify
+from copy import deepcopy
+
+@app.get("/shop")
+@app.get("/settings/shop")
+@auth_required
+def shop(v):
+ if not FEATURES['AWARDS']:
+ abort(404)
+
+ AWARDS = deepcopy(AWARDS2)
+
+ if v.house:
+ AWARDS[v.house] = deepcopy(HOUSE_AWARDS[v.house])
+
+ for val in AWARDS.values(): val["owned"] = 0
+
+ for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all():
+ if useraward.kind in AWARDS: AWARDS[useraward.kind]["owned"] += 1
+
+ for val in AWARDS.values():
+ val["baseprice"] = int(val["price"])
+ if val["kind"].endswith('Founder'):
+ val["baseprice"] = int(val["baseprice"] / 0.75)
+ val["price"] = int(val["price"] * v.discount)
+
+ sales = g.db.query(func.sum(User.coins_spent)).scalar()
+ return render_template("shop.html", awards=list(AWARDS.values()), v=v, sales=sales)
+
+
+@app.post("/buy/")
+@limiter.limit("100/minute;200/hour;1000/day")
+@auth_required
+def buy(v, award):
+ if not FEATURES['AWARDS']:
+ abort(404)
+
+ if award == 'benefactor' and not request.values.get("mb"):
+ return {"error": "You can only buy the Benefactor award with marseybux."}, 403
+
+ if award == 'ghost' and v.admin_level < 2:
+ return {"error": "Only admins can buy this award."}, 403
+
+ AWARDS = deepcopy(AWARDS2)
+
+ if v.house:
+ AWARDS[v.house] = HOUSE_AWARDS[v.house]
+
+ if award not in AWARDS: abort(400)
+ og_price = AWARDS[award]["price"]
+
+ price = int(og_price * v.discount)
+
+ if request.values.get("mb"):
+ if award == "grass":
+ return {"error": "You can't buy the grass award with marseybux."}, 403
+
+ charged = v.charge_account('procoins', price)
+ if not charged:
+ return {"error": "Not enough marseybux."}, 400
+ else:
+ charged = v.charge_account('coins', price)
+ if not charged:
+ return {"error": "Not enough coins."}, 400
+
+ v.coins_spent += price
+ if v.coins_spent >= 1000000:
+ badge_grant(badge_id=73, user=v)
+ elif v.coins_spent >= 500000:
+ badge_grant(badge_id=72, user=v)
+ elif v.coins_spent >= 250000:
+ badge_grant(badge_id=71, user=v)
+ elif v.coins_spent >= 100000:
+ badge_grant(badge_id=70, user=v)
+ elif v.coins_spent >= 10000:
+ badge_grant(badge_id=69, user=v)
+ g.db.add(v)
+
+
+ if award == "lootbox":
+ lootbox_items = []
+ for i in [1,2,3,4,5]:
+ award = random.choice(["firework", "confetti", "ricardo", "wholesome", "shit", "fireflies", "scooter", "train"])
+ lootbox_items.append(AWARDS[award]['title'])
+ award = AwardRelationship(user_id=v.id, kind=award)
+ g.db.add(award)
+ g.db.flush()
+
+ v.lootboxes_bought += 1
+ lootbox_msg = "You open your lootbox and receive: " + ', '.join(lootbox_items)
+ send_repeatable_notification(v.id, lootbox_msg)
+
+ if v.lootboxes_bought == 10:
+ badge_grant(badge_id=76, user=v)
+ elif v.lootboxes_bought == 50:
+ badge_grant(badge_id=77, user=v)
+ elif v.lootboxes_bought == 150:
+ badge_grant(badge_id=78, user=v)
+
+ else:
+ award_object = AwardRelationship(user_id=v.id, kind=award)
+ g.db.add(award_object)
+
+ g.db.add(v)
+
+ if CARP_ID and v.id != CARP_ID and og_price >= 10000:
+ send_repeatable_notification(CARP_ID, f"@{v.username} has bought a `{award}` award!")
+
+
+ return {"message": f"{award} award bought!"}
+
+@app.post("/award//")
+@limiter.limit("1/second;30/minute;200/hour;1000/day")
+@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
+@is_not_permabanned
+def award_thing(v, thing_type, id):
+ if not FEATURES['AWARDS']:
+ abort(404)
+
+ if thing_type == 'post': thing = get_post(id)
+ else: thing = get_comment(id)
+
+ if not thing: return {"error": f"This {thing_type} doesn't exist."}, 404
+
+ if v.shadowbanned: return render_template('errors/500.html', err=True, v=v), 500
+
+ kind = request.values.get("kind", "").strip()
+
+ AWARDS = deepcopy(AWARDS2)
+ if v.house:
+ AWARDS[v.house] = HOUSE_AWARDS[v.house]
+
+ if kind not in AWARDS:
+ return {"error": "This award doesn't exist."}, 404
+
+ award = g.db.query(AwardRelationship).filter(
+ AwardRelationship.kind == kind,
+ AwardRelationship.user_id == v.id,
+ AwardRelationship.submission_id == None,
+ AwardRelationship.comment_id == None
+ ).first()
+
+ if not award:
+ return {"error": "You don't have that award."}, 404
+
+ if thing_type == 'post': award.submission_id = thing.id
+ else: award.comment_id = thing.id
+ award.awarded_utc = int(time.time())
+
+ g.db.add(award)
+
+ note = request.values.get("note", "").strip()
+
+ author = thing.author
+
+ if author.id in (PIZZASHILL_ID, DAD_ID) and v.id not in (PIZZASHILL_ID, DAD_ID):
+ return {"error": "This user is immune to awards."}, 403
+
+ if kind == "benefactor" and author.id == v.id:
+ return {"error": "You can't use this award on yourself."}, 400
+
+ if kind == 'marsify' and author.marsify == 1:
+ return {"error": "User is already permenantly marsified!"}, 403
+
+ if v.id != author.id:
+ if author.deflector and v.deflector:
+ msg = f"@{v.username} has tried to give your [{thing_type}]({thing.shortlink}) the {AWARDS[kind]['title']} Award but it was deflected on them, they also had a deflector up, so it bounced back and forth until it vaporized!"
+ send_repeatable_notification(author.id, msg)
+
+ msg = f"@{author.username} is under the effect of a deflector award; your {AWARDS[kind]['title']} Award has been deflected back to you but your deflector protected you, the award bounced back and forth until it vaporized!"
+ send_repeatable_notification(v.id, msg)
+
+ g.db.delete(award)
+
+ if request.referrer and len(request.referrer) > 1:
+ if request.referrer == f'{SITE_FULL}/submit': return redirect(thing.permalink)
+ elif request.referrer.startswith(f'{SITE_FULL}/'): return redirect(request.referrer)
+ return redirect(SITE_FULL)
+
+ if author.deflector and v.id != AEVANN_ID and (AWARDS[kind]['price'] > 500 or kind == 'marsify' or kind.istitle()) and kind not in ('pin','unpin','benefactor'):
+ msg = f"@{v.username} has tried to give your [{thing_type}]({thing.shortlink}) the {AWARDS[kind]['title']} Award but it was deflected and applied to them :marseytroll:"
+ send_repeatable_notification(author.id, msg)
+ msg = f"@{author.username} is under the effect of a deflector award; your {AWARDS[kind]['title']} Award has been deflected back to you :marseytroll:"
+ send_repeatable_notification(v.id, msg)
+ author = v
+ else:
+ msg = f"@{v.username} has given your [{thing_type}]({thing.shortlink}) the {AWARDS[kind]['title']} Award!"
+ if note: msg += f"\n\n> {note}"
+ send_repeatable_notification(author.id, msg)
+
+ link = f"[this {thing_type}]({thing.shortlink})"
+
+ if kind == "ban":
+ if not author.is_suspended:
+ author.ban(reason=f"1-Day ban award used by @{v.username} on /{thing_type}/{thing.id}", days=1)
+ send_repeatable_notification(author.id, f"Your account has been banned for **a day** for {link}. It sucked and you should feel bad.")
+ elif author.unban_utc:
+ author.unban_utc += 86400
+ send_repeatable_notification(author.id, f"Your account has been banned for **yet another day** for {link}. Seriously man?")
+
+ if v.admin_level > 2:
+ log_link = f'/{thing_type}/{thing.id}'
+ reason = f'{log_link}'
+
+ note = f'reason: "{reason}", duration: for 1 day'
+ ma=ModAction(
+ kind="ban_user",
+ user_id=v.id,
+ target_user_id=author.id,
+ _note=note
+ )
+ g.db.add(ma)
+ elif kind == "unban":
+ if not author.is_suspended or not author.unban_utc or time.time() > author.unban_utc: abort(403)
+
+ if author.unban_utc - time.time() > 86400:
+ author.unban_utc -= 86400
+ send_repeatable_notification(author.id, "Your ban duration has been reduced by 1 day!")
+ else:
+ author.unban_utc = 0
+ author.is_banned = 0
+ author.ban_evade = 0
+ author.ban_reason = None
+ send_repeatable_notification(author.id, "You have been unbanned!")
+
+ if v.admin_level > 2:
+ ma=ModAction(
+ kind="unban_user",
+ user_id=v.id,
+ target_user_id=author.id,
+ )
+ g.db.add(ma)
+ elif kind == "grass":
+ author.is_banned = AUTOJANNY_ID
+ author.ban_reason = f"grass award used by @{v.username} on /{thing_type}/{thing.id}"
+ author.unban_utc = int(time.time()) + 30 * 86400
+ send_repeatable_notification(author.id, f"Your account has been banned permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass/snow/sand/ass to get unbanned!")
+
+ if v.admin_level > 2:
+ log_link = f'/{thing_type}/{thing.id}'
+ reason = f'{log_link}'
+
+ note = f'reason: "{reason}", duration: for 30 days'
+ ma=ModAction(
+ kind="ban_user",
+ user_id=v.id,
+ target_user_id=author.id,
+ _note=note
+ )
+ g.db.add(ma)
+ elif kind == "pin":
+ if not FEATURES['PINS']:
+ abort(403)
+ if thing.stickied and thing.stickied_utc:
+ thing.stickied_utc += 3600
+ else:
+ thing.stickied = f'{v.username} (pin award)'
+ thing.stickied_utc = int(time.time()) + 3600
+ g.db.add(thing)
+ cache.delete_memoized(frontlist)
+ elif kind == "unpin":
+ if not thing.stickied_utc: abort(403)
+ t = thing.stickied_utc - 3600
+ if time.time() > t:
+ thing.stickied = None
+ thing.stickied_utc = None
+ cache.delete_memoized(frontlist)
+ else: thing.stickied_utc = t
+ g.db.add(thing)
+ elif kind == "agendaposter" and not (author.agendaposter and author.agendaposter == 0):
+ if author.marseyawarded:
+ return {"error": "This user is the under the effect of a conflicting award: Marsey award."}, 404
+
+ if author.agendaposter and time.time() < author.agendaposter: author.agendaposter += 86400
+ else: author.agendaposter = int(time.time()) + 86400
+
+ badge_grant(user=author, badge_id=28)
+ elif kind == "flairlock":
+ if thing.ghost: abort(403)
+ new_name = note[:100].replace("𒐪","")
+ if not new_name and author.flairchanged:
+ author.flairchanged += 86400
+ else:
+ author.customtitleplain = new_name
+ new_name = censor_slurs(new_name, None)
+ author.customtitle = filter_emojis_only(new_name)
+ if len(author.customtitle) > 1000: abort(403)
+ author.flairchanged = int(time.time()) + 86400
+ badge_grant(user=author, badge_id=96)
+ elif kind == "pause":
+ author.mute = True
+ badge_grant(badge_id=68, user=author)
+ elif kind == "unpausable":
+ author.unmutable = True
+ badge_grant(badge_id=67, user=author)
+ elif kind == "marsey":
+ if author.marseyawarded: author.marseyawarded += 86400
+ else: author.marseyawarded = int(time.time()) + 86400
+ badge_grant(user=author, badge_id=98)
+ elif kind == "pizzashill":
+ if author.bird:
+ return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404
+ if author.longpost: author.longpost += 86400
+ else: author.longpost = int(time.time()) + 86400
+ badge_grant(user=author, badge_id=97)
+ elif kind == "bird":
+ if author.longpost:
+ return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404
+ if author.bird: author.bird += 86400
+ else: author.bird = int(time.time()) + 86400
+ badge_grant(user=author, badge_id=95)
+ elif kind == "eye":
+ author.eye = True
+ badge_grant(badge_id=83, user=author)
+ elif kind == "offsitementions":
+ author.offsitementions = True
+ badge_grant(user=author, badge_id=140)
+ elif kind == "alt":
+ author.alt = True
+ badge_grant(badge_id=84, user=author)
+ elif kind == "unblockable":
+ author.unblockable = True
+ badge_grant(badge_id=87, user=author)
+ for block in g.db.query(UserBlock).filter_by(target_id=author.id).all(): g.db.delete(block)
+ elif kind == "fish":
+ author.fish = True
+ badge_grant(badge_id=90, user=author)
+ elif kind == "progressivestack":
+ if not FEATURES['PINS']:
+ abort(403)
+ if author.progressivestack: author.progressivestack += 21600
+ else: author.progressivestack = int(time.time()) + 21600
+ badge_grant(user=author, badge_id=94)
+ elif kind == "benefactor":
+ if author.patron: return {"error": "This user is already a paypig!"}, 400
+ author.patron = 1
+ if author.patron_utc: author.patron_utc += 2629746
+ else: author.patron_utc = int(time.time()) + 2629746
+ author.procoins += 2500
+ if author.discord_id: add_role(author, "1")
+ badge_grant(user=v, badge_id=103)
+ elif kind == "rehab":
+ if author.rehab: author.rehab += 86400
+ else: author.rehab = int(time.time()) + 86400
+ badge_grant(user=author, badge_id=109)
+ elif kind == "deflector":
+ if author.deflector: author.deflector += 36000
+ else: author.deflector = int(time.time()) + 36000
+ elif kind == "beano":
+ badge_grant(user=author, badge_id=128)
+ elif kind == "checkmark":
+ author.verified = "Verified"
+ badge_grant(user=author, badge_id=150)
+ elif kind == 'marsify':
+ if author.marsify: author.marsify += 21600
+ else: author.marsify = int(time.time()) + 21600
+ badge_grant(user=author, badge_id=170)
+
+ if thing_type == 'comment' and (not author.deflector or v.id == AEVANN_ID):
+ body = thing.body
+ if author.owoify: body = owoify(body)
+ body = marsify(body)
+ thing.body_html = sanitize(body, limit_pings=5)
+ g.db.add(thing)
+ elif "Vampire" in kind and kind == v.house:
+ if author.bite: author.bite += 86400
+ else: author.bite = int(time.time()) + 86400
+
+ if not author.old_house:
+ author.old_house = author.house
+
+ if 'Vampire' not in author.house:
+ author.house = 'Vampire'
+
+ badge_grant(user=author, badge_id=168)
+ elif "Racist" in kind and kind == v.house:
+ if author.earlylife: author.earlylife += 86400
+ else: author.earlylife = int(time.time()) + 86400
+ badge_grant(user=author, badge_id=169)
+ elif ("Furry" in kind and kind == v.house) or kind == 'owoify':
+ if author.owoify: author.owoify += 21600
+ else: author.owoify = int(time.time()) + 21600
+ badge_grant(user=author, badge_id=167)
+
+ if thing_type == 'comment' and not (author.deflector or v.id == AEVANN_ID):
+ body = thing.body
+ body = owoify(body)
+ if author.marsify: body = marsify(body)
+ thing.body_html = sanitize(body, limit_pings=5)
+ g.db.add(thing)
+ elif ("Femboy" in kind and kind == v.house):
+ if author.rainbow: author.rainbow += 86400
+ else: author.rainbow = int(time.time()) + 86400
+ badge_grant(user=author, badge_id=171)
+
+ if author.received_award_count: author.received_award_count += 1
+ else: author.received_award_count = 1
+ g.db.add(author)
+
+ if request.referrer and len(request.referrer) > 1:
+ if request.referrer == f'{SITE_FULL}/submit': return redirect(thing.permalink)
+ elif request.referrer.startswith(f'{SITE_FULL}/'): return redirect(request.referrer)
+ return redirect(SITE_FULL)
+
+
+
+@app.get("/admin/awards")
+@admin_level_required(2)
+def admin_userawards_get(v):
+ if not FEATURES['AWARDS']:
+ abort(404)
+
+ if SITE == 'pcmemes.net' and v.admin_level < 3: abort(403)
+
+ if v.admin_level != 3:
+ return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v)
+
+ return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v)
+
+@app.post("/admin/awards")
+@limiter.limit("1/second;30/minute;200/hour;1000/day")
+@admin_level_required(2)
+def admin_userawards_post(v):
+ if not FEATURES['AWARDS']:
+ abort(404)
+
+ if SITE == 'pcmemes.net' and v.admin_level < 3: abort(403)
+
+ if SITE == 'watchpeopledie.co' and v.id not in (AEVANN_ID, CARP_ID, SNAKES_ID): abort(403)
+
+ try: u = request.values.get("username").strip()
+ except: abort(404)
+
+ whitelist = ("shit", "fireflies", "train", "scooter", "wholesome", "tilt", "glowie")
+
+ u = get_user(u, graceful=False, v=v)
+
+ notify_awards = {}
+
+ for key, value in request.values.items():
+ if key not in AWARDS: continue
+
+ if v.admin_level < 3 and key not in whitelist: continue
+
+ if value:
+
+ if int(value) > 10: abort(403)
+
+ if int(value): notify_awards[key] = int(value)
+
+ for x in range(int(value)):
+ award = AwardRelationship(
+ user_id=u.id,
+ kind=key,
+ granted=True
+ )
+
+ g.db.add(award)
+
+ if v.id != u.id:
+ text = f"@{v.username} has given you the following awards:\n\n"
+ for key, value in notify_awards.items():
+ text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
+ send_repeatable_notification(u.id, text)
+
+ note = ""
+
+ for key, value in notify_awards.items():
+ note += f"{value} {AWARDS[key]['title']}, "
+
+ if len(note) > 500: return {"error": "You're giving too many awards at the same time!"}, 400
+
+ ma=ModAction(
+ kind="grant_awards",
+ user_id=v.id,
+ target_user_id=u.id,
+ _note=note[:-2]
+ )
+ g.db.add(ma)
+
+
+ if v.admin_level != 3: return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v, msg=f"Awards granted to @{u.username} successfully!")
+ return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v, msg=f"Awards granted to @{u.username} successfully!")
+
diff --git a/files/routes/posts.py b/files/routes/posts.py
index 5e75687cd..1ffa53943 100644
--- a/files/routes/posts.py
+++ b/files/routes/posts.py
@@ -709,14 +709,6 @@ def submit_post(v, sub=None):
if not sub and HOLE_REQUIRED:
return error(f"You must choose a {HOLE_NAME} for your post!")
- category = None
- if FEATURES['CATEGORIES']:
- category_id = request.values.get('category', '')
- try:
- category = int(category_id)
- except:
- category = None
-
if v.is_suspended: return error("You can't perform this action while banned.")
torture = (v.agendaposter and not v.marseyawarded and sub != 'chudrama')
@@ -933,7 +925,6 @@ def submit_post(v, sub=None):
title=title[:500],
title_html=title_html,
sub=sub,
- category_id=category,
ghost=ghost
)
@@ -1168,42 +1159,6 @@ def toggle_post_nsfw(pid, v):
if post.over_18: return {"message": "Post has been marked as +18!"}
else: return {"message": "Post has been unmarked as +18!"}
-@app.post("/post_recategorize")
-@auth_required
-def post_recategorize(v):
- if not FEATURES['CATEGORIES']:
- abort(404)
- if v.admin_level < PERMS['ADMIN_CATEGORIES_CHANGE']:
- abort(403)
-
- post_id = request.values.get("post_id")
- category_id = request.values.get("category_id")
- try:
- pid = int(post_id)
- cid = None
- if category_id != '':
- cid = int(category_id)
- except:
- abort(400)
-
- post = g.db.get(Submission, pid)
- post.category_id = cid
- g.db.add(post)
-
- category_new_name = '<none>'
- if category_id != '':
- category_new_name = g.db.get(Category, cid).name
- ma = ModAction(
- kind='post_recategorize',
- user_id=v.id,
- target_submission_id=post.id,
- _note=category_new_name
- )
- g.db.add(ma)
-
- g.db.commit()
- return {"message": "Success!"}
-
@app.post("/save_post/")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
diff --git a/files/routes/settings.py b/files/routes/settings.py
index cb94d13c5..e28162488 100644
--- a/files/routes/settings.py
+++ b/files/routes/settings.py
@@ -104,6 +104,9 @@ def settings_profile_post(v):
updated = True
v.marsify = int(request.values.get("marsify") == 'true')
if v.marsify: badge_grant(user=v, badge_id=170)
+ else:
+ badge = v.has_badge(170)
+ if badge: g.db.delete(badge)
elif request.values.get("bio") == "":
v.bio = None
@@ -129,7 +132,7 @@ def settings_profile_post(v):
g.db.add(v)
return render_template("settings_profile.html", v=v, msg="Your enemies list has been updated.")
- elif (v.patron or v.id == MOOSE_ID) and request.values.get("sig"):
+ elif v.patron and request.values.get("sig"):
sig = request.values.get("sig")[:200].replace('\n','').replace('\r','')
sig_html = sanitize(sig)
diff --git a/files/routes/static.py b/files/routes/static.py
index 20469cb5b..c050d098b 100644
--- a/files/routes/static.py
+++ b/files/routes/static.py
@@ -193,37 +193,6 @@ def static_megathread_index(v):
def api(v):
return render_template("api.html", v=v)
-
-@app.get("/order")
-@auth_desired
-def order(v):
- if not FEATURES['ORDER']: abort(404)
- if v: return redirect("/")
- return render_template("order.html", v=v)
-
-@app.post("/order")
-@limiter.limit("1/hour;2/day")
-def submit_order():
- if not FEATURES['ORDER']: abort(404)
-
- body = request.values.get("message")
- if not body: abort(400)
-
- body = 'This message has been sent automatically to all admins via [/order](/order)\n\nMessage:\n\n' + body
- body = body.strip()
- body_html = sanitize(body)
- new_comment = Comment(author_id=AUTOJANNY_ID, parent_submission=None, level=1, body_html=body_html, sentto=2)
- g.db.add(new_comment)
- g.db.flush()
-
- new_comment.top_comment_id = new_comment.id
-
- for admin in g.db.query(User).filter(User.admin_level > 2, User.id != AEVANN_ID).all():
- notif = Notification(comment_id=new_comment.id, user_id=admin.id)
- g.db.add(notif)
-
- return {"success": True}
-
@app.get("/contact")
@app.get("/contactus")
@app.get("/contact_us")
@@ -262,7 +231,7 @@ def submit_contact(v):
g.db.flush()
new_comment.top_comment_id = new_comment.id
- for admin in g.db.query(User).filter(User.admin_level > 2, User.id != AEVANN_ID).all():
+ for admin in g.db.query(User).filter(User.admin_level > 2).all():
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)
@@ -466,16 +435,4 @@ def knowledgebase(v, page):
if not os.path.exists('files/templates/' + template_path):
abort(404)
- return render_template(template_path, v=v)
-
-@app.get("/categories.json")
-def categories_json():
- categories = g.db.query(Category).all()
-
- data = {}
- for c in categories:
- sub = c.sub if c.sub else ''
- sub_cats = (data[sub] if sub in data else []) + [c.as_json()]
- data.update({sub: sub_cats})
-
- return jsonify(data)
+ return render_template(template_path, v=v)
\ No newline at end of file
diff --git a/files/routes/users.py b/files/routes/users.py
index d90f9a7d8..887990e0b 100644
--- a/files/routes/users.py
+++ b/files/routes/users.py
@@ -826,7 +826,7 @@ def messagereply(v):
if c.top_comment.sentto == 2:
- admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level > 2, User.id != v.id, User.id != AEVANN_ID).all()]
+ admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level > 2, User.id != v.id).all()]
if parent.author.id not in admins:
admins.append(parent.author.id)
diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html
index c0466fd1c..5b22dc091 100644
--- a/files/templates/admin/admin_home.html
+++ b/files/templates/admin/admin_home.html
@@ -94,9 +94,6 @@
{% if v.admin_level > 2 %}
diff --git a/files/templates/admin/awards.html b/files/templates/admin/awards.html
index fe9c4bc2f..20f740bd2 100644
--- a/files/templates/admin/awards.html
+++ b/files/templates/admin/awards.html
@@ -53,7 +53,7 @@
|
{{a['title']}} |
- |
+ |
{% endfor %}
diff --git a/files/templates/admin/categories.html b/files/templates/admin/categories.html
deleted file mode 100644
index e279f581c..000000000
--- a/files/templates/admin/categories.html
+++ /dev/null
@@ -1,51 +0,0 @@
-{% extends "default.html" %}
-
-{% block title %}
- Admin — Categories
-{% endblock %}
-
-{% block content %}
-
-
-
- Category |
- {{ HOLE_NAME | capitalize }} |
- Name |
- Text Color |
- Background Color |
- Actions |
- |
-
-
-
- {% for category in categories %}
-
- {{help.submission_category_tag(category.name, category.color_text, category.color_bg)}} |
- {{category.sub if category.sub else '—'|safe}} |
-
-
-
- {% endfor %}
-
-
-
-
-
-{% endblock %}
diff --git a/files/templates/category_modal.html b/files/templates/category_modal.html
deleted file mode 100644
index 85a91878b..000000000
--- a/files/templates/category_modal.html
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
diff --git a/files/templates/comments.html b/files/templates/comments.html
index 1bb01ba3a..6ca262425 100644
--- a/files/templates/comments.html
+++ b/files/templates/comments.html
@@ -756,9 +756,6 @@
{% include "emoji_modal.html" %}
{% if v.admin_level > 1 %}
{% include "ban_modal.html" %}
- {% if FEATURES['CATEGORIES'] -%}
- {% include "category_modal.html" %}
- {%- endif %}
{% endif %}