diff --git a/files/classes/user.py b/files/classes/user.py index 57d93d289..729ef8d0e 100755 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -47,6 +47,8 @@ class User(Base): bannerurl = Column(String) patron = Column(Integer, default=0) verified = Column(String) + verifiedcolor = Column(String) + marseyawarded = Column(String) email = Column(String) css = deferred(Column(String)) profilecss = deferred(Column(String)) diff --git a/files/helpers/const.py b/files/helpers/const.py index 273333b64..4e8758c39 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -190,7 +190,7 @@ if SITE_NAME == "Drama": "flairlock": { "kind": "flairlock", "title": "1-Day Flairlock", - "description": "Sets a flair for the author and locks it or 24 hours.", + "description": "Sets a flair for the recipient and locks it or 24 hours.", "icon": "fas fa-lock", "color": "text-black", "price": 1250 @@ -198,15 +198,23 @@ if SITE_NAME == "Drama": "agendaposter": { "kind": "agendaposter", "title": "Agendaposter", - "description": "Forces the agendaposter theme on the author for 24 hours.", + "description": "Forces the agendaposter theme on the recipient for 24 hours.", "icon": "fas fa-snooze", "color": "text-purple", "price": 2000 }, + "marsey": { + "kind": "marsey", + "title": "Marsey", + "description": "Makes the recipient unable to post/comment anything but marsey emojis for 24 hours.", + "icon": "fas fa-cat", + "color": "text-orange", + "price": 3000 + }, "ban": { "kind": "ban", "title": "1-Day Ban", - "description": "Bans the author for a day.", + "description": "Bans the recipient for a day.", "icon": "fas fa-gavel", "color": "text-danger", "price": 3000 @@ -222,7 +230,7 @@ if SITE_NAME == "Drama": "grass": { "kind": "grass", "title": "Grass", - "description": "Ban the author permanently (must provide a timestamped picture of them touching grass to the admins to get unbanned)", + "description": "Ban the recipient permanently (must provide a timestamped picture of them touching grass to the admins to get unbanned)", "icon": "fas fa-seedling", "color": "text-success", "price": 10000 diff --git a/files/routes/awards.py b/files/routes/awards.py index a45141942..e3d50e4f3 100755 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -12,7 +12,7 @@ AWARDS2 = { "ban": { "kind": "ban", "title": "1-Day Ban", - "description": "Bans the author for a day.", + "description": "Bans the recipient for a day.", "icon": "fas fa-gavel", "color": "text-danger", "price": 3000 @@ -89,7 +89,7 @@ def shop(v): "flairlock": { "kind": "flairlock", "title": "1-Day Flairlock", - "description": "Sets a flair for the author and locks it or 24 hours.", + "description": "Sets a flair for the recipient and locks it or 24 hours.", "icon": "fas fa-lock", "color": "text-black", "owned": 0, @@ -98,16 +98,25 @@ def shop(v): "agendaposter": { "kind": "agendaposter", "title": "Agendaposter", - "description": "Forces the agendaposter theme on the author for 24 hours.", + "description": "Forces the agendaposter theme on the recipient for 24 hours.", "icon": "fas fa-snooze", "color": "text-purple", "owned": 0, "price": 2000 }, + "marsey": { + "kind": "marsey", + "title": "Marsey", + "description": "Makes the recipient unable to post/comment anything but marsey emojis for 24 hours.", + "icon": "fas fa-cat", + "color": "text-orange", + "owned": 0, + "price": 3000 + }, "ban": { "kind": "ban", "title": "1-Day Ban", - "description": "Bans the author for a day.", + "description": "Bans the recipient for a day.", "icon": "fas fa-gavel", "color": "text-danger", "owned": 0, @@ -125,7 +134,7 @@ def shop(v): "grass": { "kind": "grass", "title": "Grass", - "description": "Ban the author permanently (must provide a timestamped picture of them touching grass to the admins to get unbanned)", + "description": "Ban the recipient permanently (must provide a timestamped picture of them touching grass to the admins to get unbanned)", "icon": "fas fa-seedling", "color": "text-success", "owned": 0, @@ -284,7 +293,7 @@ def buy(v, award): "flairlock": { "kind": "flairlock", "title": "1-Day Flairlock", - "description": "Sets a flair for the author and locks it or 24 hours.", + "description": "Sets a flair for the recipient and locks it or 24 hours.", "icon": "fas fa-lock", "color": "text-black", "price": 1250 @@ -292,15 +301,23 @@ def buy(v, award): "agendaposter": { "kind": "agendaposter", "title": "Agendaposter", - "description": "Forces the agendaposter theme on the author for 24 hours.", + "description": "Forces the agendaposter theme on the recipient for 24 hours.", "icon": "fas fa-snooze", "color": "text-purple", "price": 2000 }, + "marsey": { + "kind": "marsey", + "title": "Marsey", + "description": "Makes the recipient unable to post/comment anything but marsey emojis for 24 hours.", + "icon": "fas fa-cat", + "color": "text-orange", + "price": 3000 + }, "ban": { "kind": "ban", "title": "1-Day Ban", - "description": "Bans the author for a day.", + "description": "Bans the recipient for a day.", "icon": "fas fa-gavel", "color": "text-danger", "price": 3000 @@ -316,7 +333,7 @@ def buy(v, award): "grass": { "kind": "grass", "title": "Grass", - "description": "Ban the author permanently (must provide a timestamped picture of them touching grass to the admins to get unbanned)", + "description": "Ban the recipient permanently (must provide a timestamped picture of them touching grass to the admins to get unbanned)", "icon": "fas fa-seedling", "color": "text-success", "price": 10000 @@ -569,6 +586,8 @@ def award_post(pid, v): send_notification(995, f"@{v.username} bought {kind} award!") new_badge = Badge(badge_id=67, user_id=author.id) g.db.add(new_badge) + elif kind == "marsey": + author.marseyawarded = True post.author.received_award_count += 1 g.db.add(post.author) @@ -686,6 +705,8 @@ def award_comment(cid, v): send_notification(995, f"@{v.username} bought {kind} award!") new_badge = Badge(badge_id=67, user_id=author.id) g.db.add(new_badge) + elif kind == "marsey": + author.marseyawarded = True c.author.received_award_count += 1 g.db.add(c.author) @@ -804,7 +825,7 @@ def items(v): "flairlock": { "kind": "flairlock", "title": "1-Day Flairlock", - "description": "Sets a flair for the author and locks it or 24 hours.", + "description": "Sets a flair for the recipient and locks it or 24 hours.", "icon": "fas fa-lock", "color": "text-black", "owned": 0, @@ -813,16 +834,25 @@ def items(v): "agendaposter": { "kind": "agendaposter", "title": "Agendaposter", - "description": "Forces the agendaposter theme on the author for 24 hours.", + "description": "Forces the agendaposter theme on the recipient for 24 hours.", "icon": "fas fa-snooze", "color": "text-purple", "owned": 0, "price": 2000 }, + "marsey": { + "kind": "marsey", + "title": "Marsey", + "description": "Makes the recipient unable to post/comment anything but marsey emojis for 24 hours.", + "icon": "fas fa-cat", + "color": "text-orange", + "owned": 0, + "price": 3000 + }, "ban": { "kind": "ban", "title": "1-Day Ban", - "description": "Bans the author for a day.", + "description": "Bans the recipient for a day.", "icon": "fas fa-gavel", "color": "text-danger", "owned": 0, @@ -840,7 +870,7 @@ def items(v): "grass": { "kind": "grass", "title": "Grass", - "description": "Ban the author permanently (must provide a timestamped picture of them touching grass to the admins to get unbanned)", + "description": "Ban the recipient permanently (must provide a timestamped picture of them touching grass to the admins to get unbanned)", "icon": "fas fa-seedling", "color": "text-success", "owned": 0, @@ -868,17 +898,16 @@ def items(v): for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all(): AWARDS[useraward.kind]["owned"] += 1 - if v.patron == 1: discount = 0.90 - elif v.patron == 2: discount = 0.85 - elif v.patron == 3: discount = 0.80 - elif v.patron == 4: discount = 0.75 - elif v.patron == 5: discount = 0.70 - else: discount = 1 + if v.patron == 1: discount = 0.10 + elif v.patron == 2: discount = 0.15 + elif v.patron == 3: discount = 0.20 + elif v.patron == 4: discount = 0.25 + elif v.patron == 5: discount = 0.30 + 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 += 0.02 - for val in AWARDS.values(): - val["price"] = int(val["price"]*discount) + for val in AWARDS.values(): val["discount"] = discount return AWARDS \ No newline at end of file diff --git a/files/routes/comments.py b/files/routes/comments.py index 18cb680c6..eae28e7ed 100755 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -155,6 +155,10 @@ def api_comment(v): body = request.values.get("body", "").strip()[:10000] body = body.strip() + if v.marseyawarded: + marregex = list(re.finditer("^(:!?mar\w+:\s*)+$", body)) + if len(marregex) == 0: return {"error":"You need to only type marseys!"}, 403 + if not body and not request.files.get('file'): return {"error":"You need to actually write something!"}, 400 for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): @@ -584,6 +588,11 @@ def edit_comment(cid, v): if c.is_banned or c.deleted_utc > 0: abort(403) body = request.values.get("body", "").strip()[:10000] + + if v.marseyawarded: + marregex = list(re.finditer("^(:!?mar\w+:\s*)+$", body)) + if len(marregex) == 0: return {"error":"You need to only type marseys!"}, 403 + for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') body_md = CustomRenderer().render(mistletoe.Document(body)) diff --git a/files/routes/posts.py b/files/routes/posts.py index 381f291de..b3ed5a6f0 100755 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -214,6 +214,10 @@ def edit_post(pid, v): title = request.values.get("title", "").strip() body = request.values.get("body", "").strip() + if v.marseyawarded: + marregex = list(re.finditer("^(:!?mar\w+:\s*)+$", body)) + if len(marregex) == 0: return {"error":"You need to only type marseys!"}, 403 + if title != p.title: p.title = title p.title_html = filter_title(title) @@ -561,6 +565,11 @@ def submit_post(v): else: render_template("submit.html", v=v, error="500 character limit for titles.", title=title[:500], url=url, body=request.values.get("body", "")), 400 body = request.values.get("body", "").strip() + + if v.marseyawarded: + marregex = list(re.finditer("^(:!?mar\w+:\s*)+$", body)) + if len(marregex) == 0: return {"error":"You need to only type marseys!"}, 403 + dup = g.db.query(Submission).options(lazyload('*')).filter( Submission.author_id == v.id, Submission.deleted_utc == 0, diff --git a/files/routes/settings.py b/files/routes/settings.py index 699ee450a..292b7f4f3 100755 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -334,11 +334,23 @@ def gumroad(v): def titlecolor(v): titlecolor = str(request.values.get("titlecolor", "")).strip() if titlecolor.startswith('#'): titlecolor = titlecolor[1:] - if len(titlecolor) != 6: return render_template("settings_security.html", v=v, error="Invalid color code") + if len(titlecolor) != 6: return render_template("settings_profile.html", v=v, error="Invalid color code") v.titlecolor = titlecolor g.db.add(v) g.db.commit() + return redirect("/settings/profile") +@app.post("/settings/verifiedcolor") +@limiter.limit("1/second") +@auth_required +@validate_formkey +def verifiedcolor(v): + verifiedcolor = str(request.values.get("verifiedcolor", "")).strip() + if verifiedcolor.startswith('#'): verifiedcolor = verifiedcolor[1:] + if len(verifiedcolor) != 6: return render_template("settings_profile.html", v=v, error="Invalid color code") + v.verifiedcolor = verifiedcolor + g.db.add(v) + g.db.commit() return redirect("/settings/profile") @app.post("/settings/security") diff --git a/files/routes/static.py b/files/routes/static.py index a24ed8e9e..ce9816f8c 100755 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -175,7 +175,7 @@ def log(v): page=int(request.args.get("page",1)) if v and v.admin_level == 6: actions = g.db.query(ModAction).order_by(ModAction.id.desc()).offset(25 * (page - 1)).limit(26).all() - else: actions=g.db.query(ModAction).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban", ModAction.kind!="club", ModAction.kind!="unclub").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all() + else: actions=g.db.query(ModAction).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban", ModAction.kind!="club", ModAction.kind!="unclub", ModAction.kind!="check").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all() next_exists=len(actions)>25 actions=actions[:25] diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 95840b20c..919b66844 100755 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -15,11 +15,11 @@ {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/award_modal.html b/files/templates/award_modal.html index 530bff6d9..18fa6d5c6 100755 --- a/files/templates/award_modal.html +++ b/files/templates/award_modal.html @@ -23,14 +23,11 @@
Or type a color code:
+Or type a color code:
-Or type a color code:
+