From c2350d36bfdbe28349f5276f913bed0c5ce1864d Mon Sep 17 00:00:00 2001 From: justcool393 Date: Sun, 6 Nov 2022 18:03:43 -0600 Subject: [PATCH] add patronage message and message for when it's enabled permanently --- files/routes/settings.py | 55 +++++++++----------------- files/templates/settings_personal.html | 29 ++++++++++---- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/files/routes/settings.py b/files/routes/settings.py index 6c3fcf2f6..d2d5ecba7 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -54,7 +54,7 @@ def settings_personal_post(v): if not request.values.get(request_name): return False current_value = getattr(v, column_name) if FEATURES['USERS_PERMANENT_WORD_FILTERS'] and current_value > 1: - abort(403, f"Cannot disable the {{friendly_name}} after you've already set it permanently!") + abort(403, f"Cannot change the {friendly_name} setting after you've already set it permanently!") request_flag = int(request.values.get(request_name, '') == 'true') if current_value and request_flag and request.values.get("permanent", '') == 'true' and request.values.get("username") == v.username: if v.client: abort(403, "Cannot set filters permanently from the API") @@ -309,37 +309,32 @@ def filters(v): return render_template("settings_filters.html", v=v, msg="Your custom filters have been updated.") +def set_color(v:User, attr:str, color:Optional[str]): + current = getattr(v, attr) + color = color.strip().lower() if color else None + if color: + if color.startswith('#'): color = color[1:] + if not color_regex.fullmatch(color): + return render_template("settings_personal.html", v=v, error="Invalid color hex code") + if color and current != color: + setattr(v, attr, color) + g.db.add(v) + return redirect("/settings/personal") + + @app.post("/settings/namecolor") @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")}') @auth_required def namecolor(v): - - color = request.values.get("color", "").strip().lower() - if color.startswith('#'): color = color[1:] - - if not color_regex.fullmatch(color): - return render_template("settings_personal.html", v=v, error="Invalid color hex code") - - v.namecolor = color - g.db.add(v) - return redirect("/settings/personal") + return set_color(v, "namecolor", request.values.get("color")) @app.post("/settings/themecolor") @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")}') @auth_required def themecolor(v): - - themecolor = str(request.values.get("themecolor", "")).strip() - if themecolor.startswith('#'): themecolor = themecolor[1:] - - if not color_regex.fullmatch(themecolor): - return render_template("settings_personal.html", v=v, error="Invalid color hex code") - - v.themecolor = themecolor - g.db.add(v) - return redirect("/settings/personal") + return set_color(v, "themecolor", request.values.get("themecolor")) @app.post("/settings/gumroad") @limiter.limit("1/second;30/minute;200/hour;1000/day") @@ -382,27 +377,15 @@ def gumroad(v): @limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}') @auth_required def titlecolor(v): - - titlecolor = request.values.get("titlecolor", "").strip().lower() - if titlecolor.startswith('#'): titlecolor = titlecolor[1:] - - if not color_regex.fullmatch(titlecolor): - return render_template("settings_personal.html", v=v, error="Invalid color hex code") - v.titlecolor = titlecolor - g.db.add(v) - return redirect("/settings/personal") + return set_color(v, "title", request.values.get("titlecolor")) @app.post("/settings/verifiedcolor") @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")}') @auth_required def verifiedcolor(v): - verifiedcolor = str(request.values.get("verifiedcolor", "")).strip() - if verifiedcolor.startswith('#'): verifiedcolor = verifiedcolor[1:] - if len(verifiedcolor) != 6: return render_template("settings_personal.html", v=v, error="Invalid color hex code") - v.verifiedcolor = verifiedcolor - g.db.add(v) - return redirect("/settings/personal") + if not v.verified: abort(403, "You don't have a checkmark") + return set_color(v, "verifiedcolor", "verifiedcolor") @app.post("/settings/security") @limiter.limit("1/second;30/minute;200/hour;1000/day") diff --git a/files/templates/settings_personal.html b/files/templates/settings_personal.html index 442383530..305de6aa5 100644 --- a/files/templates/settings_personal.html +++ b/files/templates/settings_personal.html @@ -25,7 +25,14 @@
- Internal patron level for logged in user: {{v.patron}}
Don't put this in production lol
Example text until we figure out what to put here. Dude bussy lmao + {% if v.patron %} +

You're a {{patron}}!

+ {% else %} +

You're a freeloader!

+ {% endif %} + {% if not v.patron and v.truescore >= TRUESCORE_DONATE_LIMIT %} +

To stop freeloading, first verify your email, support us on Gumroad with the same email, and click "Claim {{patron}} Rewards"

+ {% endif %}
@@ -214,10 +221,18 @@ {% set ns = namespace(slurtext='Enable if you would like to automatically replace slurs.', profanitytext='Enable if you would like to automatically replace slurs.') %} {# toggle_section(title, id, name, flag, below_text, disabled) #} {% if FEATURES['USERS_PERMANENT_WORD_FILTERS'] and v.slurreplacer %} - {% set ns.slurtext = 'Enable if you would like to automatically replace slurs. Make filter permanent for a badge!' %} + {% if v.slurreplacer == 1 %} + {% set ns.slurtext = 'Enable if you would like to automatically replace slurs. Make filter permanent for a badge!' %} + {% else %} + {% set ns.slurttext = "You've enabled the slur replacer permanently! ✊🏿" %} + {% endif %} {% endif %} {% if FEATURES['USERS_PERMANENT_WORD_FILTERS'] and v.profanityreplacer %} - {% set ns.profanitytext = 'Enable if you would like to automatically replace profanities. Make filter permanent for a badge!' %} + {% if v.profanityreplacer == 1 %} + {% set ns.profanitytext = 'Enable if you would like to automatically replace profanities. Make filter permanent for a badge!' %} + {% else %} + {% set ns.profanitytext = "You've enabled the profanity replacer permanently! 😇" %} + {% endif %} {% endif %} {{common.toggle_section("Slur Replacer", "slurreplacer", 'slurreplacer', v.slurreplacer, ns.slurtext, FEATURES['USERS_PERMANENT_WORD_FILTERS'] and v.slurreplacer > 1)}} {{common.toggle_section("Profanity Replacer", "profanityreplacer", 'profanityreplacer', v.profanityreplacer, ns.profanitytext, FEATURES['USERS_PERMANENT_WORD_FILTERS'] and v.profanityreplacer > 1)}} @@ -287,10 +302,10 @@
{%- endif %} {% endmacro %} -{% if v.slurreplacer %} +{% if v.slurreplacer == 1 -%} {{permanent_filter_modal('slurreplacer', '/settings/personal', 'slurreplacer', 'Slur Replacer', 'Social Justice Berserker')}} -{% endif %} -{% if v.profanityreplacer %} +{%- endif %} +{% if v.profanityreplacer == 1 -%} {{permanent_filter_modal('profanityreplacer', '/settings/personal', 'profanityreplacer', 'Profanity Replacer', 'Soapy-Mouthed Angel')}} -{% endif %} +{%- endif %} {% endblock %}