From 34eb58c9cb890067978b64660067fa3446a7c8f0 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 27 Oct 2021 02:37:34 +0200 Subject: [PATCH] bruh --- files/classes/user.py | 2 + files/helpers/const.py | 16 +++- files/routes/awards.py | 73 ++++++++++++------ files/routes/comments.py | 9 +++ files/routes/posts.py | 9 +++ files/routes/settings.py | 14 +++- files/routes/static.py | 2 +- files/templates/authforms.html | 6 +- files/templates/award_modal.html | 17 ++--- files/templates/comments.html | 8 +- files/templates/default.html | 8 +- files/templates/formatting.html | 9 ++- files/templates/log.html | 6 +- files/templates/login_2fa.html | 2 +- files/templates/settings.html | 4 +- files/templates/settings2.html | 4 +- files/templates/settings_profile.html | 98 ++++++++++++++++++------- files/templates/shop.html | 7 +- files/templates/sign_up.html | 2 +- files/templates/sign_up_failed_ref.html | 2 +- files/templates/submission.html | 2 +- files/templates/submission_listing.html | 2 +- files/templates/submit.html | 8 +- files/templates/userpage.html | 4 +- schema.sql | 2 + 25 files changed, 224 insertions(+), 92 deletions(-) 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 @@
{{award.owned}} owned
{% endfor %} - + + +
 
+
 
+
@@ -62,7 +59,7 @@ opacity: 0.6; } - .awards-wrapper a:hover, .awards-wrapper .picked { + .awards-wrapper a:hover:not(.disabled), .awards-wrapper .picked { background-color: var(--primary)!important; } @@ -76,7 +73,7 @@ @media (min-width: 767.98px) { .award-columns { - column-count: 6 !important; + column-count: 7 !important; } } \ No newline at end of file diff --git a/files/templates/comments.html b/files/templates/comments.html index 96c2abeb0..7836f252c 100755 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -241,7 +241,11 @@ {% elif c.author_id==NOTIFICATIONS_ACCOUNT or c.author_id==AUTOJANNY_ACCOUNT %} {{'SITE_NAME' | app_config}} Notification {% else %} - Sent to @{{c.senttouser.username}} + {% if c.sentto == 0 %} + Sent to admins + {% else %} + Sent to @{{c.senttouser.username}} + {% endif %} {% endif %} @@ -278,7 +282,7 @@ {% if c.is_blocking %}{% endif %} {% if c.is_blocked %}{% endif %} - {% if c.author.verified %} + {% if c.author.verified %} {% endif %} {{c.author.username}} diff --git a/files/templates/default.html b/files/templates/default.html index de7d957b3..17adedd98 100755 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -254,12 +254,12 @@ {% if v %} - - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} {% endblock %} diff --git a/files/templates/formatting.html b/files/templates/formatting.html index f2b979e2c..7639db80f 100755 --- a/files/templates/formatting.html +++ b/files/templates/formatting.html @@ -495,4 +495,11 @@ line breaks {% include "expanded_image_modal.html" %} -{% endblock %} + + +{% endblock %} \ No newline at end of file diff --git a/files/templates/log.html b/files/templates/log.html index 733945d0a..e608c4981 100755 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -17,11 +17,11 @@ {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %}
diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index 0f201b02b..9e4861777 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 766cd18d8..98b18bf5b 100755 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -55,8 +55,8 @@ - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index 81259caf1..04fef5116 100755 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -40,10 +40,10 @@ {% if v %} - + {% else %} - + {% endif %} diff --git a/files/templates/settings_profile.html b/files/templates/settings_profile.html index 9894fa858..205efee75 100755 --- a/files/templates/settings_profile.html +++ b/files/templates/settings_profile.html @@ -468,40 +468,88 @@
- + -
+
-
- + + - {% for titlecolor in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58'] %} - - - {% endfor %} + {% for titlecolor in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58'] %} + + + {% endfor %} +
+ +
+ + + +

Or type a color code:

+
+
+ + +
+
-

Or type a color code:

-
-
- - - -
-
-
+ + + + {% if v.verified %} + +
+ + + +
+ +
+ + + {% for verifiedcolor in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58'] %} + + + {% endfor %} + +
+ +
+ +

Or type a color code:

+
+
+ + + +
+
+ +
+ {% endif %} + +
diff --git a/files/templates/shop.html b/files/templates/shop.html index 36fce570a..71d06e9e6 100644 --- a/files/templates/shop.html +++ b/files/templates/shop.html @@ -56,7 +56,7 @@ {% for a in awards %} - + {{a['title']}} {{a['price']}} @@ -92,5 +92,10 @@ font-size: 0.7rem !important; } } + + .tooltip-inner { + font-size: 1.5rem; + max-width: 300px; + } {% endblock %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index 3cb39c81e..a47d087ef 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 6200da84a..10671e872 100755 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -31,7 +31,7 @@ - + diff --git a/files/templates/submission.html b/files/templates/submission.html index 308d69ca7..8d7085071 100755 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -424,7 +424,7 @@ {% if p.over_18 %}+18{% endif %} {% if p.private %}Draft{% endif %} {% if p.active_flags %}{{p.active_flags}} Reports{% endif %} - {% if p.author.verified %} + {% if p.author.verified %} {% endif %} {{p.author.username}}{% if p.author.customtitle %}  {% if p.author.quadrant %}{% endif %}{{p.author.customtitle | safe}}{% endif %}  {{p.age_string}} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index eb785dbf7..d7630d034 100755 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -192,7 +192,7 @@ {% if p.is_blocked %}{% endif %} {% if p.private %}Draft{% endif %} {% if p.active_flags %}{{p.active_flags}} Reports{% endif %} - {% if p.author.verified %} + {% if p.author.verified %} {% endif %} {{p.author.username}}{% if p.author.customtitle %}  {% if p.author.quadrant %}{% endif %}{{p.author.customtitle | safe}}{% endif %}  {{p.age_string}} diff --git a/files/templates/submit.html b/files/templates/submit.html index 16dc5ed80..7eeb81cd2 100755 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -25,12 +25,12 @@ {% block stylesheets %} {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - - + + {% endif %} {% endblock %} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index e77866783..8c8276fd4 100755 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -117,7 +117,7 @@ {% endif %} - {% if u.verified %}{% endif %} + {% if u.verified %}{% endif %} {% if u.admin_level > 1 or (u.admin_level == 1 and (not v or v.admin_level < 2)) %} @@ -404,7 +404,7 @@
BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}
{% if u.unban_utc %}
{{u.unban_string}}
{% endif %} {% endif %} - {% if u.verified %} {% endif %} + {% if u.verified %} {% endif %}

{{u.username}}

{% if u.username != u.original_username %} diff --git a/schema.sql b/schema.sql index c1418f112..877cf9d08 100755 --- a/schema.sql +++ b/schema.sql @@ -799,6 +799,8 @@ CREATE TABLE public.users ( controversial boolean, background character varying(20), verified character varying(20), + verifiedcolor character varying(6), + marseyawarded boolean, fail_utc integer, steal_utc integer, fail2_utc integer,