assets: fix issue noted in 77e5da55ef

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
remotes/1693176582716663532/tmp_refs/heads/watchparty
justcool393 2022-11-05 03:37:03 -05:00
parent 927e5a7cee
commit 260091eaee
2 changed files with 6 additions and 11 deletions

View File

@ -325,7 +325,6 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'):
return {"message": f"'{hat.name}' approved!"} return {"message": f"'{hat.name}' approved!"}
@app.post("/remove/hat/<name>") @app.post("/remove/hat/<name>")
@auth_required @auth_required
def remove_hat(v, name): def remove_hat(v, name):
@ -342,9 +341,10 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'):
if name: if name:
marsey = g.db.get(Marsey, name) marsey = g.db.get(Marsey, name)
if marsey: if marsey:
tags = marsey.tags tags = marsey.tags or ''
else: else:
name = None name = ''
tags = ''
error = "A marsey with this name doesn't exist!" 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") 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) 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}"]) 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 existing.tags = tags
g.db.add(existing) g.db.add(existing)
elif not file: elif not file:
@ -403,7 +403,6 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'):
_note=f'<a href="/e/{name}.webp">{name}</a>' _note=f'<a href="/e/{name}.webp">{name}</a>'
) )
g.db.add(ma) g.db.add(ma)
return render_template("update_assets.html", v=v, msg=f"'{name}' updated successfully!", name=name, tags=tags, type="Marsey") return render_template("update_assets.html", v=v, msg=f"'{name}' updated successfully!", name=name, tags=tags, type="Marsey")
@app.get("/admin/update/hats") @app.get("/admin/update/hats")
@ -467,5 +466,4 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'):
_note=f'<a href="/i/hats/{name}.webp">{name}</a>' _note=f'<a href="/i/hats/{name}.webp">{name}</a>'
) )
g.db.add(ma) g.db.add(ma)
return render_template("update_assets.html", v=v, msg=f"'{name}' updated successfully!", type="Hat") return render_template("update_assets.html", v=v, msg=f"'{name}' updated successfully!", type="Hat")

View File

@ -1,11 +1,8 @@
{% extends "default.html" %} {% extends "default.html" %}
{% block title %} {% block title %}
<title>Update {{type}}</title> <title>Update {{type}}</title>
{% endblock %} {% endblock %}
{% block pagetype %}message{% endblock %} {% block pagetype %}message{% endblock %}
{% block content %} {% block content %}
{% if error %} {% if error %}
<div class="alert alert-danger alert-dismissible fade show mb-3 mt-4" role="alert"> <div class="alert alert-danger alert-dismissible fade show mb-3 mt-4" role="alert">
@ -49,11 +46,11 @@
</div> </div>
<label class="mt-3" for="name">Name</label> <label class="mt-3" for="name">Name</label>
<input autocomplete="off" type="text" id="name" class="form-control" name="name" maxlength="30" placeholder="Required" required> <input autocomplete="off" type="text" id="name" class="form-control" name="name" maxlength="30" placeholder="Required" value="{{name}}" required>
{% if type == "Marsey" %} {% if type == "Marsey" %}
<label class="mt-3" for="tags">Tags</label> <label class="mt-3" for="tags">Tags</label>
<input autocomplete="off" type="text" id="name" class="form-control" name="tags" maxlength="200" placeholder="Leave empty to keep current tags"> <input autocomplete="off" type="text" id="name" class="form-control" name="tags" maxlength="200" placeholder="Leave empty to keep current tags" value="{{tags}}">
{% endif %} {% endif %}
<div class="footer mt-4"> <div class="footer mt-4">
<div class="d-flex"> <div class="d-flex">