From 15088e5eefa1d926aa10698f8121a14e697cd743 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 5 Dec 2022 17:14:53 +0200 Subject: [PATCH] add button to remove current profile background --- files/routes/settings.py | 12 +++++++++++- files/templates/userpage/userpage.html | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/files/routes/settings.py b/files/routes/settings.py index 5458303df..0a40ae22f 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -89,9 +89,19 @@ def upload_profile_background(v): os.remove(v.profile_background) v.profile_background = background g.db.add(v) - badge_grant(badge_id=193, user=v) + # badge_grant(badge_id=193, user=v) return redirect(f'/@{v.username}') +@app.delete('/settings/profile_background') +@limiter.limit(DEFAULT_RATELIMIT_SLOWER) +@auth_required +@ratelimit_user() +def delete_profile_background(v): + if v.profile_background: + os.remove(v.profile_background) + v.profile_background = None + return {"message": "Profile background removed!"} + @app.post("/settings/personal") @limiter.limit(DEFAULT_RATELIMIT_SLOWER) @auth_required diff --git a/files/templates/userpage/userpage.html b/files/templates/userpage/userpage.html index 57e7cb9b7..69a33a939 100644 --- a/files/templates/userpage/userpage.html +++ b/files/templates/userpage/userpage.html @@ -210,6 +210,15 @@ + + {% if v.profile_background -%} +
+ +
+ {%- endif %} {% endif %} {% if FEATURES['USERS_PROFILE_SONG'] and u.song and v and (v.id == u.id or v.mute and not u.unmutable) %} @@ -428,6 +437,15 @@ + + {% if v.profile_background -%} +
+ +
+ {%- endif %} {% endif %}