add button to remove current profile background

master
Aevann1 2022-12-05 17:14:53 +02:00
parent 84ec5f5b46
commit 15088e5eef
2 changed files with 29 additions and 1 deletions

View File

@ -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

View File

@ -210,6 +210,15 @@
</label>
<input autocomplete="off" id="upload-profile-background-file" accept="image/*", type="file" name="file" onchange="this.form.submit()" hidden>
</form>
{% if v.profile_background -%}
<div class="d-flex mb-3">
<button type="button" class="btn btn-danger" onclick="postToastReload(this,'/settings/profile_background', 'DELETE')">
<i class="fas fa-image-slash mr-1"></i>
Remove current background
</button>
</div>
{%- 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 @@
</label>
<input autocomplete="off" id="upload-profile-background-file-mobile" accept="image/*", type="file" name="file" onchange="this.form.submit()" hidden>
</form>
{% if v.profile_background -%}
<div class="d-block mt-3 mb-3">
<button type="button" class="btn btn-danger" onclick="postToastReload(this,'/settings/profile_background', 'DELETE')">
<i class="fas fa-image-slash mr-1"></i>
Remove current background
</button>
</div>
{%- endif %}
</div>
{% endif %}