From 260091eaee1d71eb2f83b31581cd1df8d8972f2d Mon Sep 17 00:00:00 2001 From: justcool393 Date: Sat, 5 Nov 2022 03:37:03 -0500 Subject: [PATCH] assets: fix issue noted in 77e5da55efbcf71e1d4c4689488356b98debb12a as it is, this is a backend issue. unforunately, there's no way in the UI that shows the name, image, or current tags, so that's why we insert it into the page this change brings two ways to keep the current tag as a sanity check: this also makes it so that you can't tag stuff as the string None --- files/routes/asset_submissions.py | 10 ++++------ files/templates/update_assets.html | 7 ++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index af035584d3..a5208a4c0c 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -325,7 +325,6 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'): return {"message": f"'{hat.name}' approved!"} - @app.post("/remove/hat/") @auth_required def remove_hat(v, name): @@ -342,9 +341,10 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'): if name: marsey = g.db.get(Marsey, name) if marsey: - tags = marsey.tags + tags = marsey.tags or '' else: - name = None + name = '' + tags = '' error = "A marsey with this name doesn't exist!" return render_template("update_assets.html", v=v, error=error, name=name, tags=tags, type="Marsey") @@ -391,7 +391,7 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'): process_image(filename, resize=200, trim=True) purge_files_in_cache([f"https://{SITE}/e/{name}.webp", f"https://{SITE}/assets/images/emojis/{name}.webp", f"https://{SITE}/asset_submissions/marseys/original/{name}.{format}"]) - if tags and existing.tags != tags: + if tags and existing.tags != tags and tags != "None": existing.tags = tags g.db.add(existing) elif not file: @@ -403,7 +403,6 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'): _note=f'{name}' ) g.db.add(ma) - return render_template("update_assets.html", v=v, msg=f"'{name}' updated successfully!", name=name, tags=tags, type="Marsey") @app.get("/admin/update/hats") @@ -467,5 +466,4 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'): _note=f'{name}' ) g.db.add(ma) - return render_template("update_assets.html", v=v, msg=f"'{name}' updated successfully!", type="Hat") diff --git a/files/templates/update_assets.html b/files/templates/update_assets.html index 88e0247b1b..c27b168076 100644 --- a/files/templates/update_assets.html +++ b/files/templates/update_assets.html @@ -1,11 +1,8 @@ {% extends "default.html" %} - {% block title %} Update {{type}} {% endblock %} - {% block pagetype %}message{% endblock %} - {% block content %} {% if error %} - + {% if type == "Marsey" %} - + {% endif %}